Skip to content

Commit

Permalink
A little less lit
Browse files Browse the repository at this point in the history
- Fix normalizing constant in light_lut.glsl to make shader light
  slightly darker and consistent with chunk lighting
  • Loading branch information
Jozufozu committed Nov 12, 2024
1 parent 671d47a commit 6709682
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const float _FLW_EPSILON = 1e-5;
const uint _FLW_LOWER_10_BITS = 0x3FFu;
const uint _FLW_UPPER_10_BITS = 0xFFF00000u;

const float _FLW_LIGHT_NORMALIZER = 1. / 16.;

uint _flw_indexLut(uint index);

uint _flw_indexLight(uint index);
Expand Down Expand Up @@ -98,7 +100,7 @@ bool flw_lightFetch(ivec3 blockPos, out vec2 lightCoord) {

uvec3 blockInSectionPos = (blockPos & 0xF) + 1;

lightCoord = vec2(_flw_lightAt(sectionOffset, blockInSectionPos)) / 15.;
lightCoord = vec2(_flw_lightAt(sectionOffset, blockInSectionPos)) * _FLW_LIGHT_NORMALIZER;
return true;
}

Expand Down Expand Up @@ -298,7 +300,7 @@ vec3 _flw_lightForDirection(uint[27] lights, vec3 interpolant, uint c00, uint c0
vec3 light = mix(light0, light1, interpolant.y);

// Normalize the light coords
light.xy *= 1. / 15.;
light.xy *= _FLW_LIGHT_NORMALIZER;
// Calculate the AO multiplier from the number of valid blocks
light.z = _flw_validCountToAo(light.z);

Expand Down Expand Up @@ -351,7 +353,7 @@ bool flw_light(vec3 worldPos, vec3 normal, out FlwLightAo light) {
vec2 light0 = mix(light00, light01, interpolant.y);
vec2 light1 = mix(light10, light11, interpolant.y);

light.light = mix(light0, light1, interpolant.x) / 15.;
light.light = mix(light0, light1, interpolant.x) * _FLW_LIGHT_NORMALIZER;
light.ao = 1.;

// Lighting and AO accurate to chunk baking
Expand Down Expand Up @@ -410,7 +412,7 @@ bool flw_light(vec3 worldPos, vec3 normal, out FlwLightAo light) {
// Entirely flat lighting, the lowest setting and a fallback in case an invalid option is set
#else

light.light = vec2(_flw_lightAt(sectionOffset, blockInSectionPos)) / 15.;
light.light = vec2(_flw_lightAt(sectionOffset, blockInSectionPos)) * _FLW_LIGHT_NORMALIZER;
light.ao = 1.;

#endif
Expand Down

0 comments on commit 6709682

Please sign in to comment.