Port the fixed lightmap shift to WorldContext

This commit is contained in:
JozsefA 2021-05-14 18:32:27 -07:00
parent 3856283353
commit 8efe8ed01e
3 changed files with 10 additions and 4 deletions

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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
}