Skip to content

veka0/mcbe-shader-codebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 

Repository files navigation

Overview

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.

Branches

Different editions are divided into separate branches

  • main - release versions
  • preview - preview versions

Reconstructed BGFX SC code

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, therefore mul() 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)));
}

Accuracy

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.

About

Latest vanilla RenderDragon GLSL and BGFX SC Bedrock shader code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published