Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Shader: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Sync: new page from Minecraft
 
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{About|in-game shaders using [[Minecraft:resource pack]]s|the shaders provided by game modifications|Shader pack|the shaders available in the [[Minecraft:options]] menu before [[Minecraft:Java Edition 1.9]]|Super Secret Settings|the built-in shaders and modern customization in ''Bedrock Edition''|Vibrant Visuals}}{{Exclusive|java}}{{Removed feature|edition=bedrock}}{{wip|Add historical Bedrock Edition information. Java Edition History section could be expanded to include more details for changes made around 1.17 to 1.19. The Java Edition "Render process" section would benefit from more information. Java Edition would benefit from more information about post_effects (specifically vertex shaders before and after 25w31a) and vertex attributes for both post and core shaders}}
{{About|in-game shaders using resource packs|the shaders provided by game modifications|Shader pack|the shaders available in the options menu before Java Edition 1.9|Super Secret Settings|the built-in shaders and modern customization in ''Bedrock Edition''|Vibrant Visuals}}{{MC/Exclusive|java}}{{MC/Removed feature|edition=bedrock}}{{MC/WIP|Add historical Bedrock Edition information. Java Edition History section could be expanded to include more details for changes made around 1.17 to 1.19. The Java Edition "Render process" section would benefit from more information. Java Edition would benefit from more information about post_effects (specifically vertex shaders before and after 25w31a) and vertex attributes for both post and core shaders}}


'''Shaders''' are used to define the game's rendering of certain elements.
'''Shaders''' are used to define the game's rendering of certain elements.


== ''Java Edition'' ==
== ''Java Edition'' ==
{{in|je}}, two distinct kinds of shaders are used: '''core shaders''' and '''post-processing shaders'''. '''Core shaders''' are used to render fundamental parts of the game such as entities and terrain, while '''post-processing shaders''' are used to apply visual effects to the screen after core shaders have ran.
{{MC/In|je}}, two distinct kinds of shaders are used: '''core shaders''' and '''post-processing shaders'''. '''Core shaders''' are used to render fundamental parts of the game such as entities and terrain, while '''post-processing shaders''' are used to apply visual effects to the screen after core shaders have ran.


Examples of post-processing shaders include the menu background blur, [[Minecraft:Spectator#Mob view|certain mob vision types]] as seen in [[Minecraft:spectator]], the ''Fabulous!'' [[Minecraft:graphics setting]]'s fixed handling of translucent object, and the [[Minecraft:glowing]] status effect.
Examples of post-processing shaders include the menu background blur, certain mob vision types as seen in spectator, the ''Fabulous!'' graphics setting's fixed handling of translucent object, and the glowing status effect.


Shaders are written in the [https://www.khronos.org/opengl/wiki/OpenGL_Shading_Language OpenGL Shading Language (GLSL)]. Each shader program{{note|A collection of shaders which run together.}} comes in two parts, the '''vertex''' and '''fragment''' shader. Vertex shaders define the positions of individual vertices, whereas fragment shaders define the final color of a single render fragment. For example, vertex shaders are often used to create waving foliage and water, and fragment shaders can be used to add effects like bloom, god rays, and blur. In ''Minecraft'', vertex shaders must use the extension {{code|.vsh}}, and fragment shaders {{code|.fsh}}.
Shaders are written in the [https://www.khronos.org/opengl/wiki/OpenGL_Shading_Language OpenGL Shading Language (GLSL)]. Each shader program{{note|A collection of shaders which run together.}} comes in two parts, the '''vertex''' and '''fragment''' shader. Vertex shaders define the positions of individual vertices, whereas fragment shaders define the final color of a single render fragment. For example, vertex shaders are often used to create waving foliage and water, and fragment shaders can be used to add effects like bloom, god rays, and blur. In ''Minecraft'', vertex shaders must use the extension {{MC/Code|.vsh}}, and fragment shaders {{MC/Code|.fsh}}.


Shader programs are stored in the {{code|assets/minecraft/shaders}} directory of [[Minecraft:client.jar]], and can be replaced with a [[Minecraft:resource pack]]. Note that if any error occurs when loading the shaders, the resource pack is disabled and fabulous graphics mode is turned off.
Shader programs are stored in the {{MC/Code|assets/minecraft/shaders}} directory of [[Minecraft:client.jar]], and can be replaced with a resource pack. Note that if any error occurs when loading the shaders, the resource pack is disabled and fabulous graphics mode is turned off.


=== Core shaders ===
=== Core shaders ===
{{Warning|section=1|Although core shaders can be replaced with a [[Minecraft:resource pack]], this isn't an intended or supported feature and may change at any time.}}
{{MC/Warning|section=1|Although core shaders can be replaced with a resource pack, this isn't an intended or supported feature and may change at any time.}}


Core shaders are used to render almost everything in the game, including terrain, entities, gui elements, etc. The shader programs for core shaders are located in the <code>assets/<namespace>/shaders/core</code> directory of a resourcepack.
Core shaders are used to render almost everything in the game, including terrain, entities, gui elements, etc. The shader programs for core shaders are located in the <code>assets/<namespace>/shaders/core</code> directory of a resourcepack.
Line 34: Line 34:


|animate_sprite_blit
|animate_sprite_blit
|Renders non-interpolated [[Minecraft:Resource_pack#Texture_animation|texture animations]], as well as any non-animated sprite to a texture atlas.
|Renders non-interpolated texture animations, as well as any non-animated sprite to a texture atlas.
Uses the <code>core/animate_sprite.vsh</code> vertex program.
Uses the <code>core/animate_sprite.vsh</code> vertex program.
|
|
Line 43: Line 43:


|animate_sprite_interpolate
|animate_sprite_interpolate
|Renders interpolated [[Minecraft:Resource_pack#Texture_animation|texture animations]] to a texture atlas.
|Renders interpolated texture animations to a texture atlas.
Uses the <code>core/animate_sprite.vsh</code> vertex program.
Uses the <code>core/animate_sprite.vsh</code> vertex program.
|
|
Line 64: Line 64:


|block
|block
|Renders blocks that aren't part of chunk meshes such as falling sand, blocks being moved by a piston, or pistons while moving a block. {{info needed|verify if this applies to anything else}}
|Renders blocks that aren't part of chunk meshes such as falling sand, blocks being moved by a piston, or pistons while moving a block. {{MC/Info needed|verify if this applies to anything else}}
|[[File:Core shader block highlight.png|thumb]]
|[[File:Core shader block highlight.png|thumb]]
|<code>DynamicTransforms</code>
|<code>DynamicTransforms</code>
Line 79: Line 79:


|debug_point
|debug_point
|Used for some debug renderers {{info needed|Which debug renderers, and add image}}
|Used for some debug renderers {{MC/Info needed|Which debug renderers, and add image}}
Uses the <code>core/position_color.fsh</code> fragment program.
Uses the <code>core/position_color.fsh</code> fragment program.
|
|
Line 265: Line 265:


|position
|position
|Handles depth for the ender dragon's death rays{{info needed | Does editing the shader affect the death rays in any way and how?}}.
|Handles depth for the ender dragon's death rays{{MC/Info needed| Does editing the shader affect the death rays in any way and how?}}.
|
|
|<code>DynamicTransforms</code>
|<code>DynamicTransforms</code>
Line 302: Line 302:


<code>Projection</code>
<code>Projection</code>
|<code>CloudFaces</code> (isamplerBuffer) - Data about cloud faces{{info needed|What exactly does this contain?}}
|<code>CloudFaces</code> (isamplerBuffer) - Data about cloud faces{{MC/Info needed|What exactly does this contain?}}
|None present.
|None present.
|-
|-
Line 545: Line 545:




|text_background {{upcoming|je 26.2}}
|text_background {{MC/Upcoming|je 26.2}}
|Renders text background, for example those seen on entity nameplates or text display entities.
|Renders text background, for example those seen on entity nameplates or text display entities.
|
|
Line 558: Line 558:




|text {{upcoming|je 26.2}}
|text {{MC/Upcoming|je 26.2}}
|Renders text in the world and in GUIs. Also renders maps in item frames or when held in first person.
|Renders text in the world and in GUIs. Also renders maps in item frames or when held in first person.
|
|
Line 622: Line 622:


=== Post-processing effects ===
=== Post-processing effects ===
As mentioned previously, post-processing effects are used in menu backgrounds, when spectating certain mobs to create vision effects, the Fabulous! graphics setting, and when rendering the [[Minecraft:glowing]] effect.
As mentioned previously, post-processing effects are used in menu backgrounds, when spectating certain mobs to create vision effects, the Fabulous! graphics setting, and when rendering the glowing effect.


==== Post-effect file format ====
==== Post-effect file format ====
Line 630: Line 630:


<div class="treeview">
<div class="treeview">
* {{nbt | compound}}: The root tag
* {{MC/Nbt| compound}}: The root tag
** {{nbt | compound | targets}}: Custom render targets to be used by render passes
** {{MC/Nbt| compound | targets}}: Custom render targets to be used by render passes
*** {{nbt | compound | target definition}}: The key is the name of the target
*** {{MC/Nbt| compound | target definition}}: The key is the name of the target
**** {{nbt | integer | width}}: Defaults to the current viewport width. The width of the target
**** {{MC/Nbt| integer | width}}: Defaults to the current viewport width. The width of the target
**** {{nbt | integer | height}}: Defaults to the current viewport height. The height of the target
**** {{MC/Nbt| integer | height}}: Defaults to the current viewport height. The height of the target
**** {{nbt | bool | persistent}}: Defaults to false. If true, this target is not cleared between frames. It is still cleared when the game window is resized, however.
**** {{MC/Nbt| bool | persistent}}: Defaults to false. If true, this target is not cleared between frames. It is still cleared when the game window is resized, however.
**** {{nbt | list}}{{nbt | int | clear_color}} Defaults to <code>[0, 0, 0, 0]</code>. The colour this target is filled with when it is created or cleared. Supports two formats. A list of floats in 0-1 range <code>[R, G, B, A]</code>, or a colour in decimal format calculated from the red, green and blue components using this formula:<br>'''(Alpha [[Minecraft:wikipedia:Logical shift|<<]] 24) + (<span style="color:red">Red</span> [[Minecraft:wikipedia:Logical shift|<<]] 16) + (<span style="color:green">Green</span> [[Minecraft:wikipedia:Logical shift|<<]] 8) + <span style="color:blue">Blue</span>'''
**** {{MC/Nbt| list}}{{MC/Nbt| int | clear_color}} Defaults to <code>[0, 0, 0, 0]</code>. The colour this target is filled with when it is created or cleared. Supports two formats. A list of floats in 0-1 range <code>[R, G, B, A]</code>, or a colour in decimal format calculated from the red, green and blue components using this formula:<br>'''(Alpha << 24) + (<span style="color:red">Red</span> << 16) + (<span style="color:green">Green</span> << 8) + <span style="color:blue">Blue</span>'''
** {{nbt | list | passes}}: Render passes
** {{MC/Nbt| list | passes}}: Render passes
*** {{nbt | compound | pass}}: A render pass
*** {{MC/Nbt| compound | pass}}: A render pass
**** {{nbt | string | vertex_shader}}: The namespaced id of a vertex shader to use for this pass, relative to the shaders folder. <code>minecraft:post/blit</code> resolves to <code>assets/minecraft/shaders/post/blit.vsh</code>
**** {{MC/Nbt| string | vertex_shader}}: The namespaced id of a vertex shader to use for this pass, relative to the shaders folder. <code>minecraft:post/blit</code> resolves to <code>assets/minecraft/shaders/post/blit.vsh</code>
**** {{nbt | string | fragment_shader}}: The namespaced id of a fragment shader to use for this pass, relative to the shaders folder. <code>minecraft:post/box_blur</code> resolves to <code>assets/minecraft/shaders/post/box_blur.fsh</code>
**** {{MC/Nbt| string | fragment_shader}}: The namespaced id of a fragment shader to use for this pass, relative to the shaders folder. <code>minecraft:post/box_blur</code> resolves to <code>assets/minecraft/shaders/post/box_blur.fsh</code>
**** {{nbt | list | inputs}}: A list of render target inputs and / or texture inputs
**** {{MC/Nbt| list | inputs}}: A list of render target inputs and / or texture inputs
***** {{nbt | compound | render target input}}
***** {{MC/Nbt| compound | render target input}}
****** {{nbt | string | sampler_name}}: The name of the sampler uniform
****** {{MC/Nbt| string | sampler_name}}: The name of the sampler uniform
******* ''Setting this to <code>MainDepth</code>, for example, makes a sampler2D uniform called <code>MainDepthSampler</code> available to the shader program for this pass. This will also provide an additional vec2 to the <code>SamplerInfo</code> uniform block called <code><sampler_name>Size</code>, for example <code>MainDepthSize</code>''
******* ''Setting this to <code>MainDepth</code>, for example, makes a sampler2D uniform called <code>MainDepthSampler</code> available to the shader program for this pass. This will also provide an additional vec2 to the <code>SamplerInfo</code> uniform block called <code><sampler_name>Size</code>, for example <code>MainDepthSize</code>''
****** {{nbt | boolean | bilinear}}: Default: false. If set to true, the sampler uses bilinear filtering instead of nearest neighbor
****** {{MC/Nbt| boolean | bilinear}}: Default: false. If set to true, the sampler uses bilinear filtering instead of nearest neighbor
****** {{nbt | string | target}}: The name of the target. Can either be a custom target as specified in <code>targets</code> above, or one of the following built in targets: <code>minecraft:main</code>, <code>minecraft:translucent</code>, <code>minecraft:item_entity</code>, <code>minecraft:particles</code>, <code>minecraft:weather</code>, <code>minecraft:clouds</code>, or <code>minecraft:entity_outline</code>
****** {{MC/Nbt| string | target}}: The name of the target. Can either be a custom target as specified in <code>targets</code> above, or one of the following built in targets: <code>minecraft:main</code>, <code>minecraft:translucent</code>, <code>minecraft:item_entity</code>, <code>minecraft:particles</code>, <code>minecraft:weather</code>, <code>minecraft:clouds</code>, or <code>minecraft:entity_outline</code>
****** {{nbt | boolean | use_depth_buffer}}: Default: false. If set to true, it samples from the depth texture instead of the color texture.
****** {{MC/Nbt| boolean | use_depth_buffer}}: Default: false. If set to true, it samples from the depth texture instead of the color texture.
***** {{nbt | compound | texture input}}
***** {{MC/Nbt| compound | texture input}}
****** {{nbt | string | sampler_name}}: The name of the sampler uniform
****** {{MC/Nbt| string | sampler_name}}: The name of the sampler uniform
******* ''Setting this to <code>MyTexture</code>, for example, makes a sampler2D uniform called <code>MyTextureSampler</code> available to the shader program for this pass. This will also provide an additional vec2 to the <code>SamplerInfo</code> uniform block called <code><sampler_name>Size</code>, for example <code>MyTextureSize</code>''
******* ''Setting this to <code>MyTexture</code>, for example, makes a sampler2D uniform called <code>MyTextureSampler</code> available to the shader program for this pass. This will also provide an additional vec2 to the <code>SamplerInfo</code> uniform block called <code><sampler_name>Size</code>, for example <code>MyTextureSize</code>''
****** {{nbt | boolean | bilinear}}: Default: false. If set to true, the sampler uses bilinear filtering instead of nearest neighbor
****** {{MC/Nbt| boolean | bilinear}}: Default: false. If set to true, the sampler uses bilinear filtering instead of nearest neighbor
****** {{nbt | string | location}}: The resource location of the texture. <code>my_namespace:post_texture</code> resolves to <code>assets/my_namespace/textures/effect/post_texture.png</code>
****** {{MC/Nbt| string | location}}: The resource location of the texture. <code>my_namespace:post_texture</code> resolves to <code>assets/my_namespace/textures/effect/post_texture.png</code>
****** {{nbt | integer | width}}: The width of the texture in pixels
****** {{MC/Nbt| integer | width}}: The width of the texture in pixels
****** {{nbt | integer | height}}: The height of the texture in pixels
****** {{MC/Nbt| integer | height}}: The height of the texture in pixels
**** {{nbt | string | output}}: The target to output to. Can either be a custom target as specified in <code>targets</code> above or <code>minecraft:main</code>. ''Note: you cannot read and write to the same target in the same pass''
**** {{MC/Nbt| string | output}}: The target to output to. Can either be a custom target as specified in <code>targets</code> above or <code>minecraft:main</code>. ''Note: you cannot read and write to the same target in the same pass''
**** {{nbt | compound | uniforms}}: An object of uniform blocks to pass to the vertex and fragment shaders. For example, <code>uniforms: { "UniformBlockName": [ { "type": "vec2", "value": [...] } ] }</code>
**** {{MC/Nbt| compound | uniforms}}: An object of uniform blocks to pass to the vertex and fragment shaders. For example, <code>uniforms: { "UniformBlockName": [ { "type": "vec2", "value": [...] } ] }</code>
***** {{nbt | list | uniform block}}: The key is what this uniform block will be called when referenced in a shader
***** {{MC/Nbt| list | uniform block}}: The key is what this uniform block will be called when referenced in a shader
****** {{nbt | compound | uniform definition}}
****** {{MC/Nbt| compound | uniform definition}}
******* {{nbt | string | name}}: The name of the uniform. This is unused by the game, however it is recommended to set it for organizational purposes
******* {{MC/Nbt| string | name}}: The name of the uniform. This is unused by the game, however it is recommended to set it for organizational purposes
******* {{nbt | string | type}}: The type of the uniform, can be any of: <code>int</code>, <code>float</code>, <code>ivec3</code>, <code>vec2</code>, <code>vec3</code>, <code>vec4</code>, and <code>matrix4x4</code>
******* {{MC/Nbt| string | type}}: The type of the uniform, can be any of: <code>int</code>, <code>float</code>, <code>ivec3</code>, <code>vec2</code>, <code>vec3</code>, <code>vec4</code>, and <code>matrix4x4</code>
******* {{nbt | int}}{{nbt | float}}{{nbt | list | value}}: Uniform values. The amount and format of this depends on what the <code>type</code> field is set to
******* {{MC/Nbt| int}}{{MC/Nbt| float}}{{MC/Nbt| list | value}}: Uniform values. The amount and format of this depends on what the <code>type</code> field is set to
******** <code>int</code> requires a single int
******** <code>int</code> requires a single int
******** <code>float</code> requires a single float
******** <code>float</code> requires a single float
Line 688: Line 688:
|-
|-
| creeper
| creeper
| Adds a green filter over the screen and give the appearance of a reduced resolution. Used when spectating a [[Minecraft:creeper]].
| Adds a green filter over the screen and give the appearance of a reduced resolution. Used when spectating a creeper.
|  
|  
[[File:Post effect creeper.png|left|thumb]]
[[File:Post effect creeper.png|left|thumb]]
|-
|-
| entity_outline
| entity_outline
| Applies a blur over a solid color silhouette of an entity. Used when an entity with the [[Minecraft:glowing]] effect is on-screen.
| Applies a blur over a solid color silhouette of an entity. Used when an entity with the glowing effect is on-screen.
|  
|  
[[File:Post effect entity outline.png|left|thumb|Left side is the "minecraft:entity_outline" target before the post effect is applied, right side is the final image with the post effect applied]]
[[File:Post effect entity outline.png|left|thumb|Left side is the "minecraft:entity_outline" target before the post effect is applied, right side is the final image with the post effect applied]]
Line 703: Line 703:
|-
|-
| spider
| spider
| Renders a blurred version of the screen with 5 additional copies overlapped on top with blurred edges. Used when spectating a [[Minecraft:spider]].
| Renders a blurred version of the screen with 5 additional copies overlapped on top with blurred edges. Used when spectating a spider.
|  
|  
[[File:Post effect spider.png|left|thumb]]
[[File:Post effect spider.png|left|thumb]]
Line 725: Line 725:


=== Render process ===
=== Render process ===
{{expand section}}
{{MC/Expand section}}


==== General game rendering ====
==== General game rendering ====
Each frame is rendered in the following order{{info needed|Verify this order}}
Each frame is rendered in the following order{{MC/Info needed|Verify this order}}
* The world, including entities, blocks, the sky, items, etc is rendered (by core shaders)
* The world, including entities, blocks, the sky, items, etc is rendered (by core shaders)
* Any Post effects are applied as necessary
* Any Post effects are applied as necessary
Line 735: Line 735:
==== GUI item and entity rendering ====
==== GUI item and entity rendering ====
When the game draws an item or entity in a GUI the following process occurs:
When the game draws an item or entity in a GUI the following process occurs:
* The item or entity is pre-rendered to an internal texture. For items, this may be an atlas of all currently visible items ("GUI items atlas") or a single texture for that item. This depends on if the <code>oversized_in_gui</code> field is set to true or false in the [[Minecraft:items model definition]]. For entities, each one always has a unique texture that it gets rendered to
* The item or entity is pre-rendered to an internal texture. For items, this may be an atlas of all currently visible items ("GUI items atlas") or a single texture for that item. This depends on if the <code>oversized_in_gui</code> field is set to true or false in the items model definition. For entities, each one always has a unique texture that it gets rendered to
* For each item or entity, a quad is drawn to the screen which samples from either the GUI items atlas or individual texture for the corresponding item or entity
* For each item or entity, a quad is drawn to the screen which samples from either the GUI items atlas or individual texture for the corresponding item or entity
The game can skip rendering an item when neccesary and will use whatever was drawn on the previous frame. An item is only re-rendered if one of the following conditions is met:
The game can skip rendering an item when neccesary and will use whatever was drawn on the previous frame. An item is only re-rendered if one of the following conditions is met:
Line 742: Line 742:
* The GUI items atlas fills up, in this case it is cleared and all currently visible GUI items are redrawn
* The GUI items atlas fills up, in this case it is cleared and all currently visible GUI items are redrawn
* The GUI scale is changed, in this case the GUI items atlas is cleared and all currently visible GUI items are redrawn
* The GUI scale is changed, in this case the GUI items atlas is cleared and all currently visible GUI items are redrawn
* The item data is changed in a way that would cause a visual update. This includes but is not limited to: changing the <code>item_model</code>, <code>custom_model_data</code>, or <code>profile</code> [[Minecraft:Data component format|data components]]
* The item data is changed in a way that would cause a visual update. This includes but is not limited to: changing the <code>item_model</code>, <code>custom_model_data</code>, or <code>profile</code> data components


=== Vanilla uniform blocks ===
=== Vanilla uniform blocks ===
<!-- DO NOT reorder the individual uniforms, the order is important -->
<!-- DO NOT reorder the individual uniforms, the order is important -->
{{Warning|section=1|Using uniform blocks outside supported shaders may work in some cases, however this is undefined behavior and may cause unexpected results or crashes. Refer to [[#List of core shaders|the list of core shaders]] for more info}}
{{MC/Warning|section=1|Using uniform blocks outside supported shaders may work in some cases, however this is undefined behavior and may cause unexpected results or crashes. Refer to [[#List of core shaders|the list of core shaders]] for more info}}


Uniforms blocks use the [https://ptgmedia.pearsoncmg.com/images/9780321552624/downloads/0321552628_AppL.pdf std140 layout]. All uniforms must be specified and in the correct order and with the correct type, otherwise weird and undefined behavior will occur. For convenience, some uniform blocks are pre-defined in include shaders, see the [[#Include_shaders|include shaders]] section for more information.
Uniforms blocks use the [https://ptgmedia.pearsoncmg.com/images/9780321552624/downloads/0321552628_AppL.pdf std140 layout]. All uniforms must be specified and in the correct order and with the correct type, otherwise weird and undefined behavior will occur. For convenience, some uniform blocks are pre-defined in include shaders, see the [[#Include_shaders|include shaders]] section for more information.
Line 756: Line 756:


;<code>Globals</code>
;<code>Globals</code>
This uniform block is always bound and has proper values in all shaders. {{INUpcoming|je 26.2}} this excludes <code>lightmap</code>, <code>animate_sprite_interpolate</code> and <code>animate_sprite_blit</code>.
This uniform block is always bound and has proper values in all shaders. {{MC/InUpcoming|je 26.2}} this excludes <code>lightmap</code>, <code>animate_sprite_interpolate</code> and <code>animate_sprite_blit</code>.
* (ivec3) <code>CameraBlockPos</code> Block position of the camera in world-space coordinates.
* (ivec3) <code>CameraBlockPos</code> Block position of the camera in world-space coordinates.
* (vec3) <code>CameraOffset</code> Fractional position of the camera in world-space coordinates.
* (vec3) <code>CameraOffset</code> Fractional position of the camera in world-space coordinates.
* (vec2) <code>ScreenSize</code> The width and height of the current framebuffer in pixels.
* (vec2) <code>ScreenSize</code> The width and height of the current framebuffer in pixels.
* (float) <code>GlintAlpha</code> The value of the Glint Strength accessibility setting in a 0-1 range.
* (float) <code>GlintAlpha</code> The value of the Glint Strength accessibility setting in a 0-1 range.
* (float) <code>GameTime</code> A value that constantly increases from 0-1 over the span of roughly 20 minutes, then resets to 0. The exact formula for this is <code>(<age of the world> modulo 24000) / 24000</code>. {{INUntil|je 26.2}} this is set to a constant 0 value within <code>animate_sprite_interpolate</code> and <code>animate_sprite_blit</code>.
* (float) <code>GameTime</code> A value that constantly increases from 0-1 over the span of roughly 20 minutes, then resets to 0. The exact formula for this is <code>(<age of the world> modulo 24000) / 24000</code>. {{MC/InUntil|je 26.2}} this is set to a constant 0 value within <code>animate_sprite_interpolate</code> and <code>animate_sprite_blit</code>.
* (int) <code>MenuBlurRadius</code> The value of the Menu Background Blur accessibility setting in a 0-10 range.
* (int) <code>MenuBlurRadius</code> The value of the Menu Background Blur accessibility setting in a 0-10 range.
* (int) <code>UseRgss</code> A "boolean" value. Value is 1 if the [[Minecraft:Options#Video_Settings|texture filtering video setting]] is set to RGSS, otherwise 0.
* (int) <code>UseRgss</code> A "boolean" value. Value is 1 if the texture filtering video setting is set to RGSS, otherwise 0.


==== Core blocks ====
==== Core blocks ====
Line 796: Line 796:
*(float) <code>SkyFactor</code> A value that specifies how much to brighten the lightmap by when the sky flashes, typically when a lightning strike occurs. This value comes from the <code>minecraft:visual/sky_light_factor</code> environment attribute.
*(float) <code>SkyFactor</code> A value that specifies how much to brighten the lightmap by when the sky flashes, typically when a lightning strike occurs. This value comes from the <code>minecraft:visual/sky_light_factor</code> environment attribute.
*(float) <code>BlockFactor</code> A value that fluctuates randomly, used in the vanilla shader for block light flickering.
*(float) <code>BlockFactor</code> A value that fluctuates randomly, used in the vanilla shader for block light flickering.
*(float) <code>NightVisionFactor</code> A value in a 0-1 range that specifies how much the Night Vision [[Minecraft:Effect| status effect]] should brighten the lightmap by.
*(float) <code>NightVisionFactor</code> A value in a 0-1 range that specifies how much the Night Vision status effect should brighten the lightmap by.
*(float) <code>DarknessScale</code> A value in a 0-1 range that specifies how much the Darkness [[Minecraft:Effect| status effect]] should darken the lightmap by.
*(float) <code>DarknessScale</code> A value in a 0-1 range that specifies how much the Darkness status effect should darken the lightmap by.
*(float) <code>BossOverlayWorldDarkeningFactor</code> A value that specifies how much to darken the lightmap by when a bossbar is visible. This is seemingly only used in the ender dragon fight {{info needed|Verify if any other boss bars can affect this}}.
*(float) <code>BossOverlayWorldDarkeningFactor</code> A value that specifies how much to darken the lightmap by when a bossbar is visible. This is seemingly only used in the ender dragon fight {{MC/Info needed|Verify if any other boss bars can affect this}}.
*(float) <code>BrightnessFactor</code> The value of the brightness video setting in a 0-1 range.
*(float) <code>BrightnessFactor</code> The value of the brightness video setting in a 0-1 range.
*(vec3) <code>BlockLightTint</code> The color of block light. This value comes from the <code>minecraft:visual/block_light_tint</code> environment attribute.
*(vec3) <code>BlockLightTint</code> The color of block light. This value comes from the <code>minecraft:visual/block_light_tint</code> environment attribute.
*(vec3) <code>SkyLightColor</code> The color of sky light. This value comes from the <code>minecraft:visual/sky_light_color</code> environment attribute.
*(vec3) <code>SkyLightColor</code> The color of sky light. This value comes from the <code>minecraft:visual/sky_light_color</code> environment attribute.
*(vec3) <code>AmbientColor</code> The ambient light color. This value comes from the <code>minecraft:visual/ambient_light_color</code> environment attribute.
*(vec3) <code>AmbientColor</code> The ambient light color. This value comes from the <code>minecraft:visual/ambient_light_color</code> environment attribute.
*(vec3) <code>NightVisionColor</code> The color of the Night Vision [[Minecraft:Effect| status effect]]. This value comes from the <code>minecraft:visual/night_vision_color</code> environment attribute.
*(vec3) <code>NightVisionColor</code> The color of the Night Vision status effect. This value comes from the <code>minecraft:visual/night_vision_color</code> environment attribute.


;<code>CloudInfo</code>
;<code>CloudInfo</code>
* (vec4) <code>CloudColor</code> The color of the clouds.
* (vec4) <code>CloudColor</code> The color of the clouds.
* (vec3) <code>CloudOffset</code> Offset of the clouds {{info needed|Verify this}}.
* (vec3) <code>CloudOffset</code> Offset of the clouds {{MC/Info needed|Verify this}}.
* (vec3) <code>CellSize</code> Size of each individual cloud {{info needed|Verify this}}.
* (vec3) <code>CellSize</code> Size of each individual cloud {{MC/Info needed|Verify this}}.


;<code>ChunkSection</code>
;<code>ChunkSection</code>
* (mat4) <code>ModelViewMat</code> The model-view matrix.
* (mat4) <code>ModelViewMat</code> The model-view matrix.
* (float) <code>ChunkVisibility</code> Value that increments from 0 to 1 once a chunk section has been displayed. The amount of time this takes is dependent on the [[Minecraft:Video settings|"Chunk Fade" video setting]]
* (float) <code>ChunkVisibility</code> Value that increments from 0 to 1 once a chunk section has been displayed. The amount of time this takes is dependent on the "Chunk Fade" video setting
* (ivec2) <code>TextureSize</code> {{info needed}}
* (ivec2) <code>TextureSize</code> {{MC/Info needed}}
* (ivec3) <code>ChunkPosition</code> {{info needed}}
* (ivec3) <code>ChunkPosition</code> {{MC/Info needed}}


;<code>SpriteAnimationInfo</code>
;<code>SpriteAnimationInfo</code>
* (mat4) <code>ProjectionMatrix</code> The projection matrix
* (mat4) <code>ProjectionMatrix</code> The projection matrix
* (mat4) <code>SpriteMatrix</code> {{info needed}}
* (mat4) <code>SpriteMatrix</code> {{MC/Info needed}}
* (float) <code>UPadding</code> {{info needed}}
* (float) <code>UPadding</code> {{MC/Info needed}}
* (float) <code>VPadding</code> {{info needed}}
* (float) <code>VPadding</code> {{MC/Info needed}}
* (int) <code>MipMapLevel</code> {{info needed}}
* (int) <code>MipMapLevel</code> {{MC/Info needed}}


==== Post-processing blocks ====
==== Post-processing blocks ====
Line 832: Line 832:


== ''Bedrock Edition'' ==
== ''Bedrock Edition'' ==
{{Expand section}}
{{MC/Expand section}}


Since [[Minecraft:Bedrock Edition 1.18.30]], third-party shader in resource packs are no longer supported on all devices due to the implementation of [[Minecraft:RenderDragon]].  
Since [[Minecraft:Bedrock Edition 1.18.30]], third-party shader in resource packs are no longer supported on all devices due to the implementation of [[Minecraft:RenderDragon]].  
Line 840: Line 840:
The deferred rendering pipeline is an alternative rendering pipeline which can be customized via resource packs and is used in the vanilla game for the [[Minecraft:Vibrant Visuals]] graphics mode.
The deferred rendering pipeline is an alternative rendering pipeline which can be customized via resource packs and is used in the vanilla game for the [[Minecraft:Vibrant Visuals]] graphics mode.


Although it doesn't directly support custom shaders, it offers ways to define properties about light, fog, atmosphere, and PBR texture materials. This can be used to create lighting effects similar to those seen in Java Edition's [[Minecraft:shader pack]]s.
Although it doesn't directly support custom shaders, it offers ways to define properties about light, fog, atmosphere, and PBR texture materials. This can be used to create lighting effects similar to those seen in Java Edition's shader packs.


== History ==
== History ==
{{HistoryTable
{{HistoryTable
|{{HistoryLine|java}}
|{{MC/HistoryLine|java}}
|{{HistoryLine||1.7.2|dev=13w38a
|{{MC/HistoryLine||1.7.2|dev=13w38a
|Shaders were added for [[Minecraft:Super Secret Settings]].
|Shaders were added for Super Secret Settings.
}}
}}
|{{HistoryLine||1.8|dev=14w05a
|{{MC/HistoryLine||1.8|dev=14w05a
|The Creeper and Spider shaders were added. Shaders are automatically applied in [[Minecraft:spectator]] mode when viewing the world as a [[Minecraft:creeper]], [[Minecraft:spider]] or [[Minecraft:enderman]].
|The Creeper and Spider shaders were added. Shaders are automatically applied in spectator mode when viewing the world as a creeper, spider or [[Minecraft:enderman]].
}}
}}
|{{HistoryLine|||dev=14w05b
|{{HistoryLine|||dev=14w05b
|Shaders have been removed from view when changing perspective while spectating a mob.<ref name="NoBug">{{bug|MC-46727#comment-219617}}</ref>|{{key|F4}} now toggles different shaders rather than turning them off.<ref name="NoBug"/>
|Shaders have been removed from view when changing perspective while spectating a mob.<ref name="NoBug">{{bug|MC-46727#comment-219617}}</ref>|{{MC/Key|F4}} now toggles different shaders rather than turning them off.<ref name="NoBug"/>
}}
}}
|{{HistoryLine|||dev=14w06a
|{{MC/HistoryLine|||dev=14w06a
|The <code>entity_outline</code> post effect shader was added.
|The <code>entity_outline</code> post effect shader was added.
}}
}}
|{{HistoryLine||1.9|dev=15w31a
|{{HistoryLine||1.9|dev=15w31a
|Removed the [[Minecraft:Super Secret Settings]] button for an internal rewrite.<ref>{{tweet|_grum|627141591942209536|nah just rewriting it all :p They are still in the game, the button is just gone atm. It would make more sense to keybind imho|July 31, 2015}}</ref>
|Removed the Super Secret Settings button for an internal rewrite.<ref>{{tweet|_grum|627141591942209536|nah just rewriting it all :p They are still in the game, the button is just gone atm. It would make more sense to keybind imho|July 31, 2015}}</ref>
}}
}}
|{{HistoryLine||1.16|dev=20w22a
|{{MC/HistoryLine||1.16|dev=20w22a
|The <code>transparency</code> post effect shader was added for ''Fabulous!'' graphics mode.
|The <code>transparency</code> post effect shader was added for ''Fabulous!'' graphics mode.
}}
}}
|{{HistoryLine||1.17|dev=21w10a
|{{MC/HistoryLine||1.17|dev=21w10a
|Added core shaders.
|Added core shaders.
|Added the <code>fog.glsl</code>, <code>light.glsl</code>, <code>matrix.glsl</code>, and <code>projection.glsl</code> include shaders
|Added the <code>fog.glsl</code>, <code>light.glsl</code>, <code>matrix.glsl</code>, and <code>projection.glsl</code> include shaders
Line 869: Line 869:
|Upgraded the existing shader programs for post processing effects from glsl version <code>110</code> to <code>150</code>
|Upgraded the existing shader programs for post processing effects from glsl version <code>110</code> to <code>150</code>
}}
}}
|{{HistoryLine||1.18.1|dev=?
|{{MC/HistoryLine||1.18.1|dev=?
|The <code>fog.glsl</code> include shader now has a <code>cylindrical_distance</code> function. All core shaders that previously used the builtin <code>length</code> function to calculate vertex distance use this.
|The <code>fog.glsl</code> include shader now has a <code>cylindrical_distance</code> function. All core shaders that previously used the builtin <code>length</code> function to calculate vertex distance use this.
}}
}}
|{{HistoryLine||1.18.2|dev=?
|{{MC/HistoryLine||1.18.2|dev=?
|In <code>fog.glsl</code> the <code>cylindrical_distance</code> function has been renamed to <code>fog_distance</code>. It also takes an additional int parameter for fog shape.
|In <code>fog.glsl</code> the <code>cylindrical_distance</code> function has been renamed to <code>fog_distance</code>. It also takes an additional int parameter for fog shape.
}}
}}
|{{HistoryLine|||dev=?
|{{MC/HistoryLine|||dev=?
|Added the <code>FogShape</code> uniform for core shaders.
|Added the <code>FogShape</code> uniform for core shaders.
}}
}}
|{{HistoryLine||1.19|dev=22w12a
|{{MC/HistoryLine||1.19|dev=22w12a
|There are now shader files for translucent entity rendering.
|There are now shader files for translucent entity rendering.
}}
}}
|{{HistoryLine||1.20.5|dev=24w05a
|{{MC/HistoryLine||1.20.5|dev=24w05a
|The attributes array in core shader definitions has been removed. All attributes are now always bound for a given shader.
|The attributes array in core shader definitions has been removed. All attributes are now always bound for a given shader.
|The unused <code>position_color_normal</code> and <code>position_tex_lightmap_color</code> core shaders have been removed
|The unused <code>position_color_normal</code> and <code>position_tex_lightmap_color</code> core shaders have been removed
Line 888: Line 888:
|Light direction uniforms are no longer premultiplied by the view matrix
|Light direction uniforms are no longer premultiplied by the view matrix
}}
}}
|{{HistoryLine|||dev=24w09a
|{{MC/HistoryLine|||dev=24w09a
|The menu background dirt texture has been replaced by a post-processing blur shader.
|The menu background dirt texture has been replaced by a post-processing blur shader.
}}
}}
|{{HistoryLine|||dev=24w11a
|{{MC/HistoryLine|||dev=24w11a
|All unused post-processing shaders that were used for [[Minecraft:Super Secret Settings]] have been removed.
|All unused post-processing shaders that were used for Super Secret Settings have been removed.
}}
}}
|{{HistoryLine||1.21.2|dev=24w34a
|{{MC/HistoryLine||1.21.2|dev=24w34a
|Shader program configurations can now specify preprocessor define directives to apply to their linked shaders.
|Shader program configurations can now specify preprocessor define directives to apply to their linked shaders.
|The format of core shader and post-processing shader configurations have been consolidated.
|The format of core shader and post-processing shader configurations have been consolidated.
Line 900: Line 900:
|The <code>rendertype_entity_translucent_cull</code> shader has been removed and replaced by <code>rendertype_item_entity_translucent_cull</code>.
|The <code>rendertype_entity_translucent_cull</code> shader has been removed and replaced by <code>rendertype_item_entity_translucent_cull</code>.
}}
}}
|{{HistoryLine|||dev=?
|{{MC/HistoryLine|||dev=?
|Renamed the <code>ChunkOffset</code> uniform to <code>ModelOffset</code>
|Renamed the <code>ChunkOffset</code> uniform to <code>ModelOffset</code>
}}
}}
|{{HistoryLine|||dev=?
|{{MC/HistoryLine|||dev=?
|The <code>moj_import</code> directive now accepts a [[Minecraft:resource location]], allowing include shaders to be placed in namespaces other than '''minecraft'''
|The <code>moj_import</code> directive now accepts a resource location, allowing include shaders to be placed in namespaces other than '''minecraft'''
}}
}}
|{{HistoryLine|||dev=?
|{{MC/HistoryLine|||dev=?
|Most textured gui elements now use the <code>position_tex_color</code> core shader instead of <code>position_tex</code>
|Most textured gui elements now use the <code>position_tex_color</code> core shader instead of <code>position_tex</code>
}}
}}


|{{HistoryLine||1.21.5|dev=25w06a
|{{MC/HistoryLine||1.21.5|dev=25w06a
|Added a new core shader, <code>rendertype_world_border</code>, which is used to render the world border
|Added a new core shader, <code>rendertype_world_border</code>, which is used to render the world border
}}
}}
|{{HistoryLine|||dev=25w07a
|{{MC/HistoryLine|||dev=25w07a
|Shader program configuration files have been removed. The shader programs are still present, however the only uniforms available to them are the default ones that are used in the vanilla rendering.
|Shader program configuration files have been removed. The shader programs are still present, however the only uniforms available to them are the default ones that are used in the vanilla rendering.
|In post-processing effects, the field <code>program</code> was replaced with <code>vertex_shader</code> and <code>fragment_shader</code> which resolve to <code>assets/<namespace>/shaders/<path>.<vsh or fsh></code>
|In post-processing effects, the field <code>program</code> was replaced with <code>vertex_shader</code> and <code>fragment_shader</code> which resolve to <code>assets/<namespace>/shaders/<path>.<vsh or fsh></code>
Line 919: Line 919:
|In post-processing effects, the <code>values</code> field is now option for each <code>uniform</code>. Leaving it unset is not recommended as it will result in undefined behavior. Leaving it unset is only used for runtime configuration of the blur post-processing effect in the vanilla rendering
|In post-processing effects, the <code>values</code> field is now option for each <code>uniform</code>. Leaving it unset is not recommended as it will result in undefined behavior. Leaving it unset is only used for runtime configuration of the blur post-processing effect in the vanilla rendering
|The <code>EndPortalLayers</code> uniform has been removed and replaced by a pre-processor define called  <code>PORTAL_LAYERS</code>}}
|The <code>EndPortalLayers</code> uniform has been removed and replaced by a pre-processor define called  <code>PORTAL_LAYERS</code>}}
|{{HistoryLine|||dev=25w10a
|{{MC/HistoryLine|||dev=25w10a
|"Global" uniforms can now be defined in shader programs. If a uniform is not usually available to that shader, or the type of the uniform is not defined as what it would normally be, undefined behavior will occur
|"Global" uniforms can now be defined in shader programs. If a uniform is not usually available to that shader, or the type of the uniform is not defined as what it would normally be, undefined behavior will occur
|Currently, the "global" uniforms are: <code>ModelViewMat</code>, <code>ProjMat</code>, <code>TextureMat</code>, <code>ScreenSize</code>, <code>ColorModulator</code>, <code>Light0_Direction</code>, <code>Light1_Direction</code>, <code>GlintAlpha</code>, <code>FogStart</code>, <code>FogEnd</code>, <code>FogColor</code>, <code>FogShape</code>, <code>LineWidth</code>, <code>GameTime</code>, and <code>ModelOffset</code>
|Currently, the "global" uniforms are: <code>ModelViewMat</code>, <code>ProjMat</code>, <code>TextureMat</code>, <code>ScreenSize</code>, <code>ColorModulator</code>, <code>Light0_Direction</code>, <code>Light1_Direction</code>, <code>GlintAlpha</code>, <code>FogStart</code>, <code>FogEnd</code>, <code>FogColor</code>, <code>FogShape</code>, <code>LineWidth</code>, <code>GameTime</code>, and <code>ModelOffset</code>
Line 935: Line 935:
|The <code>minecraft_sample_lightmap</code> has been removed from the <code>light.glsl</code> include shader. All shaders that previously used this function now instead sample the lightmap texture directly.
|The <code>minecraft_sample_lightmap</code> has been removed from the <code>light.glsl</code> include shader. All shaders that previously used this function now instead sample the lightmap texture directly.
}}
}}
|{{HistoryLine|||dev=25w17a
|{{MC/HistoryLine|||dev=25w17a
|Added two new core shaders; <code>stars</code>, and <code>sky</code> which are used to render the stars and upper portion of the sky respectively.
|Added two new core shaders; <code>stars</code>, and <code>sky</code> which are used to render the stars and upper portion of the sky respectively.
|Removed the <code>FOG_IS_SKY</code> define directive, as the sky now uses a separate shader.
|Removed the <code>FOG_IS_SKY</code> define directive, as the sky now uses a separate shader.
}}
}}
|{{HistoryLine|||dev=25w19a
|{{MC/HistoryLine|||dev=25w19a
|The main menu panorama now uses a new vertex program, <code>core/panorama.vsh</code>.
|The main menu panorama now uses a new vertex program, <code>core/panorama.vsh</code>.
|The <code>core/position_tex.vsh</code> program is now unused.
|The <code>core/position_tex.vsh</code> program is now unused.
Line 946: Line 946:
}}
}}


|{{HistoryLine||1.21.9|dev=25w31a
|{{MC/HistoryLine||1.21.9|dev=25w31a
|Removed the <code>post/blit.vsh</code>, <code>post/blur.vsh</code>, <code>post/invert.vsh</code>, <code>post/sobel.vsh</code>, <code>post/screenquad.vsh</code>, and <code>core/blit_screen.vsh</code> shader programs and replaced them with <code>core/screenquad.vsh</code>.
|Removed the <code>post/blit.vsh</code>, <code>post/blur.vsh</code>, <code>post/invert.vsh</code>, <code>post/sobel.vsh</code>, <code>post/screenquad.vsh</code>, and <code>core/blit_screen.vsh</code> shader programs and replaced them with <code>core/screenquad.vsh</code>.
|Vertex shaders for post-processing effects and full screen blits are no longer are passed a <code>Position</code> attribute. Instead these must assign vertex coordinates using <code>gl_VertexID</code>. Additionally, these shaders are only executed with 3 vertices instead of a full quad like they were previously.
|Vertex shaders for post-processing effects and full screen blits are no longer are passed a <code>Position</code> attribute. Instead these must assign vertex coordinates using <code>gl_VertexID</code>. Additionally, these shaders are only executed with 3 vertices instead of a full quad like they were previously.
}}
}}
|{{HistoryLine|||dev=25w33a
|{{MC/HistoryLine|||dev=25w33a
|In the <code>LightmapInfo</code> uniform block, the <code>int UseBrightLightmap</code> uniform has been removed, and <code>vec3 AmbientColor</code> has been added.
|In the <code>LightmapInfo</code> uniform block, the <code>int UseBrightLightmap</code> uniform has been removed, and <code>vec3 AmbientColor</code> has been added.
|The <code>core/lightmap.fsh</code> shader has been modified for the new end flashes.
|The <code>core/lightmap.fsh</code> shader has been modified for the new end flashes.
}}
}}
|{{HistoryLine|||dev=25w35a
|{{MC/HistoryLine|||dev=25w35a
|The <code>core/lightmap.fsh</code> shader has been modified slightly to fix some issues with end flashes. The darkness effect pulsing is no longer applied in the end as part of these changes.
|The <code>core/lightmap.fsh</code> shader has been modified slightly to fix some issues with end flashes. The darkness effect pulsing is no longer applied in the end as part of these changes.
}}
}}
|{{HistoryLine|||dev=25w36a
|{{MC/HistoryLine|||dev=25w36a
|Removed the unused <code>core/position_color_lightmap.fsh</code>, <code>core/position_color_lightmap.vsh</code>, <code>core/position_color_tex_lightmap.fsh</code>, and <code>core/position_color_tex_lightmap.vsh</code> shader programs.
|Removed the unused <code>core/position_color_lightmap.fsh</code>, <code>core/position_color_lightmap.vsh</code>, <code>core/position_color_tex_lightmap.fsh</code>, and <code>core/position_color_tex_lightmap.vsh</code> shader programs.
|Minor change to uv calculations in the <code>minecraft_sample_lightmap</code> function in the <code>core/terrain.vsh</code> program.
|Minor change to uv calculations in the <code>minecraft_sample_lightmap</code> function in the <code>core/terrain.vsh</code> program.
}}
}}
|{{HistoryLine|||dev=25w37a|The <code>core/entity</code> shader can now have a <code>PER_FACE_LIGHTING</code> flag. When set, cardinal lighting will be computed separately for front and back faces of each quad.
|{{MC/HistoryLine|||dev=25w37a|The <code>core/entity</code> shader can now have a <code>PER_FACE_LIGHTING</code> flag. When set, cardinal lighting will be computed separately for front and back faces of each quad.
|The game now requires OpenGL 3.3 Core Profile.
|The game now requires OpenGL 3.3 Core Profile.
|Upgraded all shader programs from glsl version <code>150</code> to <code>330</code>
|Upgraded all shader programs from glsl version <code>150</code> to <code>330</code>
|Split the logic for <code>minecraft_mix_light</code> function in <code>include/light.glsl</code> into two additional functions: <code>minecraft_compute_light</code> and <code>minecraft_mix_light_separate</code>
|Split the logic for <code>minecraft_mix_light</code> function in <code>include/light.glsl</code> into two additional functions: <code>minecraft_compute_light</code> and <code>minecraft_mix_light_separate</code>
}}
}}
|{{HistoryLine||1.21.11|dev=25w41a
|{{MC/HistoryLine||1.21.11|dev=25w41a
|Added a new shader program <code>core/debug_point.vsh</code>
|Added a new shader program <code>core/debug_point.vsh</code>
|Removed the <code>LineWidth</code> uniform from the <code>DynamicTransforms</code> uniform block. Line width is now passed as a vertex attribute to the <code>core/rendertype_lines</code> and <code>core/debug_point</code> shaders instead.
|Removed the <code>LineWidth</code> uniform from the <code>DynamicTransforms</code> uniform block. Line width is now passed as a vertex attribute to the <code>core/rendertype_lines</code> and <code>core/debug_point</code> shaders instead.
}}
}}
|{{HistoryLine|||dev=25w44a
|{{MC/HistoryLine|||dev=25w44a
|Added new shader programs <code>core/animate_sprite.vsh</code>, <code>core/animate_sprite_blit.fsh</code>, and <code>core/animate_sprite_interpolate.fsh</code> for rendering [[Minecraft:Resource_pack#Texture_animation|texture animations]].
|Added new shader programs <code>core/animate_sprite.vsh</code>, <code>core/animate_sprite_blit.fsh</code>, and <code>core/animate_sprite_interpolate.fsh</code> for rendering texture animations.
|Changes have been made to the <code>core/terrain</code> shader for texel antialiasing and chunk fade animations.
|Changes have been made to the <code>core/terrain</code> shader for texel antialiasing and chunk fade animations.
|The <code>Sampler0</code> uniform in the <code>core/terrain</code> shader now uses linear filtering instead of nearest.
|The <code>Sampler0</code> uniform in the <code>core/terrain</code> shader now uses linear filtering instead of nearest.
Line 978: Line 978:
|Added two new uniforms, <code>ivec3 CameraBlockPos</code> and <code>vec3 CameraOffset</code>, to the <code>Globals</code> uniform block.
|Added two new uniforms, <code>ivec3 CameraBlockPos</code> and <code>vec3 CameraOffset</code>, to the <code>Globals</code> uniform block.
}}
}}
|{{HistoryLine|||dev=pre1
|{{MC/HistoryLine|||dev=pre1
|The <code>core/terrain.fsh</code> shader has been modified to implement RGSS texture filtering.
|The <code>core/terrain.fsh</code> shader has been modified to implement RGSS texture filtering.
|Added a new uniform, <code>int UseRgss</code>, to the <code>Globals</code> uniforms block.
|Added a new uniform, <code>int UseRgss</code>, to the <code>Globals</code> uniforms block.
}}
}}


|{{HistoryLine||26.1|dev=26.1 Snapshot 1
|{{MC/HistoryLine||26.1|dev=26.1 Snapshot 1
|The <code>core/lightmap.fsh</code> shader has been mostly rewritten
|The <code>core/lightmap.fsh</code> shader has been mostly rewritten
|Added two new uniforms to the <code>LightmapInfo</code> uniform block: <code>vec3 BlockLightTint</code> and <code>vec3 NightVisionColor</code>.
|Added two new uniforms to the <code>LightmapInfo</code> uniform block: <code>vec3 BlockLightTint</code> and <code>vec3 NightVisionColor</code>.
Line 990: Line 990:
|Added a new <code>include/smooth_lighting.glsl</code> shader. Contains a function called <code>minecraft_sample_lightmap</code> used by various shaders to sample the lightmap texture.
|Added a new <code>include/smooth_lighting.glsl</code> shader. Contains a function called <code>minecraft_sample_lightmap</code> used by various shaders to sample the lightmap texture.
}}
}}
|{{HistoryLine|||dev=26.1 Snapshot 5
|{{MC/HistoryLine|||dev=26.1 Snapshot 5
|Various shaders now sample the lightmap texture using the <code>texture</code> function instead of <code>texelFetch</code>. This includes <code>core/entity.vsh</code>, <code>core/rendertype_entity_decal.vsh</code>, <code>core/rendertype_item_entity_translucent_cull.vsh</code>, <code>core/rendertype_leash.vsh</code>, <code>core/rendertype_text.vsh</code>, <code>core/rendertype_text_background.vsh</code>, <code>core/rendertype_text_intensity.vsh</code>, and <code>core/rendertype_translucent_moving_block.vsh</code>.
|Various shaders now sample the lightmap texture using the <code>texture</code> function instead of <code>texelFetch</code>. This includes <code>core/entity.vsh</code>, <code>core/rendertype_entity_decal.vsh</code>, <code>core/rendertype_item_entity_translucent_cull.vsh</code>, <code>core/rendertype_leash.vsh</code>, <code>core/rendertype_text.vsh</code>, <code>core/rendertype_text_background.vsh</code>, <code>core/rendertype_text_intensity.vsh</code>, and <code>core/rendertype_translucent_moving_block.vsh</code>.
}}
}}
|{{HistoryLine|||dev=26.1 Snapshot 6
|{{MC/HistoryLine|||dev=26.1 Snapshot 6
|The <code>core/rendertype_item_entity_translucent_cull</code> shader has been removed, most things that were previously handled by this shader are now handled by <code>core/entity</code>.
|The <code>core/rendertype_item_entity_translucent_cull</code> shader has been removed, most things that were previously handled by this shader are now handled by <code>core/entity</code>.
|The <code>core/rendertype_entity_alpha</code> and <code>core/rendertype_entity_decal</code> shaders have been removed and replaced by a <code>DISSOLVE</code> define directive in <code>core/entity</code>
|The <code>core/rendertype_entity_alpha</code> and <code>core/rendertype_entity_decal</code> shaders have been removed and replaced by a <code>DISSOLVE</code> define directive in <code>core/entity</code>
|All item models are now rendered using a new <code>core/item</code> shader instead of <code>core/entity</code>, with the exception of special model renderers which still use <code>core/entity</code>
|All item models are now rendered using a new <code>core/item</code> shader instead of <code>core/entity</code>, with the exception of special model renderers which still use <code>core/entity</code>
}}
}}
|{{HistoryLine|||dev=26.1 Snapshot 7
|{{MC/HistoryLine|||dev=26.1 Snapshot 7
|The <code>core/terrain.vsh</code> and <code>core/block.vsh</code> shaders no longer have the <code>Normal</code> vertex attribute
|The <code>core/terrain.vsh</code> and <code>core/block.vsh</code> shaders no longer have the <code>Normal</code> vertex attribute
|Some small changes were to how various shaders sample the lightmap texture. This includes <code>core/entity.vsh</code>, <code>core/item.vsh</code>, <code>core/rendertype_leash.vsh</code>, <code>core/rendertype_text.vsh</code>, <code>core/rendertype_text_background.vsh</code>, <code>core/rendertype_text_intensity.vsh</code>, and <code>core/rendertype_translucent_moving_block.vsh</code>.
|Some small changes were to how various shaders sample the lightmap texture. This includes <code>core/entity.vsh</code>, <code>core/item.vsh</code>, <code>core/rendertype_leash.vsh</code>, <code>core/rendertype_text.vsh</code>, <code>core/rendertype_text_background.vsh</code>, <code>core/rendertype_text_intensity.vsh</code>, and <code>core/rendertype_translucent_moving_block.vsh</code>.
}}
}}
|{{HistoryLine|||dev=26.1 Snapshot 10
|{{MC/HistoryLine|||dev=26.1 Snapshot 10
|The <code>include/smooth_lighting.glsl</code> shader has been removed and replaced by a new <code>include/sample_lightmap.glsl</code> shader. This contains a function called <code>sample_lightmap</code> used by various shaders to sample the lightmap texture.
|The <code>include/smooth_lighting.glsl</code> shader has been removed and replaced by a new <code>include/sample_lightmap.glsl</code> shader. This contains a function called <code>sample_lightmap</code> used by various shaders to sample the lightmap texture.
|The following shaders; <code>core/block.vsh</code>, <code>core/entity.vsh</code>, <code>core/item.vsh</code>, <code>core/particle.vsh</code>, <code>core/rendertype_leash.vsh</code>, <code>core/rendertype_text.vsh</code>, <code>core/rendertype_text_background.vsh</code>, <code>core/rendertype_text_intensity.vsh</code>, <code>core/rendertype_translucent_moving_block.vsh</code>, and <code>core/terrain.vsh</code>, now sample the lightmap texture using the helper function declared in <code>include/sample_lightmap.glsl</code>.
|The following shaders; <code>core/block.vsh</code>, <code>core/entity.vsh</code>, <code>core/item.vsh</code>, <code>core/particle.vsh</code>, <code>core/rendertype_leash.vsh</code>, <code>core/rendertype_text.vsh</code>, <code>core/rendertype_text_background.vsh</code>, <code>core/rendertype_text_intensity.vsh</code>, <code>core/rendertype_translucent_moving_block.vsh</code>, and <code>core/terrain.vsh</code>, now sample the lightmap texture using the helper function declared in <code>include/sample_lightmap.glsl</code>.
|<code>core/rendertype_crumbling.vsh</code> no longer defines a varying named <code>texCoord2</code>
|<code>core/rendertype_crumbling.vsh</code> no longer defines a varying named <code>texCoord2</code>
}}
}}
|{{HistoryLine|||dev=26.1 Pre-Release 1
|{{MC/HistoryLine|||dev=26.1 Pre-Release 1
|The <code>core/rendertype_translucent_moving_block</code> shaders have been removed. Objects which were previously rendered by this shader are now handled by <code>core/block</code>
|The <code>core/rendertype_translucent_moving_block</code> shaders have been removed. Objects which were previously rendered by this shader are now handled by <code>core/block</code>
}}
}}


|{{HistoryLine|Java edition upcoming}}
|{{MC/HistoryLine|Java edition upcoming}}
|{{HistoryLine||26.2|dev=26.2 Snapshot 1
|{{MC/HistoryLine||26.2|dev=26.2 Snapshot 1
|The <code>core/rendertype_text</code>, <code>core/rendertype_text_see_through</code>, <code>core/rendertype_text_intensity</code>, and <code>core/rendertype_text_intensity_see_through</code> shaders have been merged into new <code>core/text</code> shaders. Three defines are available for handling variants of text; <code>IS_GUI</code>, <code>IS_SEE_THROUGH</code>, and <code>IS_GRAYSCALE</code>.
|The <code>core/rendertype_text</code>, <code>core/rendertype_text_see_through</code>, <code>core/rendertype_text_intensity</code>, and <code>core/rendertype_text_intensity_see_through</code> shaders have been merged into new <code>core/text</code> shaders. Three defines are available for handling variants of text; <code>IS_GUI</code>, <code>IS_SEE_THROUGH</code>, and <code>IS_GRAYSCALE</code>.
|The <code>core/rendertype_text_background</code> and <code>core/rendertype_text_background_see_through</code> shaders have been merged into new <code>core/text_background</code> shaders. The <code>IS_SEE_THROUGH</code> define is availble for handling see-through backgrounds.
|The <code>core/rendertype_text_background</code> and <code>core/rendertype_text_background_see_through</code> shaders have been merged into new <code>core/text_background</code> shaders. The <code>IS_SEE_THROUGH</code> define is availble for handling see-through backgrounds.
Line 1,029: Line 1,029:


== Issues ==
== Issues ==
{{issue list}}
{{MC/Issue list}}


== References ==
== References ==
{{reflist}}
{{MC/Reflist}}


== Notes ==
== Notes ==
Line 1,047: Line 1,047:


== Navigation ==
== Navigation ==
{{Navbox resource packs}}
{{MC/Navbox resource packs}}
{{Navbox Java Edition technical|resourcepack}}
{{MC/Navbox Java Edition technical|resourcepack}}


[[Category:Gameplay]]
[[Category:Gameplay]]


[[Minecraft:de:Shaderdaten]]
de:Shaderdaten
[[Minecraft:es:Sombreador]]
es:Sombreador
[[Minecraft:fr:Filtres]]
fr:Filtres
[[Minecraft:ja:シェーダー]]
ja:シェーダー
[[Minecraft:pl:Shadery]]
pl:Shadery
[[Minecraft:pt:Shader]]
pt:Shader
[[Minecraft:ru:Шейдеры]]
ru:Шейдеры
[[Minecraft:zh:着色器]]
zh:着色器

Latest revision as of 20:55, 9 April 2026

Script error: No such module "Exclusive".{{#vardefine: $edition | Template:El }}Template:Message boxTemplate:Article other

  1. REDIRECT Template:Work in progress

Template:Redr

Shaders are used to define the game's rendering of certain elements.

Java Edition

in Template:Editions, two distinct kinds of shaders are used: core shaders and post-processing shaders. Core shaders are used to render fundamental parts of the game such as entities and terrain, while post-processing shaders are used to apply visual effects to the screen after core shaders have ran.

Examples of post-processing shaders include the menu background blur, certain mob vision types as seen in spectator, the Fabulous! graphics setting's fixed handling of translucent object, and the glowing status effect.

Shaders are written in the OpenGL Shading Language (GLSL). Each shader programTemplate:Note comes in two parts, the vertex and fragment shader. Vertex shaders define the positions of individual vertices, whereas fragment shaders define the final color of a single render fragment. For example, vertex shaders are often used to create waving foliage and water, and fragment shaders can be used to add effects like bloom, god rays, and blur. In Minecraft, vertex shaders must use the extension .vsh, and fragment shaders .fsh.

Shader programs are stored in the assets/minecraft/shaders directory of Minecraft:client.jar, and can be replaced with a resource pack. Note that if any error occurs when loading the shaders, the resource pack is disabled and fabulous graphics mode is turned off.

Core shaders

Template:Message box

Core shaders are used to render almost everything in the game, including terrain, entities, gui elements, etc. The shader programs for core shaders are located in the assets/<namespace>/shaders/core directory of a resourcepack.

Some objects are not drawn using shaders, this includes:

  • The sky in the nether and bottom half of the overworld. These are the opengl clear color which is set to the same value as the FogColor uniform

List of core shaders

A list of all core shaders can be found by expanding the header below, listing descriptions of what each shader is responsible for, as well as what uniforms, samplers, and define directives are available to each shader.

Name Used for Sample images Available uniforms blocks Available samplers.

All samplers are of type sampler2d unless otherwise specified

Define directives
animate_sprite_blit Renders non-interpolated texture animations, as well as any non-animated sprite to a texture atlas.

Uses the core/animate_sprite.vsh vertex program.

SpriteAnimationInfo Sprite - The next animation frame None present.
animate_sprite_interpolate Renders interpolated texture animations to a texture atlas.

Uses the core/animate_sprite.vsh vertex program.

SpriteAnimationInfo CurrentSprite - The current animation frame

NextSprite - The next animation frame

None present.
blit_screen Copies one buffer to another.

Uses the core/screenquad.vsh vertex program.

None present. Sampler0 - The buffer to copy from. None present.
block Renders blocks that aren't part of chunk meshes such as falling sand, blocks being moved by a piston, or pistons while moving a block. ​<more information needed></more information needed>
File:Core shader block highlight.png
DynamicTransforms

Fog

Projection

Sampler0 - The blocks atlas.

Sampler2 - The lightmap.

ALPHA_CUTOUT - Minimum opacity before pixels are discarded, if not defined no pixels get discarded.
debug_point Used for some debug renderers ​<more information needed></more information needed>

Uses the core/position_color.fsh fragment program.

DynamicTransforms

Projection

None present. None present.
entity Renders most entities including but not limited to:
  • Mobs
  • End crystal beams
  • Block entities that use special rendering such as banners and chests, both in the world and in guis
  • Equipment and other overlays such as the charged creeper energy swirls
  • Experience orbs
File:Core shader entity highlight.png
DynamicTransforms

Fog

Lighting

Projection

Sampler0 - The base texture of the entity.

Sampler1 - The red damage indicator overlay.

Sampler2 - The lightmap.

DissolveMaskSampler - An alpha mask to use when the DISSOLVE define is set.

ALPHA_CUTOUT - Minimum opacity before pixels are discarded, if not defined no pixels get discarded.

APPLY_TEXTURE_MATRIX - Whether or not the uv should be offset by the TextureMat uniform.

EMISSIVE - Whether or not lighting should be applied to the entity.

NO_CARDINAL_LIGHTING - Whether or not directional shading should be applied.

NO_OVERLAY - Whether or not the red damage tint should be applied.

PER_FACE_LIGHTING - Whether or not lighting should be calculated seperately for the front and back quad faces.

DISSOLVE - Whether or not the DissolveMaskSampler should be used as an alpha mask.

glint Renders the enchantment glint on items, equipment, etc.
File:Core shader glint highlight.png
DynamicTransforms

Fog

Globals

Projection

Sampler0 - The enchantment glint texture. None present.
gui Renders flat colored gui elements including but not limited to:
  • Chat and F3 screen text background
  • Advancement screen lines and background darken effect
  • Background of resource/datapack screen items
  • Background of selected world/server in world/server screens
  • Loading screen background
  • Selected language in language menu
  • Selected statistic in statistics menu
  • Inventory screen backgrounds
  • World loading progress
  • Text background on "Saving world" and similar screens
File:Core shader gui highlight.png
File:Core shader gui 2 highlight.png
DynamicTransforms

Projection

None present. None present.
item Renders item models in various contexts, such as when dropped on the ground, held in an entities hand, in a display entity, etc
File:Core shader item highlight.png
DynamicTransforms

Fog

Lighting

Projection

Sampler0 - The items or blocks atlas depending on the model currently being rendered.

Sampler2 - The lightmap.

ALPHA_CUTOUT - Minimum opacity before pixels are discarded, if not defined no pixels get discarded.
lightmap Renders the lightmap which is used by other shaders to determine how bright or dark parts of the world should be.

Uses the core/screenquad.vsh vertex program.

File:Core shader lightmap highlight.png
In this image the lightmap shader outputs a horizontal gradient from black to red
File:Core shader lightmap visualisation.png
Here the lightmap has been modified to output a gradient from black to red horizontally, and black to green vertically. A mod has been used to display the output of this shader to the top left of the screen for a clearer visualisation
LightmapInfo None present. None present.
panorama Renders the title screen panorama cubemap.
File:Core shader position tex highlight.png
DynamicTransforms

Projection

Sampler0 (samplerCube) - A cubemap sampler containing all 6 panorama images. None present.
particle Renders all particle effects. Also renders the rain and snow weather effects.
File:Core shader particle highlight.png
DynamicTransforms

Fog

Projection

Sampler0 - The particles or blocks atlas, depending on the particle that is being rendered. If rendering a weather effect then this is the corresponding texture for that effect.

Sampler2 - The lightmap.

None present.
position_color Renders the lower half of the sky at sunrise and sunset. Also renders the F3 debug pie and chunk borders.
File:Core shader position color highlight.png
File:Core shader position color 2 highlight.png
DynamicTransforms

Projection

None present. None present.
position_tex_color Renders some miscellaneous textured things including but not limited to:
  • The end skybox
  • GUI buttons, backgrounds, tooltips, icons etc
  • Pre-rendered items and entities in GUIs (see the Render process section for more information)
  • World icons, server icons, resourcepack icons, datapack icons, etc
  • HUD elements such as the hotbar, crosshair, health hearts, tab list heads, etc
  • The Mojang and Minecraft logos
  • Fire overlay
  • Camera overlay effects such as the vignette, pumpkin blur, freezing effect, etc
  • The sun and moon
File:Core shader position tex color highlight JE2.png
File:Position tex color 3 highlight.png
In this image, the square to the right is a prerendered item being drawn onto a quad
DynamicTransforms

Projection

Sampler0 - For most gui widgets and icons, this is the gui atlas. For world, resourcepack, etc icons, mojang logo, camera overlays, or other non-gui things this is the texture of the object being rendered. None present.
position_tex Unused. None present. None present. None present.
position Handles depth for the ender dragon's death rays​<more information needed></more information needed>. DynamicTransforms

Fog

Projection

None present. None present.
rendertype_beacon_beam Renders the beacon and end gateway beams.
File:Core shader rendertype beacon beam highlight.png
DynamicTransforms

Fog

Projection

Sampler0 - The texture of the current part of the beam being rendered. None present.
rendertype_clouds Renders the clouds.
File:Core shader rendertype clouds highlight.png
CloudInfo

DynamicTransforms

Fog

Projection

CloudFaces (isamplerBuffer) - Data about cloud faces​<more information needed></more information needed> None present.
rendertype_crumbling Renders the block breaking animation.
File:Core shader rendertype crumbling highlight.png
DynamicTransforms

Fog - Although not explicitly defined in the code this can be used

Projection

Sampler0 - The texture for current stage of the block breaking animation. None present
rendertype_end_portal Renders the end portal and end gateway block entities, as well as the end_cube special model type
File:Core shader rendertype end portal highlight JE2.png
DynamicTransforms

Fog

Globals

Projection

Sampler0 - The end sky texture textures/environment/end_sky.png.

Sampler1 - The end portal stars texture textures/entity/end_portal.png.

PORTAL_LAYERS - The amount of star layers to render.
rendertype_entity_shadow Renders the shadow that appears under most entities.
File:Core shader rendertype entity shadow highlight JE2.png
Highlighted in orange is where the shadow is normally visible in vanilla
DynamicTransforms

Fog

Projection

Sampler0 - The shadow texture textures/misc/shadow.png. None present.
rendertype_leash Renders leads that are attached to entities in the world.
File:Core shader rendertype leash highlight JE2.png
DynamicTransforms

Fog

Projection

Sampler2 - The lightmap. None present.
rendertype_lightning Renders lightning bolts and the ender dragon's death rays.
File:Core shader rendertype lightning highlight.png
File:Core shader rendertype lightning 2 highlight.png
DynamicTransforms

Fog

Projection

None present. None present.
rendertype_lines Renders all types of lines including:
  • The block outline
  • Entity debug hitboxes
  • The F3 screen crosshair
  • Structure and test block bounding boxes
File:Core shader rendertype lines highlight JE2.png
DynamicTransforms

Fog

Globals

Projection

None present. None present.
rendertype_outline Renders a flat colored outline of entities which have the glowing effect.

The colour of this is based on the team the entity is in, or the glow color override for display entities, which is passed to the shader via the Color vertex attribute.

The output of this shader is saved to a buffer and then later used in the entity_outline post effect to create the full glowing effect.

File:Core shader rendertype outline highlight JE2.png
In this image, the entity_outline post effect has been disabled to clearly show what this shader outputs
DynamicTransforms

Projection

Sampler0 - The base texture of the object being rendered. None present.
rendertype_text_background_see_through Renders the background of text display entities that are set to render through blocks.
File:Core shader rendertype text background see through highlight.png
DynamicTransforms

Projection

None present. None present.
rendertype_text_background Renders the background of text display entities that are not set to render through blocks.
File:Core shader rendertype text background highlight.png
DynamicTransforms

Fog

Projection

None present. None present.
rendertype_text_see_through

rendertype_text_intensity_see_through

Renders text that is visible through blocks. Also renders the background of player and entity nameplates.

Note: rendertype_text_intensity_see_through is identical, however it is only used to render ttf fonts.

File:Core shader rendertype text see through highlight JE2.png
DynamicTransforms

Projection

Sampler0 - An automatically generated 256x256 atlas which contains the current character that is being rendered. None present.
rendertype_text

rendertype_text_intensity

Renders text in the world and in GUIs. Also renders maps in item frames or when held in first person.

Note: rendertype_text_intensity is identical, however it is only used to render ttf fonts.

File:Core shader rendertype text highlight JE2.png
File:Core shader rendertype text 2 highlight.png
DynamicTransforms

Fog

Projection

Sampler0 - An automatically generated 256x256 atlas which contains the current character that is being rendered. For maps, this is the map background texture, map_decorations atlas, or the map itself depending on which part is currently being rendered.

Sampler2 - The lightmap.

None present.
rendertype_water_mask A mask used to hide water inside boats.
File:Core shader rendertype water mask highlight.png
In this image the shader has been edited to discard all pixels on the right half of the screen
DynamicTransforms

Projection

None present. None present.
rendertype_world_border Renders the world border.
File:Core shader rendertype world border highlight.png
DynamicTransforms

Projection

Sampler0 - The world border texture textures/misc/forcefield.png. None present.
sky Renders the upper half of the overworld skybox.
File:Sky core shader highlight.png
DynamicTransforms

Fog

Projection

None present. None present.
stars Renders the stars in the overworld sky at night.
File:Stars core shader highlight.png
DynamicTransforms

Projection

None present. None present.
terrain Renders all blocks and fluids in the world.
File:Core shader terrain highlight.png
ChunkSection

Fog

Projection

Sampler0 - The blocks atlas.

Sampler2 - The lightmap.

ALPHA_CUTOUT - Minimum opacity before pixels are discarded, if not defined no pixels get discarded.
je 26.2

}}{{#vardefine: $version2 | }}<upcoming: Template:Version link & Template:Version link></upcoming: Template:Version link & Template:Version link>

Renders text background, for example those seen on entity nameplates or text display entities. DynamicTransforms

Fog

Projection

Sampler2 - The lightmap IS_SEE_THROUGH - Defined if the shader has no depth test and can be seen through other objects.
je 26.2

}}{{#vardefine: $version2 | }}<upcoming: Template:Version link & Template:Version link></upcoming: Template:Version link & Template:Version link>

Renders text in the world and in GUIs. Also renders maps in item frames or when held in first person. DynamicTransforms

Fog (only when IS_GUI is not defined)

Projection

Sampler0 - An automatically generated 256x256 atlas which contains the current character that is being rendered. For maps, this is the map background texture, map_decorations atlas, or the map itself depending on which part is currently being rendered.

Sampler2 - The lightmap (only when IS_GUI is not defined)

IS_GRAYSCALE - Defined if the shader should treat the font texture as an intensity texture for TTF font rendering.

IS_SEE_THROUGH - Defined if the shader has no depth test and can be seen through other objects.

IS_GUI - Defined if the shader handles text for the gui.

Include shaders

Include shaders (stored in assets/<namespace>/shaders/include) contain helper functions and variables that can be used in multiple shader programs. These must have the .glsl, .vsh, or .fsh file extensions.

To import an include shader, add one of the following import directives anywhere in a vertex or fragment shader program

  • #moj_import <filepath.glsl> imports a file from assets/minecraft/shaders/include/<filepath>.glsl
  • #moj_import <namespace:path.glsl> imports a file from assets/<namespace>/shaders/include/<path>.glsl
  • #moj_import "filepath.glsl" imports a file from assets/minecraft/shaders/core/<filepath>.glsl

When importing an include shader, the game replaces the import directive with the contents of the include shader. The imported file needs to end with an empty line, otherwise the shader does not load.

Vanilla include shaders

The following include shaders are used throughout the vanilla resource pack

Name Description
fog.glsl Contains the linear_fog function to calculate the color based on the vertex distance. Contains a definition of the Fog uniform block
light.glsl Contains the minecraft_mix_light function, used to calculate face lighting in entity shaders. Contains a definition of the Lighting uniform block
matrix.glsl Contains the mat2_rotate_z function that returns the rotation matrix for a vec2 around the z-axis.
projection.glsl Contains the projection_from_position function. Contains a definition of the Projection uniform block
globals.glsl Contains a definition of the Globals uniform block.
dynamictransforms.glsl Contains a definition of the DynamicTransforms uniform block.
chunksection.glsl Contains a definition of the ChunkSection uniform block.
animation_sprite.glsl Contains a definition of the SpriteAnimationInfo uniform block.
sample_lightmap.glsl Contains the sample_lightmap function, used by various shaders to sample the lightmap texture.

Post-processing effects

As mentioned previously, post-processing effects are used in menu backgrounds, when spectating certain mobs to create vision effects, the Fabulous! graphics setting, and when rendering the glowing effect.

Post-effect file format

Post-processing effects are made up of multiple passes and render targets. A target is a buffer that can be read from and written to. The game provides some built-in targets that contain certain parts of the game world (particles, water, etc), and you can define your own to read and write data to. A pass can have multiple inputs from png textures or render targets.

Post-processing effects are defined in assets/<namespace>/post_effect/<post effect>.json. Note that post-processing effects are applied before the HUD and GUI elements are rendered

  • Template:Nbt/sprite: The root tag
    • Template:Nbt/sprite  targets: Custom render targets to be used by render passes
      • Template:Nbt/sprite  target definition: The key is the name of the target
        • Template:Nbt/sprite  width: Defaults to the current viewport width. The width of the target
        • Template:Nbt/sprite  height: Defaults to the current viewport height. The height of the target
        • Template:Nbt/sprite  persistent: Defaults to false. If true, this target is not cleared between frames. It is still cleared when the game window is resized, however.
        • Template:Nbt/spriteTemplate:Nbt/sprite  clear_color Defaults to [0, 0, 0, 0]. The colour this target is filled with when it is created or cleared. Supports two formats. A list of floats in 0-1 range [R, G, B, A], or a colour in decimal format calculated from the red, green and blue components using this formula:
          (Alpha << 24) + (Red << 16) + (Green << 8) + Blue
    • Template:Nbt/sprite  passes: Render passes
      • Template:Nbt/sprite  pass: A render pass
        • Template:Nbt/sprite  vertex_shader: The namespaced id of a vertex shader to use for this pass, relative to the shaders folder. minecraft:post/blit resolves to assets/minecraft/shaders/post/blit.vsh
        • Template:Nbt/sprite  fragment_shader: The namespaced id of a fragment shader to use for this pass, relative to the shaders folder. minecraft:post/box_blur resolves to assets/minecraft/shaders/post/box_blur.fsh
        • Template:Nbt/sprite  inputs: A list of render target inputs and / or texture inputs
          • Template:Nbt/sprite  render target input
            • Template:Nbt/sprite  sampler_name: The name of the sampler uniform
              • Setting this to MainDepth, for example, makes a sampler2D uniform called MainDepthSampler available to the shader program for this pass. This will also provide an additional vec2 to the SamplerInfo uniform block called <sampler_name>Size, for example MainDepthSize
            • Template:Nbt/sprite  bilinear: Default: false. If set to true, the sampler uses bilinear filtering instead of nearest neighbor
            • Template:Nbt/sprite  target: The name of the target. Can either be a custom target as specified in targets above, or one of the following built in targets: minecraft:main, minecraft:translucent, minecraft:item_entity, minecraft:particles, minecraft:weather, minecraft:clouds, or minecraft:entity_outline
            • Template:Nbt/sprite  use_depth_buffer: Default: false. If set to true, it samples from the depth texture instead of the color texture.
          • Template:Nbt/sprite  texture input
            • Template:Nbt/sprite  sampler_name: The name of the sampler uniform
              • Setting this to MyTexture, for example, makes a sampler2D uniform called MyTextureSampler available to the shader program for this pass. This will also provide an additional vec2 to the SamplerInfo uniform block called <sampler_name>Size, for example MyTextureSize
            • Template:Nbt/sprite  bilinear: Default: false. If set to true, the sampler uses bilinear filtering instead of nearest neighbor
            • Template:Nbt/sprite  location: The resource location of the texture. my_namespace:post_texture resolves to assets/my_namespace/textures/effect/post_texture.png
            • Template:Nbt/sprite  width: The width of the texture in pixels
            • Template:Nbt/sprite  height: The height of the texture in pixels
        • Template:Nbt/sprite  output: The target to output to. Can either be a custom target as specified in targets above or minecraft:main. Note: you cannot read and write to the same target in the same pass
        • Template:Nbt/sprite  uniforms: An object of uniform blocks to pass to the vertex and fragment shaders. For example, uniforms: { "UniformBlockName": [ { "type": "vec2", "value": [...] } ] }
          • Template:Nbt/sprite  uniform block: The key is what this uniform block will be called when referenced in a shader
            • Template:Nbt/sprite  uniform definition
              • Template:Nbt/sprite  name: The name of the uniform. This is unused by the game, however it is recommended to set it for organizational purposes
              • Template:Nbt/sprite  type: The type of the uniform, can be any of: int, float, ivec3, vec2, vec3, vec4, and matrix4x4
              • Template:Nbt/spriteTemplate:Nbt/spriteTemplate:Nbt/sprite  value: Uniform values. The amount and format of this depends on what the type field is set to
                • int requires a single int
                • float requires a single float
                • ivec3 requires list of 3 ints
                • vec2 requires list of 2 floats
                • vec3 requires list of 3 floats
                • vec4 requires list of 4 floats
                • matrix4x4 requires 16 floats

List of post-processing effects

There are currently six post-processing effects used in the game:

Name Used for Sample images
blur Used for the blur effect in the background of most menus in-game and on the title screen. This post effect is not used when the "Menu Background Blur" accessibility setting is set to 0.
File:Post effect blur.png
File:Post effect blur ingame.png
creeper Adds a green filter over the screen and give the appearance of a reduced resolution. Used when spectating a creeper.
File:Post effect creeper.png
entity_outline Applies a blur over a solid color silhouette of an entity. Used when an entity with the glowing effect is on-screen.
File:Post effect entity outline.png
Left side is the "minecraft:entity_outline" target before the post effect is applied, right side is the final image with the post effect applied
invert Inverts the colours of the screen. Used when spectating an Minecraft:enderman.
File:Post effect invert.png
spider Renders a blurred version of the screen with 5 additional copies overlapped on top with blurred edges. Used when spectating a spider.
File:Post effect spider.png
transparency Combines multiple passes (targets) of different objects in the world, resulting in slightly better translucency blending compared to "Fast" or "Fancy" graphics. Used when the graphics mode is set to "Fabulous!".
File:Post effect transparency main.png
"minecraft:main" target
File:Post effect Transparency translucent.png
"minecraft:translucent" target

File:Post effect transparency item entity.png
"minecraft:item_entity" target
File:Post effect transparency particles.png
"minecraft:particles" target

File:Post effect transparency clouds.png
"minecraft:clouds" target
File:Post effect transparency weather.png
"minecraft:weather" target

File:Post effect transparency.png
Final image

Render process

Template:Message boxTemplate:Article other

General game rendering

Each frame is rendered in the following order​<more information needed></more information needed>

  • The world, including entities, blocks, the sky, items, etc is rendered (by core shaders)
  • Any Post effects are applied as necessary
  • The GUI and HUD elements are rendered (by core shaders)

GUI item and entity rendering

When the game draws an item or entity in a GUI the following process occurs:

  • The item or entity is pre-rendered to an internal texture. For items, this may be an atlas of all currently visible items ("GUI items atlas") or a single texture for that item. This depends on if the oversized_in_gui field is set to true or false in the items model definition. For entities, each one always has a unique texture that it gets rendered to
  • For each item or entity, a quad is drawn to the screen which samples from either the GUI items atlas or individual texture for the corresponding item or entity

The game can skip rendering an item when neccesary and will use whatever was drawn on the previous frame. An item is only re-rendered if one of the following conditions is met:

  • The item has an animated texture somewhere on its model
  • The item has an enchantment glint
  • The GUI items atlas fills up, in this case it is cleared and all currently visible GUI items are redrawn
  • The GUI scale is changed, in this case the GUI items atlas is cleared and all currently visible GUI items are redrawn
  • The item data is changed in a way that would cause a visual update. This includes but is not limited to: changing the item_model, custom_model_data, or profile data components

Vanilla uniform blocks

Template:Message box

Uniforms blocks use the std140 layout. All uniforms must be specified and in the correct order and with the correct type, otherwise weird and undefined behavior will occur. For convenience, some uniform blocks are pre-defined in include shaders, see the include shaders section for more information.

Some shaders may not use all uniforms in a given uniform block, in this case the unused uniforms will have a 'default' value. For example, while the rendertype_lines core shader will have the proper value for the LineWidth uniform, other shaders will have a "default value" for which will likely not be useful.

Common blocks

The following uniform blocks are available in both post-processing and core shaders.

Globals

This uniform block is always bound and has proper values in all shaders. ‌{{ #vardefine: $version | je 26.2 }}{{ #vardefine: $version2 | }}in Template:Version link and Template:Version linkTemplate:Upcoming this excludes lightmap, animate_sprite_interpolate and animate_sprite_blit.

  • (ivec3) CameraBlockPos Block position of the camera in world-space coordinates.
  • (vec3) CameraOffset Fractional position of the camera in world-space coordinates.
  • (vec2) ScreenSize The width and height of the current framebuffer in pixels.
  • (float) GlintAlpha The value of the Glint Strength accessibility setting in a 0-1 range.
  • (float) GameTime A value that constantly increases from 0-1 over the span of roughly 20 minutes, then resets to 0. The exact formula for this is (<age of the world> modulo 24000) / 24000. until Template:Version link this is set to a constant 0 value within animate_sprite_interpolate and animate_sprite_blit.
  • (int) MenuBlurRadius The value of the Menu Background Blur accessibility setting in a 0-10 range.
  • (int) UseRgss A "boolean" value. Value is 1 if the texture filtering video setting is set to RGSS, otherwise 0.

Core blocks

The following uniform blocks are only available in core shaders.

Fog

This uniform block is always bound, however may not have proper values if used outside shaders which support it.

  • (vec4) FogColor Colour of the fog.
  • (float) FogEnvironmentalStart Starting distance of environmental fog.
  • (float) FogEnvironmentalEnd Ending distance of environmental fog.
  • (float) FogRenderDistanceStart Starting distance of render distance fog.
  • (float) FogRenderDistanceEnd Ending distance of render distance fog.
  • (float) FogSkyEnd Ending distance of fog for the upper portion of the sky.
  • (float) FogCloudsEnd Ending distance for clouds fog.
DynamicTransforms
  • (mat4) ModelViewMat The model-view matrix.
  • (vec4) ColorModulator A color multiplier that can be set in game code to modify the final color of objects.
  • (vec3) ModelOffset The offset of the model being rendered.
  • (mat4) TextureMat A 4D matrix used to transform UV's for some animated effects, such as the enchantment glint, breeze and wind charge wind, world border, etc.
Lighting

This uniform block is always bound, however may not have proper values if used outside shaders which support it.

  • (vec3) Light0_Direction First light direction. Used to calculate directional entity shading.
  • (vec3) Light1_Direction Second light direction. Used to calculate directional entity shading.
Projection

This uniform block is always bound, however may not have proper values if used outside shaders which support it.

  • (mat4) ProjMat The projection matrix
LightmapInfo
  • (float) SkyFactor A value that specifies how much to brighten the lightmap by when the sky flashes, typically when a lightning strike occurs. This value comes from the minecraft:visual/sky_light_factor environment attribute.
  • (float) BlockFactor A value that fluctuates randomly, used in the vanilla shader for block light flickering.
  • (float) NightVisionFactor A value in a 0-1 range that specifies how much the Night Vision status effect should brighten the lightmap by.
  • (float) DarknessScale A value in a 0-1 range that specifies how much the Darkness status effect should darken the lightmap by.
  • (float) BossOverlayWorldDarkeningFactor A value that specifies how much to darken the lightmap by when a bossbar is visible. This is seemingly only used in the ender dragon fight ​<more information needed></more information needed>.
  • (float) BrightnessFactor The value of the brightness video setting in a 0-1 range.
  • (vec3) BlockLightTint The color of block light. This value comes from the minecraft:visual/block_light_tint environment attribute.
  • (vec3) SkyLightColor The color of sky light. This value comes from the minecraft:visual/sky_light_color environment attribute.
  • (vec3) AmbientColor The ambient light color. This value comes from the minecraft:visual/ambient_light_color environment attribute.
  • (vec3) NightVisionColor The color of the Night Vision status effect. This value comes from the minecraft:visual/night_vision_color environment attribute.
CloudInfo
ChunkSection
SpriteAnimationInfo

Post-processing blocks

The following uniform blocks are only available in post-processing shaders.

SamplerInfo
  • (vec2) OutSize The width and height of the output buffer in pixels.
  • (vec2) All other inputs specified in the same order as the post-effect definition. These are named as <sampler_name>Size, for example, MainSize for an input with a name of "Main"


Bedrock Edition

Template:Message boxTemplate:Article other

Since Minecraft:Bedrock Edition 1.18.30, third-party shader in resource packs are no longer supported on all devices due to the implementation of Minecraft:RenderDragon.

Deferred rendering pipeline

The deferred rendering pipeline is an alternative rendering pipeline which can be customized via resource packs and is used in the vanilla game for the Minecraft:Vibrant Visuals graphics mode.

Although it doesn't directly support custom shaders, it offers ways to define properties about light, fog, atmosphere, and PBR texture materials. This can be used to create lighting effects similar to those seen in Java Edition's shader packs.

History

Template:HistoryTable

Gallery

Issues

Script error: No such module "Issue list".

References

<references group="">

 </references>

Notes

Template:Notelist

External links

Navigation

Components
Java Edition only
Template:BE only
Built-in
Tutorials
Concepts
General format
World
Legacy
Level format
Legacy
.minecraft
Tools
Sound
Commands

All commands

Launching
Legacy
Protocol
Server
Protocols
Legacy
Components
Tag
GameTest
World generation
Noise settings
Structures
Removed
Data packs
Tutorials
Content
World generation

Template:Article other

de:Shaderdaten es:Sombreador fr:Filtres ja:シェーダー pl:Shadery pt:Shader ru:Шейдеры zh:着色器