Shaders are used to depict how to render the game.
Java Edition
There are two kinds of shaders: core shaders and post-processing shaders.
Core shaders are used to render different parts of the game.
Post-processing shaders are used for mob view in spectator mode, blending of translucent layers in Fabulous! graphics, and glowing status effect.
Shaders are written in OpenGL Shading Language (GLSL). Each single render program come in two parts, vertex and fragment. The vertex shaders modify the positions of individual vertices and are most often used to create waving foliage and water. Fragment shaders are applied to every pixel and can be used to add effects like bloom, god rays, and blur.
Shaders are stored in the assets/minecraft/shaders/ directory of minecraft.jar. Can be replaced with a resource pack. Note that if any error occurs when loading the shaders, the resource pack will be disabled and fabulous graphics mode will be turned off.
Core shaders
Core shaders are responsible for rendering parts of the game. They are used to render not only blocks and entities when playing the game, but also the main screen, option screen and so on.
Each core shader is a single render program defined by a JSON file, in which vertex and fragment shader file are specified.
Core shaders are stored in the assets/minecraft/shaders/core directory of minecraft.jar.
The following table lists them all including a short description of what the shader renders, as well as, an image highlighting the shaders target in red.
- Fishing rod line
- Darkness vignette, and world border vignette screen effects
- The super subtle underwater screen effect
- Totem of Undying use animation
- End gateway beam (possibly different from beacon beam due to a since-fixed rendering issue MC-173745, however it may have been unified as a result)
- Wither armor
- Enchantment overlay
- Ender dragon death beams
- Ender dragon disintegration effect.
Non-rendertype
| Name | Used for | Sample Images |
|---|---|---|
| blit_screen | Blit copies one buffer to another, however this cannot be overridden in a resource pack. | |
| block | Unknown, does not seem to have any usages in code. | |
| new_entity | Unknown, does not seem to have any usages in code. | |
| particle | All particles. | |
| position |
|
|
| position_color | Used for solid color-block, including:
|
|
| position_color_lightmap | Unknown, does not seem to have any usages in code. | |
| position_color_normal | Unknown, does not seem to be referenced anywhere in code. | |
| position_color_tex |
|
|
| position_color_tex_lightmap | Unknown, does not seem to have any usages in code. | |
| position_tex | Used to render a texture:
|
|
| position_tex_color |
|
|
| position_tex_color_normal | Clouds. |
|
| position_tex_lightmap_color | Unknown, does not seem to have any usages in code. |
Rendertype
- Blocks
| Name | Description | Sample Image |
|---|---|---|
| rendertype_beacon_beam | The beam of the beacon. | |
| rendertype_crumbling | The block cracks when mining a block. | |
| rendertype_cutout | All non-cube-hitbox blocks.[verify] | |
| rendertype_cutout_mipped | Some blocks: grass blocks, iron bars, glass panes, tripwire hooks, hoppers, chains (leaves when using fancy or fabulous graphics) | |
| rendertype_end_gateway | The inside of an end gateway, reuses the same shader as rendertype_end_portal.
|
|
| rendertype_end_portal | The inside of an end portal, as well as the insides of end gateways. |
|
| rendertype_solid | All solid blocks, lava, and when in fast mode, leaves. |
|
| rendertype_translucent | Translucent blocks: water (still and flowing), ice, nether portal, stained and tinted glass, slime and honey, bubbles. |
|
| rendertype_translucent_moving_block | Blocks which are translucent and are being moved by a piston. The one below is stained glass. |
|
| rendertype_translucent_no_crumbling | Unknown, does not seem to have any usages in code. | |
| rendertype_tripwire | Tripwire (sections connected to tripwire hooks are instead rendered completely solid[1] |
|
| rendertype_water_mask | Used to mask out water surface inside a boat to to prevent it from appearing flooded. |
- Entities
- Miscellaneous
Include shaders
Include shaders aren't stand-alone shader programs. They should be invoked by other shader files.
Include shaders contain helper functions that are commonly used. To import a glsl file in a shader use #moj_import <FILENAME.glsl> or #moj_import "FILENAME.glsl". NOTE: The imported file needs to end with an empty line, otherwise the shader will not load.
Include shaders are stored in the assets/minecraft/shaders/include directory of minecraft.jar.
| Name | Description |
|---|---|
| fog | Contains the linear_fog function to calculate the color based on the vertex distance.
|
| light | Contains the minecraft_mix_light function.
|
| matrix | Contains the mat2_rotate_z function that returns the rotation matrix for a vec2 around the z-axis.
|
| projection | Contains the projection_from_position function.
|
Post-processing shaders
Currently, post-processing shaders is used for mob view in spectator mode, blending of translucent layers in Fabulous! graphics, and glowing status effect.
Post-processing shaders use "post" files to define a pipeline made up of applying a sequence of "programs".
Each "program" is then defined by another JSON file, in which a single render program is defined.
"post" files are stored in the assets/minecraft/shaders/post directory of the version .jar, while "program" files are stored in assets/minecraft/shaders/program.
There are only 5 post-processing shaders used in the game:
- creeper.json: Used when spectating a creeper
- invert.json: Used when spectating an enderman
- spider.json: Used when spectating a spider
- entity_outline.json: Used when a glowing entity is on screen
- transparency.json: Used when in "Fabulous!" graphics mode.
In these two directories, there are also many useless shaders, which were used for "Super Secret Settings" before 1.9 (15w31a). See Shaders/Before 1.9.
Render process
File format
Render program
- The root tag
- blend: Settings for OpenGL blending.
- func: Operator to be used when blending. Can be
add,subtract,reversesubtract,reverse_subtract,min, ormax. Not case sensitive. Defaults toadd. Used asmodeparameter ofglBlendEquation - srcrgb: Used as
sfactorparameter ofglBlendFuncorsrcRGBparameter ofglBlendFuncSeparate. Can be0,1,srccolor,1-srccolor,dstcolor,1-dstcolor,srcalpha,1-srcalpha,dstalpha, or1-dstalpha. Case insensitive. Ignores "_". "1", "0", "-" can be replaced by "one", "zero", "minus". - dstrgb: Used as
dfactorparameter ofglBlendFuncordstRGBparameter ofglBlendFuncSeparate. Can be0,1,srccolor,1-srccolor,dstcolor,1-dstcolor,srcalpha,1-srcalpha,dstalpha, or1-dstalpha. Case insensitive. Ignores "_". "1", "0", "-" can be replaced by "one", "zero", "minus". - srcalpha: Used as
srcalphaparameter ofglBlendFuncSeparate. Can be0,1,srccolor,1-srccolor,dstcolor,1-dstcolor,srcalpha,1-srcalpha,dstalpha, or1-dstalpha. Case insensitive. Ignores "_". "1", "0", "-" can be replaced by "one", "zero", "minus". - dstalpha: Used as
dstalphaparameter of glBlendFuncSeparate. Can be0,1,srccolor,1-srccolor,dstcolor,1-dstcolor,srcalpha,1-srcalpha,dstalpha, or1-dstalpha. Case insensitive. Ignores "_". "1", "0", "-" can be replaced by "one", "zero", "minus".
- func: Operator to be used when blending. Can be
- cull: If true, run
glEnable(GL_CULL_FACE). If false, runglDisable(GL_CULL_FACE). Defaults to true. - vertex: The name (without file extension) of the vertex shader to be used.
- fragment: The name (without file extension) of the fragment shader to be used.
- attributes: Attributes to be used by the vertex shader.
- : An attribute. Available values are hard-coded.
- samplers: A list of samplers that may be used in the shaders.
- : A sampler.
- name: The samplers name.
- file: [more information needed]
- : A sampler.
- uniforms: A list of uniforms that can be used in the shaders.
- : A uniform.
- name: The name of the uniform as referenced in the GLSL code. Some names give a uniform special behavior(Note that these following special uniform does not work in all shader programs):
- (float) Time: A value from 0 to 1, representing time in seconds. Resets every second. Only valid in post-processing shaders.
- (vec2) InSize: The width and height of the input buffer in pixels. Only valid in post-processing shaders.
- (vec2) OutSize: The width and height of the output buffer in pixels. Only valid in post-processing shaders.
- (vec2) AuxSize<i>: The width and height of the auxiliary buffer in pixels. <i> should be replaced by the order of the auxtarget in the render pass. Only valid in post-processing shaders.
- (matrix4x4) ModelViewMat: The model-view matrix. Only valid in core shaders.
- (matrix4x4) ProjMat: The projection matrix.
- (matrix4x4) TextureMat: 4D matrix used to transform UV's for item glint effects. Only valid in core shaders.
- (vec2) ScreenSize: vec2 containing the current framebuffer width and height, in that order.
- (vec4) ColorModulator: A global vec4 of multipliers that can be set from the game code as a color multiplier. Only valid in core shaders.
- (vec3) Light0_Direction: First light direction as vec3 for entity rendering. Only valid in core shaders.
- (vec3) Light1_Direction: Second light direction, see Light0_Direction. Only valid in core shaders.
- (float) FogStart: Fog start distance from the camera. Only valid in core shaders.
- (float) FogEnd: Fog end distance from the camera. Only valid in core shaders.
- (vec4) FogColor: vec4 fog color. Only valid in core shaders.
- (float) LineWidth: Line width, used for rendering wireframe lines such as the block selection frame and debug hitboxes. Only valid in core shaders.
- (float) GameTime: Global time of the world, in fractional days. Only valid in core shaders.
- (vec3) ChunkOffset: When rendering a chunk section, the offset from the camera world position to the chunk section's base point. Only valid in core shaders.
- type: The type of the uniform. Can be one of
int,float,matrix4x4,matrix3x3andmatrix2x2.intcan also be interpreted asivec2,ivec3orivec4depending on how many values are actually included invalues.floatcan also be interpreted asvec2,vec3orvec4depending on how many values are actually included invalues. - count: The number of values included in
values. - values: The value of the uniform, given as a list of floats. The length of the list should be the same as
count.
- name: The name of the uniform as referenced in the GLSL code. Some names give a uniform special behavior(Note that these following special uniform does not work in all shader programs):
- : A uniform.
- blend: Settings for OpenGL blending.
Render pipeline
Here's the process of how a post-processing shader is used in game: first, the shader initializes all of the render targets specified in the "targets" list with the proper width and height. After that, the shader goes through each render pass specified in the "passes" list from first in the list to last in the list. Each pass will apply the program shader on the render target specified by "intarget" (with any extra data provided by other auxiliary render targets) and output the end result on the render target specified by "outtarget".
- The root tag
- targets: A list of render targets. They can be buffer provided by the game, or new buffer with any name.
- : The name of a render target. The size defaults to screen resolution. Post-processing shader
transparencymust contain render targets namedtranslucent、itemEntity、particles、weatherandclouds. Post-processing shaderentity_outlinemust contain render target namedfinal. - : A render target to add.
- name: The name of the render target to add.
- width: The width of the render target.
- height: The height of the render target.
- : The name of a render target. The size defaults to screen resolution. Post-processing shader
- passes: A list of passes.
- : A render pass.
- name: The name of a program shader to apply on the input and post into the output. Use "blit" to copy the data from intarget to outtarget.
- intarget: The name of a render target to use as an input. Use
minecraft:mainto specify the main screen. - outtarget: The name of a render target to output to. It should not be the same as intarget. Use
minecraft:mainto specify the main screen. - auxtargets: A list of auxiliary targets.
- An auxiliary target.
- name: The auxiliary target's name that is passed into the "Program" JSON.
- id: The auxiliary target's id. Either points into the name of a buffer that is defined in
targetsor into the location of a texture underassets/<namespace>/textures/effect(use a resource location to reference it). Append:depthafter the name of the buffer to access its depth buffer. For example, to access the depth buffer ofminecraft:main, useminecraft:main:depth. - width: Required if
idreferences a texture. Describes the width of the texture in pixels. - height: Required if
idreferences a texture. Describes the height of the texture in pixels. - bilinear: Required if
idreferences a texture. Determines whether the scaling algorithm used for the image is bilinear or nearest neighbour.
- An auxiliary target.
- uniforms: A list of overrides that change the values in the
uniformslist in the "Program" JSON.- : A uniform.
- name: The name of the field that should be changed.
- values: The values that the field should be changed to.
- : A uniform.
- : A render pass.
- targets: A list of render targets. They can be buffer provided by the game, or new buffer with any name.
Tutorials and useful docs
Here are some guides with additional information on creating shaders:
Bedrock Edition
Since Bedrock Edition 1.16.200, third party shader resource packs are no longer supported on Windows 10 or Console versions, although they still work on mobile devices.
History
| Java Edition | |||||
|---|---|---|---|---|---|
| 1.7.2 | 13w38a | Shaders were added for Super Secret Settings. | |||
| 1.8 | 14w05a | The Creeper and Spider shaders were added. Shaders are automatically applied in spectator mode when viewing the world as a Creeper, Spider or Enderman. | |||
| 14w05b | Shaders are now removed from view when changing perspective while spectating a mob.[2] | ||||
| F4 now toggles different shaders rather than turning them off.[2] | |||||
| 14w06a | The Entity Outline shader was added. | ||||
| 1.9 | 15w31a | Removed the Super Secret Settings button for an internal rewrite.[3] | |||
| 1.16 | 20w22a | The Transparency shader was added for Fabulous! graphics mode. | |||
| 1.17 | 21w10a | Core shaders were added. | |||
Issues
Issues relating to "Shaders" are maintained on the bug tracker. Report issues there.
















