[Bf-blender-cvs] [8e126c3fa27] ui-asset-view-template: EEVEE: Fix incorrect volumetric light shadowing

Clément Foucault noreply at git.blender.org
Wed Mar 3 21:45:17 CET 2021


Commit: 8e126c3fa2708a0a5fd42f01f43709ea9706a076
Author: Clément Foucault
Date:   Tue Mar 2 16:28:16 2021 +0100
Branches: ui-asset-view-template
https://developer.blender.org/rB8e126c3fa2708a0a5fd42f01f43709ea9706a076

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.

===================================================================

M	source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl

===================================================================

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);
   }



More information about the Bf-blender-cvs mailing list