diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-04 05:26:47 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-04 05:26:47 +1000 |
commit | 1d04c689ba3e9d8bb3602a7289fe5756aa8fb3fd (patch) | |
tree | 1d8b8772645d4f2a4ff3dbe3a5048c62ca2b9cfc /assets/opensb/rendering | |
parent | ced1ba32bbabbac5f4c022434b02cb4afeff7c62 (diff) |
Blend tile lighting correctly
Diffstat (limited to 'assets/opensb/rendering')
-rw-r--r-- | assets/opensb/rendering/world.frag | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/assets/opensb/rendering/world.frag b/assets/opensb/rendering/world.frag index ed197c3..b4450ad 100644 --- a/assets/opensb/rendering/world.frag +++ b/assets/opensb/rendering/world.frag @@ -55,10 +55,14 @@ vec4 bicubicSample(sampler2D texture, vec2 texcoord, vec2 texscale) { mix(sample1, sample0, sx), sy); } -vec4 sampleLightMap(vec2 texcoord, vec2 texscale) { - vec4 a = bicubicSample(lightMap, texcoord, texscale); +vec3 sampleLightMap(vec2 texcoord, vec2 texscale) { vec4 b = bicubicSample(tileLightMap, texcoord, texscale); - return mix(a, b, b.z); + vec4 a = bicubicSample(lightMap, texcoord, texscale); + + if (b.z <= 0.0) + return a.rgb; + + return mix(a.rgb, b.rgb / b.z, b.z); } void main() { @@ -80,6 +84,6 @@ void main() { if (texColor.a == 0.99607843137) finalColor.a = fragmentColor.a; else if (lightMapEnabled && finalLightMapMultiplier > 0.0) - finalColor.rgb *= sampleLightMap(fragmentLightMapCoordinate, 1.0 / lightMapSize).rgb * finalLightMapMultiplier; + finalColor.rgb *= sampleLightMap(fragmentLightMapCoordinate, 1.0 / lightMapSize) * finalLightMapMultiplier; gl_FragColor = finalColor; }
\ No newline at end of file |