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
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-07 15:24:58 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-07 15:25:28 +0300
commit13944c3dda75089bce9fd9fbbaffcb0b418b6393 (patch)
treecf3aa02cca2c3017a36c6665902b163d5e05133a /source
parent84ad9b102e708da54188752bde34daba8b6611b2 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl6
1 files changed, 4 insertions, 2 deletions
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