Minecraft:Shader: Difference between revisions
More actions
Sync: new page from Minecraft |
Remove broken links to missing pages |
||
| Line 1: | Line 1: | ||
{{About|in-game shaders using | {{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}}{{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}} | ||
'''Shaders''' are used to define the game's rendering of certain elements. | '''Shaders''' are used to define the game's rendering of certain elements. | ||
| Line 6: | Line 6: | ||
{{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. | {{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, | 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 {{code|.vsh}}, and fragment shaders {{code|.fsh}}. | ||
Shader programs are stored in the {{code|assets/minecraft/shaders}} directory of [[Minecraft:client.jar]], and can be replaced with a | Shader programs are stored in the {{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 | {{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 | |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 | |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 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 | 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 636: | Line 636: | ||
**** {{nbt | integer | height}}: Defaults to the current viewport height. The height of the target | **** {{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. | **** {{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 | **** {{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 << 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 | ** {{nbt | list | passes}}: Render passes | ||
*** {{nbt | compound | pass}}: A render pass | *** {{nbt | compound | pass}}: A render pass | ||
| 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 | | 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 | | 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 | | 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 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 | * 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> | * 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 === | ||
| Line 763: | Line 763: | ||
* (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>. {{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 | * (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 | *(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 | *(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 {{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. | ||
| Line 803: | Line 803: | ||
*(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 | *(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> | ||
| Line 812: | Line 812: | ||
;<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 | * (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> {{info needed}} | ||
* (ivec3) <code>ChunkPosition</code> {{info needed}} | * (ivec3) <code>ChunkPosition</code> {{info needed}} | ||
| 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 | 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 == | ||
| Line 846: | Line 846: | ||
|{{HistoryLine|java}} | |{{HistoryLine|java}} | ||
|{{HistoryLine||1.7.2|dev=13w38a | |{{HistoryLine||1.7.2|dev=13w38a | ||
|Shaders were added for | |Shaders were added for Super Secret Settings. | ||
}} | }} | ||
|{{HistoryLine||1.8|dev=14w05a | |{{HistoryLine||1.8|dev=14w05a | ||
|The Creeper and Spider shaders were added. Shaders are automatically applied in | |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 | ||
| Line 858: | Line 858: | ||
}} | }} | ||
|{{HistoryLine||1.9|dev=15w31a | |{{HistoryLine||1.9|dev=15w31a | ||
|Removed the | |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 | |{{HistoryLine||1.16|dev=20w22a | ||
| Line 892: | Line 892: | ||
}} | }} | ||
|{{HistoryLine|||dev=24w11a | |{{HistoryLine|||dev=24w11a | ||
|All unused post-processing shaders that were used for | |All unused post-processing shaders that were used for Super Secret Settings have been removed. | ||
}} | }} | ||
|{{HistoryLine||1.21.2|dev=24w34a | |{{HistoryLine||1.21.2|dev=24w34a | ||
| Line 904: | Line 904: | ||
}} | }} | ||
|{{HistoryLine|||dev=? | |{{HistoryLine|||dev=? | ||
|The <code>moj_import</code> directive now accepts a | |The <code>moj_import</code> directive now accepts a resource location, allowing include shaders to be placed in namespaces other than '''minecraft''' | ||
}} | }} | ||
|{{HistoryLine|||dev=? | |{{HistoryLine|||dev=? | ||
| Line 971: | Line 971: | ||
}} | }} | ||
|{{HistoryLine|||dev=25w44a | |{{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 | |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 1,052: | Line 1,052: | ||
[[Category:Gameplay]] | [[Category:Gameplay]] | ||
de:Shaderdaten | |||
es:Sombreador | |||
fr:Filtres | |||
ja:シェーダー | |||
pl:Shadery | |||
pt:Shader | |||
ru:Шейдеры | |||
zh:着色器 | |||
Revision as of 16:03, 9 April 2026
|
For the {{{Description}}} of the same name, see [[{{{Destination}}}]]. |
Template:ExclusiveTemplate:Removed featureTemplate:Wip
Shaders are used to define the game's rendering of certain elements.
Java Edition
Template:In, 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 Template:Code, and fragment shaders Template:Code.
Shader programs are stored in the Template:Code 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 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
FogColoruniform
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 |
Define directives |
|---|---|---|---|---|---|
| animate_sprite_blit | Renders non-interpolated texture animations, as well as any non-animated sprite to a texture atlas.
Uses the |
SpriteAnimationInfo
|
Sprite - The next animation frame
|
None present. | |
| animate_sprite_interpolate | Renders interpolated texture animations to a texture atlas.
Uses the |
SpriteAnimationInfo
|
CurrentSprite - The current animation frame
|
None present. | |
| blit_screen | Copies one buffer to another.
Uses the |
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. Template:Info needed | DynamicTransforms
|
Sampler0 - The blocks atlas.
|
ALPHA_CUTOUT - Minimum opacity before pixels are discarded, if not defined no pixels get discarded.
| |
| debug_point | Used for some debug renderers Template:Info needed
Uses the |
DynamicTransforms
|
None present. | None present. | |
| entity | Renders most entities including but not limited to:
|
DynamicTransforms
|
Sampler0 - The base texture of the entity.
|
ALPHA_CUTOUT - Minimum opacity before pixels are discarded, if not defined no pixels get discarded.
| |
| glint | Renders the enchantment glint on items, equipment, etc. | DynamicTransforms
|
Sampler0 - The enchantment glint texture.
|
None present. | |
| gui | Renders flat colored gui elements including but not limited to:
|
DynamicTransforms
|
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 | DynamicTransforms
|
Sampler0 - The items or blocks atlas depending on the model currently being rendered.
|
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 |
LightmapInfo
|
None present. | None present. | |
| panorama | Renders the title screen panorama cubemap. |
|
DynamicTransforms
|
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. |
|
DynamicTransforms
|
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.
|
None present. |
| position_color | Renders the lower half of the sky at sunrise and sunset. Also renders the F3 debug pie and chunk borders. |
|
DynamicTransforms
|
None present. | None present. |
| position_tex_color | Renders some miscellaneous textured things including but not limited to:
|
|
DynamicTransforms
|
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 raysTemplate:Info needed. | DynamicTransforms
|
None present. | None present. | |
| rendertype_beacon_beam | Renders the beacon and end gateway beams. |
|
DynamicTransforms
|
Sampler0 - The texture of the current part of the beam being rendered.
|
None present. |
| rendertype_clouds | Renders the clouds. |
|
CloudInfo
|
CloudFaces (isamplerBuffer) - Data about cloud facesTemplate:Info needed
|
None present. |
| rendertype_crumbling | Renders the block breaking animation. |
|
DynamicTransforms
|
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
|
|
DynamicTransforms
|
Sampler0 - The end sky texture textures/environment/end_sky.png.
|
PORTAL_LAYERS - The amount of star layers to render.
|
| rendertype_entity_shadow | Renders the shadow that appears under most entities. |
|
DynamicTransforms
|
Sampler0 - The shadow texture textures/misc/shadow.png.
|
None present. |
| rendertype_leash | Renders leads that are attached to entities in the world. |
|
DynamicTransforms
|
Sampler2 - The lightmap.
|
None present. |
| rendertype_lightning | Renders lightning bolts and the ender dragon's death rays. |
|
DynamicTransforms
|
None present. | None present. |
| rendertype_lines | Renders all types of lines including:
|
|
DynamicTransforms
|
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 The output of this shader is saved to a buffer and then later used in the |
|
DynamicTransforms
|
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. |
|
DynamicTransforms
|
None present. | None present. |
| rendertype_text_background | Renders the background of text display entities that are not set to render through blocks. |
|
DynamicTransforms
|
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. |
|
DynamicTransforms
|
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. |
|
DynamicTransforms
|
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.
|
None present. |
| rendertype_water_mask | A mask used to hide water inside boats. |
|
DynamicTransforms
|
None present. | None present. |
| rendertype_world_border | Renders the world border. |
|
DynamicTransforms
|
Sampler0 - The world border texture textures/misc/forcefield.png.
|
None present. |
| sky | Renders the upper half of the overworld skybox. |
|
DynamicTransforms
|
None present. | None present. |
| stars | Renders the stars in the overworld sky at night. |
|
DynamicTransforms
|
None present. | None present. |
| terrain | Renders all blocks and fluids in the world. |
|
ChunkSection
|
Sampler0 - The blocks atlas.
|
ALPHA_CUTOUT - Minimum opacity before pixels are discarded, if not defined no pixels get discarded.
|
| text_background Template:Upcoming | Renders text background, for example those seen on entity nameplates or text display entities. | DynamicTransforms
|
Sampler2 - The lightmap
|
IS_SEE_THROUGH - Defined if the shader has no depth test and can be seen through other objects.
| |
| text Template:Upcoming | Renders text in the world and in GUIs. Also renders maps in item frames or when held in first person. | DynamicTransforms
|
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.
|
IS_GRAYSCALE - Defined if the shader should treat the font texture as an intensity texture for TTF font rendering.
|
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 fromassets/minecraft/shaders/include/<filepath>.glsl#moj_import <namespace:path.glsl>imports a file fromassets/<namespace>/shaders/include/<path>.glsl#moj_import "filepath.glsl"imports a file fromassets/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: The root tag
- Template:Nbt: Custom render targets to be used by render passes
- Template:Nbt: The key is the name of the target
- Template:Nbt: Defaults to the current viewport width. The width of the target
- Template:Nbt: Defaults to the current viewport height. The height of the target
- Template:Nbt: Defaults to false. If true, this target is not cleared between frames. It is still cleared when the game window is resized, however.
- Template:NbtTemplate:Nbt 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: The key is the name of the target
- Template:Nbt: Render passes
- Template:Nbt: A render pass
- Template:Nbt: The namespaced id of a vertex shader to use for this pass, relative to the shaders folder.
minecraft:post/blitresolves toassets/minecraft/shaders/post/blit.vsh - Template:Nbt: The namespaced id of a fragment shader to use for this pass, relative to the shaders folder.
minecraft:post/box_blurresolves toassets/minecraft/shaders/post/box_blur.fsh - Template:Nbt: A list of render target inputs and / or texture inputs
- Template:Nbt
- Template:Nbt: The name of the sampler uniform
- Setting this to
MainDepth, for example, makes a sampler2D uniform calledMainDepthSampleravailable to the shader program for this pass. This will also provide an additional vec2 to theSamplerInfouniform block called<sampler_name>Size, for exampleMainDepthSize
- Setting this to
- Template:Nbt: Default: false. If set to true, the sampler uses bilinear filtering instead of nearest neighbor
- Template:Nbt: The name of the target. Can either be a custom target as specified in
targetsabove, or one of the following built in targets:minecraft:main,minecraft:translucent,minecraft:item_entity,minecraft:particles,minecraft:weather,minecraft:clouds, orminecraft:entity_outline - Template:Nbt: Default: false. If set to true, it samples from the depth texture instead of the color texture.
- Template:Nbt: The name of the sampler uniform
- Template:Nbt
- Template:Nbt: The name of the sampler uniform
- Setting this to
MyTexture, for example, makes a sampler2D uniform calledMyTextureSampleravailable to the shader program for this pass. This will also provide an additional vec2 to theSamplerInfouniform block called<sampler_name>Size, for exampleMyTextureSize
- Setting this to
- Template:Nbt: Default: false. If set to true, the sampler uses bilinear filtering instead of nearest neighbor
- Template:Nbt: The resource location of the texture.
my_namespace:post_textureresolves toassets/my_namespace/textures/effect/post_texture.png - Template:Nbt: The width of the texture in pixels
- Template:Nbt: The height of the texture in pixels
- Template:Nbt: The name of the sampler uniform
- Template:Nbt
- Template:Nbt: The target to output to. Can either be a custom target as specified in
targetsabove orminecraft:main. Note: you cannot read and write to the same target in the same pass - Template:Nbt: An object of uniform blocks to pass to the vertex and fragment shaders. For example,
uniforms: { "UniformBlockName": [ { "type": "vec2", "value": [...] } ] }- Template:Nbt: The key is what this uniform block will be called when referenced in a shader
- Template:Nbt
- Template:Nbt: The name of the uniform. This is unused by the game, however it is recommended to set it for organizational purposes
- Template:Nbt: The type of the uniform, can be any of:
int,float,ivec3,vec2,vec3,vec4, andmatrix4x4 - Template:NbtTemplate:NbtTemplate:Nbt: Uniform values. The amount and format of this depends on what the
typefield is set tointrequires a single intfloatrequires a single floativec3requires list of 3 intsvec2requires list of 2 floatsvec3requires list of 3 floatsvec4requires list of 4 floatsmatrix4x4requires 16 floats
- Template:Nbt
- Template:Nbt: The key is what this uniform block will be called when referenced in a shader
- Template:Nbt: The namespaced id of a vertex shader to use for this pass, relative to the shaders folder.
- Template:Nbt: A render pass
- Template:Nbt: Custom render targets to be used by render passes
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. |
|
| creeper | Adds a green filter over the screen and give the appearance of a reduced resolution. Used when spectating a creeper. |
|
| entity_outline | Applies a blur over a solid color silhouette of an entity. Used when an entity with the glowing effect is on-screen. |
|
| invert | Inverts the colours of the screen. Used when spectating an Minecraft:enderman. |
|
| spider | Renders a blurred version of the screen with 5 additional copies overlapped on top with blurred edges. Used when spectating a spider. |
|
| 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!". |
|
Render process
General game rendering
Each frame is rendered in the following orderTemplate:Info 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_guifield 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, orprofiledata components
Vanilla uniform blocks
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. Template:INUpcoming this excludes lightmap, animate_sprite_interpolate and animate_sprite_blit.
- (ivec3)
CameraBlockPosBlock position of the camera in world-space coordinates. - (vec3)
CameraOffsetFractional position of the camera in world-space coordinates. - (vec2)
ScreenSizeThe width and height of the current framebuffer in pixels. - (float)
GlintAlphaThe value of the Glint Strength accessibility setting in a 0-1 range. - (float)
GameTimeA 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. Template:INUntil this is set to a constant 0 value withinanimate_sprite_interpolateandanimate_sprite_blit. - (int)
MenuBlurRadiusThe value of the Menu Background Blur accessibility setting in a 0-10 range. - (int)
UseRgssA "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)
FogColorColour of the fog. - (float)
FogEnvironmentalStartStarting distance of environmental fog. - (float)
FogEnvironmentalEndEnding distance of environmental fog. - (float)
FogRenderDistanceStartStarting distance of render distance fog. - (float)
FogRenderDistanceEndEnding distance of render distance fog. - (float)
FogSkyEndEnding distance of fog for the upper portion of the sky. - (float)
FogCloudsEndEnding distance for clouds fog.
DynamicTransforms
- (mat4)
ModelViewMatThe model-view matrix. - (vec4)
ColorModulatorA color multiplier that can be set in game code to modify the final color of objects. - (vec3)
ModelOffsetThe offset of the model being rendered. - (mat4)
TextureMatA 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_DirectionFirst light direction. Used to calculate directional entity shading. - (vec3)
Light1_DirectionSecond 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)
ProjMatThe projection matrix
LightmapInfo
- (float)
SkyFactorA value that specifies how much to brighten the lightmap by when the sky flashes, typically when a lightning strike occurs. This value comes from theminecraft:visual/sky_light_factorenvironment attribute. - (float)
BlockFactorA value that fluctuates randomly, used in the vanilla shader for block light flickering. - (float)
NightVisionFactorA value in a 0-1 range that specifies how much the Night Vision status effect should brighten the lightmap by. - (float)
DarknessScaleA value in a 0-1 range that specifies how much the Darkness status effect should darken the lightmap by. - (float)
BossOverlayWorldDarkeningFactorA 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 Template:Info needed. - (float)
BrightnessFactorThe value of the brightness video setting in a 0-1 range. - (vec3)
BlockLightTintThe color of block light. This value comes from theminecraft:visual/block_light_tintenvironment attribute. - (vec3)
SkyLightColorThe color of sky light. This value comes from theminecraft:visual/sky_light_colorenvironment attribute. - (vec3)
AmbientColorThe ambient light color. This value comes from theminecraft:visual/ambient_light_colorenvironment attribute. - (vec3)
NightVisionColorThe color of the Night Vision status effect. This value comes from theminecraft:visual/night_vision_colorenvironment attribute.
CloudInfo
- (vec4)
CloudColorThe color of the clouds. - (vec3)
CloudOffsetOffset of the clouds Template:Info needed. - (vec3)
CellSizeSize of each individual cloud Template:Info needed.
ChunkSection
- (mat4)
ModelViewMatThe model-view matrix. - (float)
ChunkVisibilityValue 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)
TextureSizeTemplate:Info needed - (ivec3)
ChunkPositionTemplate:Info needed
SpriteAnimationInfo
- (mat4)
ProjectionMatrixThe projection matrix - (mat4)
SpriteMatrixTemplate:Info needed - (float)
UPaddingTemplate:Info needed - (float)
VPaddingTemplate:Info needed - (int)
MipMapLevelTemplate:Info needed
Post-processing blocks
The following uniform blocks are only available in post-processing shaders.
SamplerInfo
- (vec2)
OutSizeThe 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,MainSizefor an input with a name of "Main"
Bedrock Edition
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
Gallery
-
The creeper vision shader
-
The enderman vision shader
-
The spider vision shader
Issues
References
Notes
External links
Template:Navbox resource packs Template:Navbox Java Edition technical
de:Shaderdaten es:Sombreador fr:Filtres ja:シェーダー pl:Shadery pt:Shader ru:Шейдеры zh:着色器