diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-29 10:11:19 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-29 10:11:19 +1000 |
commit | 624c7aaaf192f2e87081a241123a8507a4718ba3 (patch) | |
tree | a54b09902da8d724f3ba740a215fd53d8a861fd9 /assets/opensb/rendering | |
parent | 9d67cda97fc327ca3c53e044a897fbfb196104c4 (diff) |
Move lighting calculation to separate thread
Diffstat (limited to 'assets/opensb/rendering')
-rw-r--r-- | assets/opensb/rendering/opengl20.config | 6 | ||||
-rw-r--r-- | assets/opensb/rendering/opengl20.frag | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/assets/opensb/rendering/opengl20.config b/assets/opensb/rendering/opengl20.config index 923578c..70ff6c7 100644 --- a/assets/opensb/rendering/opengl20.config +++ b/assets/opensb/rendering/opengl20.config @@ -28,6 +28,12 @@ "textureSizeUniform" : "lightMapSize", "textureAddressing" : "clamp", "textureFiltering" : "linear" + }, + "tileLightMap" : { + "textureUniform" : "tileLightMap", + "textureSizeUniform" : "tileLightMapSize", + "textureAddressing" : "clamp", + "textureFiltering" : "linear" } }, diff --git a/assets/opensb/rendering/opengl20.frag b/assets/opensb/rendering/opengl20.frag index 92a121f..a57c029 100644 --- a/assets/opensb/rendering/opengl20.frag +++ b/assets/opensb/rendering/opengl20.frag @@ -6,7 +6,9 @@ uniform sampler2D texture2; uniform sampler2D texture3; uniform bool lightMapEnabled; uniform vec2 lightMapSize; +uniform vec2 tileLightMapSize; uniform sampler2D lightMap; +uniform sampler2D tileLightMap; uniform float lightMapMultiplier; varying vec2 fragmentTextureCoordinate; @@ -53,6 +55,12 @@ 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); + vec4 b = bicubicSample(tileLightMap, texcoord, texscale); + return mix(a, b, b.z); +} + void main() { vec4 texColor; if (fragmentTextureIndex > 2.9) { @@ -70,6 +78,6 @@ void main() { vec4 finalColor = texColor * fragmentColor; float finalLightMapMultiplier = fragmentLightMapMultiplier * lightMapMultiplier; if (lightMapEnabled && finalLightMapMultiplier > 0.0) - finalColor.rgb *= bicubicSample(lightMap, fragmentLightMapCoordinate, 1.0 / lightMapSize).rgb * finalLightMapMultiplier; + finalColor.rgb *= sampleLightMap(fragmentLightMapCoordinate, 1.0 / lightMapSize).rgb * finalLightMapMultiplier; gl_FragColor = finalColor; }
\ No newline at end of file |