Shaders

Shaders are used to define the game's rendering of certain elements.
== Java Edition ==
Two distinct kinds of shaders exist: core shaders and post-processing shaders.
Core shaders are used to render fundamental parts of the game.
Post-processing shaders are used for certain minor visual effects:
* Certain mob vision types as seen in the Spectator gamemode
* The Fabulous! graphics setting's fixed handling of translucent objects
* The glowing status effect
Shaders are written in the OpenGL Shading Language (GLSL). Each single render program comes in two parts, "vertex" and "fragment"; vertex shaders modify the positions of individual vertices, whereas fragment shaders are applied to every pixel. 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.
Shaders are stored in the assets/minecraft/shaders/ directory of minecraft.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 responsible for rendering parts of the game. They are used to render not only blocks and entities when playing the game, but also menu and inventory screens.
Each core shader is a single render program defined by a JSON file, in which vertex and fragment shader files are specified.
Core shaders are stored in the assets/minecraft/shaders/core directory of minecraft.jar.
==== 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, with images highlighting each element in red:
==== Non-rendertype ====
Name 	Used for 	Sample Images
blit_screen 	Blit copies one buffer to another, however this cannot be overridden in a resource pack.	
particle 	All particles. 	
position 	
* Top sky and stars in the overworld
* Dark fog when the player is in the void
* The highlight color when selecting a world.	
position_color 	Used for solid color-block, including:
* Sunrise and Sunset
* Chunk border
* Sleep overlay	
position_color_lightmap 	Unknown. 	
position_color_normal 	Unknown; does not seem to be referenced anywhere in code. 	
position_color_tex 	
*Suffocation overlay screen effect
*On fire overlay 	
position_color_tex_lightmap	Unknown. 	
position_tex 	Used to render a texture:
*The sun and the moon
*World border
*Underwater screen effect
*Spyglass texture overlay
*Carved pumpkin overlay
*Powder snow freezing overlay
*Portal overlay
*Darkness and world border vignette effects
*Distortion effect overlay for nausea effect when "Distortion Effects" less than 100%
*Hotbar
*Crosshair
*Bossbar overlay
*Health bar, Armor bar, Hunger bar, Oxygen bar, Jump bar, Experience bar
*Effect icons
*Normal GUIs
*Button in GUI
*Game logo and Mojang logo	
position_tex_color 	
*Skybox with the dimension effect.
*Dirt background of GUIs
*The panorama view in the title screen	
position_tex_color_normal 	Clouds. 	
position_tex_lightmap_color	Unknown. 	
==== Rendertype ====
; Blocks
Name 	Description 	Sample Image
rendertype_beacon_beam 	The beam of the beacon and end gateway. 	
rendertype_crumbling 	The block cracks when mining a block. 	
rendertype_cutout 	All blocks with partially transparent textures (with the exception of those listed in rendertype_cutout_mipped and rendertype_translucent)	
rendertype_cutout_mipped 	Some blocks: grass blocks, iron bars, glass panes, tripwire hooks, hoppers, chains (leaves when using fancy or fabulous graphics) 	
rendertype_end_gateway 	The inside of an end gateway, reuses the same shader as . 	
rendertype_end_portal 	The inside of an end portal, as well as the insides of end gateways. 	
rendertype_solid 	All solid blocks, lava, and when in fast mode, leaves. 	
rendertype_translucent 	Translucent blocks: water (still and flowing), ice, nether portal, stained and tinted glass, slime and honey, bubbles. 	
rendertype_translucent_moving_block	Blocks that are translucent and are being moved by a piston. The one below is stained glass. 	
rendertype_translucent_no_crumbling	Unknown. 	
rendertype_tripwire 	Tripwire (sections connected to tripwire hooks are instead rendered completely solid 	
rendertype_water_mask 	Used to mask out water surface inside a boat to to prevent it from appearing flooded. 	
;Entities
Name 	Desciption 	Sample Image
rendertype_armor_cutout_no_cull 	Armor and armor trims on entities. 	
rendertype_armor_entity_glint 	Enchantment glint on equipped armor. 	
rendertype_armor_glint 	Unknown. 	
rendertype_energy_swirl 	Charged Creeper swirling outline and Wither armor. 	
rendertype_entity_alpha 	Ender Dragon death disintegration effect. 	
rendertype_entity_cutout 	Items in the inventory, head (e.g. of armor stands) hand that are blocks (not flat textures)? Doesn’t seem to work with shulker boxes. 	
rendertype_entity_cutout_no_cull 	All entities and guardian beams. 	
rendertype_entity_cutout_no_cull_z_offset	Skulls on entities and as an item. 	
rendertype_entity_decal 	Dying Ender Dragon. 	
rendertype_entity_glint 	Unknown. 	
rendertype_entity_glint_direct 	Enchantment glint on trident model. 	
rendertype_entity_no_outline 	Banner patterns (banners and shields). 	
rendertype_entity_shadow 	The blocks that are affected by an entity's shadow, but not the shadow itself. 	
rendertype_entity_smooth_cutout 	End crystal beams. 	
rendertype_entity_solid 	Certain entities or entity-style objects: banners, shulker heads, books on lecterns/enchantment tables, shields, beds, bell part of bells, capes, shells of conduits, paintings, tridents, the ears on the Deadmau5 skin.
With item frames, the item frame entity itself is part of the shader, however items on it are not. Only non-filled in parts of maps placed on an item frame where the underlying frame is exposed are part of the shader.
Also includes the first person bottom skin layer.	
rendertype_entity_translucent 	Translucent entities and parts of entities: slimes, players (all layers) along with player heads with custom skins on them, markings on horses, shulker bullets, piglins, zombified piglins, elder guardian particle effect.	
rendertype_entity_translucent_cull 	
*Flat texture items (in world and inventory).
*Translucent blocks in the inventory.
*Totem of Undying use animation. 	
rendertype_entity_translucent_emissive 	Glowing parts of Warden texture. 	
rendertype_eyes 	A shader for the entire body of an entity that has glowing eyes (not the eyes themselves). This is not fully opaque. 	
rendertype_item_entity_translucent_cull 	Handles dropped translucent items in Fabulous graphics. Also affects invisible entities while using spectator mode or the gamerule seeFriendlyInvisibles, as well as experience orbs in all graphics settings. 	
rendertype_leash 	A leash on an entity. Applies when on a fence too. 	
rendertype_outline 	Glowing effect on entities. This buffer draws the already-outlined and semi-transparent glowing, not covering the entire entity like pre-snapshot. 	
;Miscellaneous
Name 	Description 	Sample Image	
rendertype_glint 	Enchanted glint for items. used only when graphics settings are below fabulous if the item is seen in-world (not in inventory or hand from first person) and either a stained glass pane or a non fully transparent block like honey, ice, slime or any glass block	 	
rendertype_glint_direct 	Enchanted glint for items. used when the item is in inventory, in hand in first person or the item is opaque(see or for list of all blocks that are not considered opaque as of version 1.17.1) 	 	
rendertype_glint_translucent 	Enchanted glint for items. used only when graphics settings are on fabulous if the item is seen in-world (not in inventory or hand from first person) and either a stained glass pane or a non fully transparent block like honey, ice, slime or any glass block 	 	
rendertype_gui 	
* Mojang Studios loading screen bar
* Text background
* Text box in UI
* Black background on UI elements
* Inventory tooltips 	 	
rendertype_gui_ghost_recipe_overlay 	The "ghost items" that appear when clicking on a recipe in the recipe book without the required materials. 	 	
rendertype_gui_overlay 	
* Mojang Studios loading screen background
* Item durability bars
* Item cooldown animation
* Hovering over item slots
* Black background of spyglass overlay
* Fade effect in the columns of the resource pack menu 	 	
rendertype_gui_text_highlight 	Highlighting text 	 	
rendertype_lightning 	Lightning bolts, Ender Dragon death beams 	 	
rendertype_lines 	Outline when hovering over a block, Fishing rod line, Debug crosshair, Hitboxes 	 	
rendertype_text 	All parts of text, including the shadow. This encompasses all text rendered including: F3 Menu, Menu button text, Entity names, Item names, descriptions & amounts in the inventory and the Chat etc.
Also includes the filled in parts of maps placed in item frames and the entirety of non-empty map items held in hand.	 	
rendertype_text_background 	The background of text_display entities when 'see-through' is set to false. 	 	
rendertype_text_background_see_through	The background of text_display entities when 'see-through' is set to true. 	 	
rendertype_text_intensity 	TTF fonts in resource packs. 	 	
rendertype_text_intensity_see_through 	TTF fonts in resource packs on text_display entities when 'see-through' is set to true. 	 	
rendertype_text_see_through 	The background nameplate of an entity’s custom name. 	 	
=== Include shaders ===
Include shaders should be invoked by other shader files; they are not standalone shader programs. 
Include shaders contain commonly used helper functions. To import a glsl file in a shader, use #moj_import <FILENAME.glsl> or #moj_import "FILENAME.glsl". The imported file needs to end with an empty line, otherwise the shader does not load.
Include shaders are stored in the assets/minecraft/shaders/include directory of minecraft.jar.
Name 	Description
fog 	Contains the linear_fog function to calculate the color based on the vertex distance.
light 	Contains the minecraft_mix_light function.
matrix 	Contains the mat2_rotate_z function that returns the rotation matrix for a vec2 around the z-axis.
projection	Contains the projection_from_position function.
=== Post-processing shaders ===
As mentioned previously, post-processing shaders are used for special Spectator mode mob vision types, the Fabulous! graphics setting, and for rendering the outline associated with Glowing.
Post-processing shaders use "post" files to define a pipeline made up of applying a sequence of "programs". Each "program" is then defined by another JSON file, in which a single render program is defined.
"post" files are stored in the assets/minecraft/shaders/post directory of the jar file, while "program" files are stored in assets/minecraft/shaders/program.
Only five post-processing shaders are currently used in the game:
* creeper.json: Used when spectating a creeper
* invert.json: Used when spectating an enderman
* spider.json: Used when spectating a spider
* entity_outline.json: Used when a glowing entity is on screen
* transparency.json: Used when in "Fabulous!" graphics mode.
In these two directories, there are also many unused shaders, which were used for "Super Secret Settings" before 1.9 (15w31a). See Shaders/Before 1.9.
=== Render process ===
=== File format ===
==== Render program ====
* The root tag
**: Settings for OpenGL blending.
*** : Operator to be used when blending. Can be add, subtract, reversesubtract, reverse_subtract, min, or max. Not case sensitive. Defaults to add. Used as mode parameter of glBlendEquation
*** : Used as sfactor parameter of glBlendFunc or srcRGB parameter of glBlendFuncSeparate. Can be 0, 1, srccolor, 1-srccolor, dstcolor, 1-dstcolor, srcalpha, 1-srcalpha, dstalpha, or1-dstalpha. Case insensitive. Ignores "_". "1", "0", "-" can be replaced by "one", "zero", "minus".
*** : Used as dfactor parameter of glBlendFunc or dstRGB parameter of glBlendFuncSeparate. Can be 0, 1, srccolor, 1-srccolor, dstcolor, 1-dstcolor, srcalpha, 1-srcalpha, dstalpha, or1-dstalpha. Case insensitive. Ignores "_". "1", "0", "-" can be replaced by "one", "zero", "minus".
*** : Used as srcalpha parameter of glBlendFuncSeparate. Can be 0, 1, srccolor, 1-srccolor, dstcolor, 1-dstcolor, srcalpha, 1-srcalpha, dstalpha, or1-dstalpha. Case insensitive. Ignores "_". "1", "0", "-" can be replaced by "one", "zero", "minus".
*** : Used as dstalpha parameter of glBlendFuncSeparate. Can be 0, 1, srccolor, 1-srccolor, dstcolor, 1-dstcolor, srcalpha, 1-srcalpha, dstalpha, or1-dstalpha. Case insensitive. Ignores "_". "1", "0", "-" can be replaced by "one", "zero", "minus".
** : If true, run glEnable(GL_CULL_FACE). If false, run glDisable(GL_CULL_FACE). Defaults to true.
** : The name (without file extension) of the vertex shader to be used.
** : The name (without file extension) of the fragment shader to be used.
** : Attributes to be used by the vertex shader.
*** : An attribute. Available values are hard-coded.
** : A list of samplers that may be used in the shaders.
*** : A sampler.
**** : The samplers name.
** : A list of uniforms that can be used in the shaders.
***: A uniform.
****: The name of the uniform as referenced in the GLSL code. Some names give a uniform special behavior(Note that these following special uniform does not work in all shader programs):
*****(float) Time: A value from 0 to 1, representing time in seconds. Resets every second. Valid only in post-processing shaders.
*****(vec2) InSize: The width and height of the input buffer in pixels. Valid only in post-processing shaders.
*****(vec2) OutSize: The width and height of the output buffer in pixels. Valid only in post-processing shaders.
*****(vec2) AuxSize: The width and height of the auxiliary buffer in pixels. should be replaced by the order of the auxtarget in the render pass. Valid only in post-processing shaders.
*****(matrix4x4) ModelViewMat: The model-view matrix. Valid only in core shaders.
*****(matrix4x4) ProjMat: The projection matrix.
*****(matrix4x4) TextureMat: 4D matrix used to transform UV's for item glint effects. Valid only in core shaders.
*****(vec2) ScreenSize: vec2 containing the current framebuffer width and height, in that order.
*****(vec4) ColorModulator: A global vec4 of multipliers that can be set from the game code as a color multiplier. Valid only in core shaders.
*****(vec3) Light0_Direction: First light direction as vec3 for entity rendering. Valid only in core shaders.
*****(vec3) Light1_Direction: Second light direction, see Light0_Direction. Valid only in core shaders.
*****(float) FogStart: Fog start distance from the camera. Valid only in core shaders.
*****(float) FogEnd: Fog end distance from the camera. Valid only in core shaders.
*****(vec4) FogColor: vec4 fog color. Valid only in core shaders.
*****(float) LineWidth: Line width, used for rendering wireframe lines such as the block selection frame and debug hitboxes. Valid only in core shaders.
*****(float) GameTime: Global time of the world, in fractional days. Valid only in core shaders.
*****(vec3) ChunkOffset: When rendering a chunk section, the offset from the camera world position to the chunk section's base point. Valid only in core shaders.
**** : The type of the uniform. Can be one of int, float, matrix4x4, matrix3x3 and matrix2x2. int can also be interpreted as ivec2, ivec3 or ivec4 depending on how many values are actually included in values. float can also be interpreted as vec2, vec3 or vec4 depending on how many values are actually included in values.
**** : The number of values included in values.
**** : The value of the uniform, given as a list of floats. The length of the list should be the same as count.
==== Render pipeline ====
Here's the process of how a post-processing shader is used in game: first, the shader initializes all of the render targets specified in the "targets" list with the proper width and height. After that, the shader goes through each render pass specified in the "passes" list from first in the list to last in the list. Each pass applies the program shader on the render target specified by "intarget" (with any extra data provided by other auxiliary render targets) and output the end result on the render target specified by "outtarget".
* The root tag
** : A list of render targets. They can be buffer provided by the game, or new buffer with any name.
*** : The name of a render target. The size defaults to screen resolution. Post-processing shader transparency must contain render targets named translucent, itemEntity, particles, weather and clouds. Post-processing shader entity_outline must contain a render target named final.
*** : A render target to add.
**** : The name of the render target to add.
**** : The width of the render target.
**** : The height of the render target.
** : A list of passes.
*** : A render pass.
**** : The name of a program shader to apply on the input and post into the output. Use "blit" to copy the data from intarget to outtarget.
**** : The name of a render target to use as an input. Use minecraft:main to specify the main screen.
**** : The name of a render target to output to. It should not be the same as intarget. Use minecraft:main to specify the main screen.
**** : A list of auxiliary targets.
***** An auxiliary target.
****** : The auxiliary target's name that is passed into the "Program" JSON.
****** : The auxiliary target's id. Either points into the name of a buffer that is defined in targets or into the location of a texture under assets/<namespace>/textures/effect (use a resource location to reference it). Append :depth after the name of the buffer to access its depth buffer. For example, to access the depth buffer of minecraft:main, use minecraft:main:depth.
****** : Required if id references a texture. Describes the width of the texture in pixels.
****** : Required if id references a texture. Describes the height of the texture in pixels.
****** : Required if id references a texture. Determines whether the scaling algorithm used for the image is bilinear or nearest neighbor.
**** : A list of overrides that change the values in the uniforms list in the "Program" JSON.
***** : A uniform.
****** : The name of the field that should be changed.
****** : The values that the field should be changed to.
=== Tutorials and useful docs ===
Here are some guides with additional information on creating shaders:
* Minecraft Vanilla Shaders Guide
*Vanilla Shaders Wiki
== Bedrock Edition ==
Since Bedrock Edition 1.18.30, third party shader resource packs are no longer supported on all devices except Fire OS.
== History ==
==Gallery==
SpiderVision.png|The spider vision shader
CreeperVision.png|The creeper vision shader
== Issues ==
== References ==
de:Shaders
es:Filtros
fr:Filtres
pl:Shadery
pt:Shaders
ru:Шейдеры
zh:着色器
Category:Gameplay