diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-07-03 23:08:07 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-07-03 23:08:33 +0300 |
commit | b09052002c3bc9ffcf60dd8e2efe0374ca6e550f (patch) | |
tree | 3a4b1d3c9f103b246502b3ad464a5a8a7eed6089 /source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl | |
parent | 2eef097831caf14634cc0fc6749b857096baf3da (diff) |
Eevee: Add support for volumetrics in node tree.
Only volume scatter is implemented for now.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl index 8e7393a2f58..fe80fed232f 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl @@ -1,34 +1,17 @@ out vec4 FragColor; -#ifdef STEP_INTEGRATE +#ifdef VOLUMETRICS uniform sampler2D depthFull; -float find_next_step(float near, float far, float noise, int iter, int iter_count) -{ - const float lambda = 0.8f; /* TODO : Parameter */ - - float progress = (float(iter) + noise) / float(iter_count); - - float linear_split = mix(near, far, progress); - - if (ProjectionMatrix[3][3] == 0.0) { - float exp_split = near * pow(far / near, progress); - return mix(linear_split, exp_split, lambda); - } - else { - return linear_split; - } -} - void participating_media_properties(vec3 wpos, out vec3 absorption, out vec3 scattering, out float anisotropy) { - /* TODO Call nodetree from here. */ - absorption = vec3(0.00); - scattering = vec3(1.0) * step(-1.0, -wpos.z); + Closure cl = nodetree_exec(); - anisotropy = -0.8; + absorption = cl.absorption; + scattering = cl.scatter; + anisotropy = cl.anisotropy; } float phase_function_isotropic() @@ -38,7 +21,7 @@ float phase_function_isotropic() float phase_function(vec3 v, vec3 l, float g) { -#if 0 +#if 1 /* Henyey-Greenstein */ float cos_theta = dot(v, l); float sqr_g = g * g; @@ -54,6 +37,23 @@ vec3 light_volume(LightData ld, vec4 l_vector, vec3 l_col) return l_col * (4.0 * ld.l_radius * ld.l_radius * M_PI * M_PI) / (dist * dist); } +float find_next_step(float near, float far, float noise, int iter, int iter_count) +{ + const float lambda = 0.8f; /* TODO : Parameter */ + + float progress = (float(iter) + noise) / float(iter_count); + + float linear_split = mix(near, far, progress); + + if (ProjectionMatrix[3][3] == 0.0) { + float exp_split = near * pow(far / near, progress); + return mix(linear_split, exp_split, lambda); + } + else { + return linear_split; + } +} + /* Based on Frosbite Unified Volumetric. * https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */ void main() |