Uniforms¶
General uniforms¶
Source |
Value |
---|---|
|
held item ID (main hand), used only for items defined in |
|
held item light value (main hand) |
|
held item ID (off hand), used only for items defined in |
|
held item light value (off hand) |
|
GL_LINEAR, GL_EXP or GL_EXP2 |
|
0.0-1.0 |
|
r, g, b |
|
r, g, b |
|
<ticks> = worldTicks % 24000 |
|
<days> = worldTicks / 24000 |
|
0-7 |
|
Frame index (0 to 720719, then resets to 0) |
|
last frame time, seconds |
|
run time, seconds (resets to 0 after 3600s) |
|
0.0-1.0 |
|
0.0-1.0 |
|
0.0-1.0 |
|
viewWidth / viewHeight |
|
viewWidth |
|
viewHeight |
|
near viewing plane distance |
|
far viewing plane distance |
|
sun position in eye space |
|
moon position in eye space |
|
shadow light (sun or moon) position in eye space |
|
direction up |
|
camera position in world space |
|
last frame cameraPosition |
|
modelview matrix after setting up the camera transformations |
|
inverse gbufferModelView |
|
last frame gbufferModelView |
|
projection matrix when the gbuffers were generated |
|
inverse gbufferProjection |
|
last frame gbufferProjection |
|
projection matrix when the shadow map was generated |
|
inverse shadowProjection |
|
modelview matrix when the shadow map was generated |
|
inverse shadowModelView |
|
rainStrength smoothed with wetnessHalfLife or drynessHalfLife |
|
view entity Y position |
|
x = block brightness, y = sky brightness, light 0-15 = brightness 0-240 |
|
eyeBrightness smoothed with eyeBrightnessHalflife |
|
not used |
|
not used |
|
1 = camera is in water, 2 = camera is in lava, 3 = camera is in powdered snow |
|
night vision (0.0-1.0) |
|
blindness (0.0-1.0) |
|
screen brightness (0.0-1.0) |
|
GUI is hidden |
|
centerDepth smoothed with centerDepthSmoothHalflife |
|
texture atlas size (only set when the atlas texture is bound) |
|
sprite bounds in the texture atlas (u0, v0, u1, v1), set when MC_ANISOTROPIC_FILTERING is enabled |
|
entity color multiplier (entity hurt, creeper flashing when exploding) |
|
entity ID |
|
block entity ID (block ID for the tile entity, only for blocks specified in |
|
blend function (srcRGB, dstRGB, srcAlpha, dstAlpha) |
|
instance ID when instancing is enabled (countInstances > 1), 0 = original, 1-N = copies |
|
player mood (0.0-1.0), increases the longer a player stays underground |
|
render stage, see Macros, J. Render stages |
1.17+ Options Below |
|
|
model view matrix |
|
modelViewMatrixInverse |
|
projectionMatrix |
|
projectionMatrixInverse |
|
textureMatrix = mat4(1.0) |
|
normal matrix |
|
terrain chunk origin, used with attribute |
|
alpha test reference value, the check is |
|
strength of the darkness effect (0.0-1.0) |
|
lightmap variations caused by the darkness effect (0.0-1.0) |
GBuffers uniforms¶
Note
Programs: basic, textured, textured_lit, skybasic, skytextured, clouds, terrain, terrain_solid, terrain_cutout_mip, terrain_cutout, damagedblock, water, block, beaconbeam, item, entities, armor_glint, spidereyes, hand, hand_water, weather
Source |
Value |
---|---|
|
0 |
|
1 |
|
|
|
3 |
|
waterShadowEnabled ? 5 : 4 |
|
4 |
|
4 |
|
5 |
|
6 |
|
7 <custom texture or output from deferred programs> |
|
8 <custom texture or output from deferred programs> |
|
9 <custom texture or output from deferred programs> |
|
10 <custom texture or output from deferred programs> |
|
7 <custom texture or output from deferred programs> |
|
8 <custom texture or output from deferred programs> |
|
9 <custom texture or output from deferred programs> |
|
10 <custom texture or output from deferred programs> |
|
16 <custom texture or output from deferred programs> |
|
17 <custom texture or output from deferred programs> |
|
18 <custom texture or output from deferred programs> |
|
19 <custom texture or output from deferred programs> |
|
20 <custom texture or output from deferred programs> |
|
21 <custom texture or output from deferred programs> |
|
22 <custom texture or output from deferred programs> |
|
23 <custom texture or output from deferred programs> |
|
11 |
|
13 |
|
13 |
|
14 |
|
15 |
Shadow uniforms¶
Note
Programs: shadow, shadow_solid, shadow_cutout
Source |
Value |
---|---|
|
0 |
|
0 |
|
1 |
|
|
|
3 |
|
Is waterShadowEnabled true? Yes: 5, no: 4 |
|
4 |
|
4 |
|
5 |
|
7 <custom texture> |
|
8 <custom texture> |
|
9 <custom texture> |
|
10 <custom texture> |
|
7 <custom texture> |
|
8 <custom texture> |
|
9 <custom texture> |
|
10 <custom texture> |
|
16 <custom texture> |
|
17 <custom texture> |
|
18 <custom texture> |
|
19 <custom texture> |
|
20 <custom texture> |
|
21 <custom texture> |
|
22 <custom texture> |
|
23 <custom texture> |
|
13 |
|
13 |
|
14 |
|
15 |
Composite and deferred uniforms¶
Note
Programs: composite, composite1, composite2, composite3, composite4, composite5, composite6, composite7, final, deferred, deferred1, deferred2, deferred3, deferred4, deferred5, deferred6, deferred7
Source |
Value |
---|---|
|
0 |
|
1 |
|
2 |
|
3 |
|
7 |
|
8 |
|
9 |
|
10 |
|
0 |
|
1 |
|
2 |
|
3 |
|
7 |
|
8 |
|
9 |
|
10 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
Is waterShadowEnabled true? Yes: 5, no: 4 |
|
4 |
|
4 |
|
5 |
|
6 |
|
6 |
|
11 |
|
12 |
|
13 |
|
13 |
|
14 |
|
15 |
Custom uniforms¶
Define custom variables and uniforms using general mathematical expressions with brackets, constants, variables, operators and functions. The uniforms are sent to the shaders, the variables can be used in other variables or uniforms. The custom uniforms are updated on program change.
Important
Lightmap texture matrix, 1.17+:
const mat4 TEXTURE_MATRIX_2 = mat4(
vec4(0.00390625, 0.0, 0.0, 0.0),
vec4(0.0, 0.00390625, 0.0, 0.0),
vec4(0.0, 0.0, 0.00390625, 0.0),
vec4(0.03125, 0.03125, 0.03125, 1.0)
);
Name |
Type |
Meaning |
---|---|---|
|
Float, constant |
Floating point, |
|
Boolean, constant |
Truthy boolean |
|
Boolean, constant |
False boolean |
The available biome ids, categories and precipitation types are defines as constants.
For example: BIOME_PLAINS
, BIOME_DESERT
, BIOME_EXTREME_HILLS
, etc.
Constant |
Meaning |
---|---|
biome |
biome id |
biome_category |
0 to 16 (CAT_NONE, CAT_TAIGA, CAT_EXTREME_HILLS, CAT_JUNGLE, CAT_MESA, CAT_PLAINS, CAT_SAVANNA, CAT_ICY, CAT_THE_END, CAT_BEACH, CAT_FOREST, CAT_OCEAN, CAT_DESERT, CAT_RIVER, CAT_SWAMP, CAT_MUSHROOM, CAT_NETHER) |
biome_precipitation |
0 to 2 (PPT_NONE, PPT_RAIN, PPT_SNOW) |
temperature |
0.0 to 1.0 |
rainfall |
0.0 to 1.0 (humidity) |
Rain/snow is rendered for biome_precipitation != PPT_NONE
. If temperature >= 0.15
, rain is rendered, otherwise snow.
The fixed scalar uniforms are also available as parameters. For example: heldItemId
, worldTime
, moonPhase
, etc.
Vector elements can be accessed with suffix
.x
,.y
, and.z
. For example:sunPosition.y
Color elements can be accessed with suffix
.r
,.g
, and.b
. For example:skyColor.r
Matrix elements can be accessed by row and column index. For example:
gbufferModelView.0.1
Important
The dynamic uniforms entityColor
, entityId
, blockEntityId
, fogMode
, and fogColor
can not be used as parameters as they may change many times per program.
See also
Parameters (boolean), operators, functions are in Values.
|
Smooths a variable with custom fade-in time
| The
[id] must be unique; if not specified, it is generated automatically
| Default fade time is 1 sec |
Vector functions: |
vec2(x, y)
vec3(x, y, z)
vec4(x, y, z, w)
Example¶
variable.bool.isBiomeDark=in(biome, BIOME_RIVER, BIOME_FOREST)
variable.float.valBiomeDark=smooth(1, if(isBiomeDark, 1, 0), 5)
variable.float.valHurtDark=smooth(2, if(is_hurt, 1.3, 0), 0, 10)
variable.float.valSwordDark=smooth(3, if(heldItemId == 276, 1, 0), 0.5, 0.5)
uniform.float.screenDark=max(valBiomeDark, valHurtDark, valSwordDark)
uniform.vec3.screenDark3=vec3(screenDark, heldItemId, biome)
# More generally,
uniform.<float|int|bool|vec2|vec3|vec4>.<name>=<expression>
variable.<float|int|bool|vec2|vec3|vec4>.<name>=<expression>