Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2021-03-02 18:28:16 +0300
committerClément Foucault <foucault.clem@gmail.com>2021-03-02 20:00:02 +0300
commit3a29c19b2bffdd664981543c2f68151a6520b48b (patch)
tree98ea62a4d7c501327873fd3ec5e79f6f27b4e69b
parent3d7a00b8aa174069cf622952dbddda6201fbf653 (diff)
EEVEE: Fix incorrect volumetric light shadowing
The shadowing was computed on the light distance squared, leaking to much light since it was integrating the extinction behind the ligth itself. Also bump the maximum shadow max step to the actual UI values. Otherwise we get shadowing under evaluated because `dd` is too small.
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
index 9b852a57ec4..b1e3a40e8d2 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
@@ -98,7 +98,7 @@ vec3 light_volume(LightData ld, vec4 l_vector)
return tint * lum;
}
-#define VOLUMETRIC_SHADOW_MAX_STEP 32.0
+#define VOLUMETRIC_SHADOW_MAX_STEP 128.0
vec3 participating_media_extinction(vec3 wpos, sampler3D volume_extinction)
{
@@ -115,10 +115,10 @@ vec3 light_volume_shadow(LightData ld, vec3 ray_wpos, vec4 l_vector, sampler3D v
#if defined(VOLUME_SHADOW)
/* Heterogeneous volume shadows */
float dd = l_vector.w / volShadowSteps;
- vec3 L = l_vector.xyz * l_vector.w;
+ vec3 L = l_vector.xyz / volShadowSteps;
vec3 shadow = vec3(1.0);
- for (float s = 0.5; s < VOLUMETRIC_SHADOW_MAX_STEP && s < (volShadowSteps - 0.1); s += 1.0) {
- vec3 pos = ray_wpos + L * (s / volShadowSteps);
+ for (float s = 1.0; s < VOLUMETRIC_SHADOW_MAX_STEP && s <= volShadowSteps; s += 1.0) {
+ vec3 pos = ray_wpos + L * s;
vec3 s_extinction = participating_media_extinction(pos, volume_extinction);
shadow *= exp(-s_extinction * dd);
}