Skip to content

Rendering Uniforms

These uniforms store information related to rendering, such as near/far planes, chunk offsets, fog parameters, and more.

near

uniform float near;

The near clipping plane distance. Unless changed by a mod, this is equal to 0.05.


far

uniform float far;

The current render distance in blocks. Despite the name, this is not the far clipping plane distance, in fact that value is roughly four times far.


alphaTestRef

uniform float alphaTestRef;

This value stores the alpha value that Iris recommends you discard pixels bellow. This value is commonly 0.1, but can change in certain cases (therefore it is recommended to use the uniform over a hardcoded value). The value is also affected by the alphaTest directive. It is normally used like this:

if (albedoOut.a < alphaTestRef) discard;

chunkOffset

uniform vec3 chunkOffset;

The chunk offset in model space for the currently rendering chunk of terrain. Used in combination with vaPosition to get the model space position as follows:

vec3 model_pos = vaPosition + chunkOffset;

The value of chunkOffset is all 0s when not rendering terrain, or when using the compatibility profile.


entityColor

uniform vec4 entityColor;

The entity tint color. The rgb components store the color, and the a component stores the blend factor. The entity color should be applied as follows:

color.rgb = mix(color.rgb, entityColor.rgb, entityColor.a);

blendFunc

uniform ivec4 blendFunc;

The alpha blending function multipliers for the current program, as described in blend.<program>. The components of the vector store the following:

  • x: source RGB
  • y: destination RGB
  • z: source Alpha
  • w: destination Alpha

The value stored in each component is one of the following hardcoded integer values (see LWJGL docs):

Blend ValueInteger Value
GL_ZERO0
GL_ONE1
GL_SRC_COLOR768
GL_ONE_MINUS_SRC_COLOR769
GL_SRC_ALPHA770
GL_ONE_MINUS_SRC_ALPHA771
GL_DST_ALPHA772
GL_ONE_MINUS_DST_ALPHA773
GL_DST_COLOR774
GL_ONE_MINUS_DST_COLOR775
GL_SRC_ALPHA_SATURATE776

atlasSize

uniform ivec2 atlasSize;

This value stores the size of the texture atlas. It only stores a value when the texture atlas is bound, and will return 0 when not.


renderStage

uniform int renderStage;

This uniform stores the “render stage” of the current geometry. This can be used to identify what type of geometry is being rendered in more detail than the gbuffer program it’s running in. The uniform value is intended to be compared to one of the render stage preprocessor macros which are defined by Iris.


fogColor

uniform vec3 fogColor;

The horizon fog color used by the vanilla game for sky rendering and fog. It can be dependent on biome, time of day, and viewing angle.


skyColor

uniform vec3 skyColor;

The upper sky color used by the vanilla game for sky rendering. It can be dependent on biome, time of day, but not viewing angle.


fogDensity

uniform float fogDensity;

This uniform stores the relative fog density used for vanilla fog, based on the current biome, weather, water/lava/packed snow, etc. The value ranges from 0.0 (lowest density) to 1.0 (highest density).


fogStart

uniform float fogStart;

This uniform stores the starting distance in blocks used for vanilla fog, based on the current biome, weather, water/lava/packed snow, etc.


fogEnd

uniform float fogEnd;

This uniform stores the ending distance in blocks used for vanilla fog, based on the current biome, weather, water/lava/packed snow, etc.


fogMode

uniform int fogMode;

This uniform stores the fog type used for vanilla fog, based on the current biome, weather, water/lava/packed snow, etc. This is the function used to determine the strength of fog based on distance.

The value stored in each component is one of the following hardcoded integer values (see LWJGL docs):

  • GL_EXP: 2048
  • GL_EXP2 : 2049
  • GL_LINEAR: 9729

fogShape

uniform int fogShape;

This uniform encodes the fog shape used for vanilla fog, based on the current biome, weather, water/lava/packed snow, caves, etc. The following values are possible:

  • 0: sphere
  • 1: cylinder