diff options
author | William Deurwaarder <william.git@xs4all.nl> | 2021-10-12 23:25:45 +0200 |
---|---|---|
committer | William Deurwaarder <william.git@xs4all.nl> | 2021-10-12 23:25:45 +0200 |
commit | fbd95c3e537f268de38f7e37672d66216b290132 (patch) | |
tree | 98d2a4f87fd88c52992ac470cc9d950c0912b89c /modules | |
parent | 6f1d2133bb2b77048bf13a8180f57bff1a747226 (diff) |
GPULightmapper: process rays to sky in all bounces as active
Before this change only rays to the sky (RAY_MISS) in the first bounce were
processed as active rays. This caused artifacts, areas were too light, when
more than one bounce were processed.
Now rays to the sky are processed as active rays for all bounces.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/lightmapper_rd/lm_compute.glsl | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl index 25b334c5eb..45b8ddab65 100644 --- a/modules/lightmapper_rd/lm_compute.glsl +++ b/modules/lightmapper_rd/lm_compute.glsl @@ -420,20 +420,22 @@ void main() { light = textureLod(sampler2DArray(source_light, linear_sampler), uvw, 0.0).rgb; active_rays += 1.0; - } else if (trace_result == RAY_MISS && params.env_transform[0][3] == 0.0) { // Use env_transform[0][3] to indicate when we are computing the first bounce - // Did not hit a triangle, reach out for the sky - vec3 sky_dir = normalize(mat3(params.env_transform) * ray_dir); + } else if (trace_result == RAY_MISS) { + if (params.env_transform[0][3] == 0.0) { // Use env_transform[0][3] to indicate when we are computing the first bounce + // Did not hit a triangle, reach out for the sky + vec3 sky_dir = normalize(mat3(params.env_transform) * ray_dir); - vec2 st = vec2( - atan(sky_dir.x, sky_dir.z), - acos(sky_dir.y)); + vec2 st = vec2( + atan(sky_dir.x, sky_dir.z), + acos(sky_dir.y)); - if (st.x < 0.0) - st.x += PI * 2.0; + if (st.x < 0.0) + st.x += PI * 2.0; - st /= vec2(PI * 2.0, PI); + st /= vec2(PI * 2.0, PI); - light = textureLod(sampler2D(environment, linear_sampler), st, 0.0).rgb; + light = textureLod(sampler2D(environment, linear_sampler), st, 0.0).rgb; + } active_rays += 1.0; } |