diff --git a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag index 8f43ae7f6..054697141 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/contraption/builtin.frag @@ -1,4 +1,5 @@ #flwinclude <"create:context/std/fog.glsl"> +#flwinclude <"create:core/lightutil.glsl"> varying vec3 BoxCoord; uniform sampler3D uLightVolume; @@ -23,6 +24,7 @@ void FLWFinalizeColor(vec4 color) { } vec4 FLWLight(vec2 lightCoords) { - vec2 lm = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg); - return texture2D(uLightMap, lm * 0.99609375 + 0.03125); // * 255/256 + 1/32 + lightCoords = max(lightCoords, texture3D(uLightVolume, BoxCoord).rg); + + return texture2D(uLightMap, shiftLight(lightCoords)); } diff --git a/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag b/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag index d8f079be6..8a30001a6 100644 --- a/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag +++ b/src/main/resources/assets/create/flywheel/shaders/context/std/builtin.frag @@ -1,4 +1,5 @@ #flwinclude <"create:context/std/fog.glsl"> +#flwinclude <"create:core/lightutil.glsl"> uniform sampler2D uBlockAtlas; uniform sampler2D uLightMap; @@ -20,6 +21,5 @@ void FLWFinalizeColor(vec4 color) { } vec4 FLWLight(vec2 lightCoords) { - vec2 lm = lightCoords * 0.9375 + 0.03125; - return texture2D(uLightMap, lm); + return texture2D(uLightMap, shiftLight(lightCoords)); } diff --git a/src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl b/src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl new file mode 100644 index 000000000..9967c4f51 --- /dev/null +++ b/src/main/resources/assets/create/flywheel/shaders/core/lightutil.glsl @@ -0,0 +1,4 @@ +// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap +vec2 shiftLight(vec2 lm) { + return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32 +}