[Bf-blender-cvs] [13944c3dda7] blender2.8: Workbench: Scale shadowing based on density

Clément Foucault noreply at git.blender.org
Wed Nov 7 13:25:36 CET 2018


Commit: 13944c3dda75089bce9fd9fbbaffcb0b418b6393
Author: Clément Foucault
Date:   Wed Nov 7 13:24:58 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB13944c3dda75089bce9fd9fbbaffcb0b418b6393

Workbench: Scale shadowing based on density

This makes previewing thick smoke a bit more plausible with better shadows.

The shadowing is clamped so that nothing is completely black. That said the
lower bound is pretty low.

This is not an option but could become one if users do not like it in
all situations.

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

M	source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl

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

diff --git a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
index f14078a71eb..0bb6af40647 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
@@ -135,10 +135,12 @@ void volume_properties(vec3 ls_pos, out vec3 scattering, out float extinction)
 	float shadows = sample_volume_texture(shadowTexture, co).r;
 	vec4 density = sample_volume_texture(densityTexture, co); /* rgb: color, a: density */
 
-	scattering = density.rgb * density.a * densityScale;
+	scattering = density.rgb * (density.a * densityScale);
 	extinction = max(1e-4, dot(scattering, vec3(0.33333)));
 
-	scattering *= shadows * M_PI;
+	/* Scale shadows in log space and clamp them to avoid completely black shadows. */
+	scattering *= exp(clamp(log(shadows) * densityScale * 0.1, -2.5, 0.0)) * M_PI;
+
 	/* 800 is arbitrary and here to mimic old viewport. TODO make it a parameter */
 	scattering += pow(emission.rgb, vec3(2.2)) * emission.a * 800.0;
 #endif



More information about the Bf-blender-cvs mailing list