This repository contains vanilla Minecraft: Bedrock Edition GLSL and BGFX SC shaders.
Shader code is auto-generated with lazurite using material.bin files extracted from Android MCBE version.
Different editions are divided into separate branches
main
- release versionspreview
- preview versions
BGFX SC code is generated by further processing GLSL.
// Attention!
comment is inserted into places where a potential manual editing is required. Currently, it might indicate:
- Potential matrix multiplication (needs to be replaced with
mul()
. Note that vec*vec in GLSL is component-wise, while mul(vec, vec) in HLSL returns a dot product, thereforemul()
cannot be used for multiplying 2 vectors). - Matrix element access (index row-column order needs to be inverted for platforms other than GLSL. Note that [x][y] syntax could also be used for accessing component of a vector array, in which case inverting indices is not needed).
For example, the following code:
vec4 jitterVertexPosition(vec3 worldPosition) {
mat4 offsetProj = Proj;
offsetProj[2][0] += SubPixelOffset.x; // Attention!
offsetProj[2][1] -= SubPixelOffset.y; // Attention!
return ((offsetProj) * (((View) * (vec4(worldPosition, 1.0f))))); // Attention!
}
Should be edited into this:
vec4 jitterVertexPosition(vec3 worldPosition) {
mat4 offsetProj = Proj;
#if BGFX_SHADER_LANGUAGE_GLSL
offsetProj[2][0] += SubPixelOffset.x;
offsetProj[2][1] -= SubPixelOffset.y;
#else
offsetProj[0][2] += SubPixelOffset.x;
offsetProj[1][2] -= SubPixelOffset.y;
#endif
return mul(offsetProj, mul(View, vec4(worldPosition, 1.0f)));
}
Generated code is usually accurate, however sometimes the tool is unable to generate exact macro condition, in that case it will use the best approximation it could find and insert a comment just before macro condition, which will look like this:
// Approximation, matches 44 cases out of 48
#if defined(SEASONS__ON) && !defined(DEPTH_ONLY_OPAQUE_PASS) && !defined(DEPTH_ONLY_PASS) && !defined(TRANSPARENT_PBR_PASS)
vec3 vec3_splat(float _x) { return vec3(_x, _x, _x); }
#endif
which means the following macro condition is accurate for 44 shader variants out of the total 48 available in material.bin file.