diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-11-01 20:48:55 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-11-01 20:48:55 +0300 |
commit | cf6e45b5224d16263d7c87411a2ff71ed928410f (patch) | |
tree | 328b2c4cb2df10182048d4f69e145ac8d0a9af57 /source/blender/draw | |
parent | cd7e43f29f3b80dd5959423e6ce00be7efcbaec7 (diff) |
Eevee: Fix Black volumetrics.
Was caused by a division by 0.
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl | 2 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl index 68729c6b02b..b3f5e8b60ad 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl @@ -61,7 +61,7 @@ float phase_function(vec3 v, vec3 l, float g) float cos_theta = dot(v, l); g = clamp(g, -1.0 + 1e-3, 1.0 - 1e-3); float sqr_g = g * g; - return (1- sqr_g) / (4.0 * M_PI * pow(1 + sqr_g - 2 * g * cos_theta, 3.0 / 2.0)); + return (1- sqr_g) / max(1e-8, 4.0 * M_PI * pow(1 + sqr_g - 2 * g * cos_theta, 3.0 / 2.0)); } #ifdef LAMPS_LIB diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl index af7e0f0d17e..ea402ff3d99 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl @@ -39,7 +39,7 @@ void main() vec3 wdir = cameraVec; vec2 phase = texelFetch(volumePhase, volume_cell, 0).rg; - float s_anisotropy = phase.x / phase.y; + float s_anisotropy = phase.x / max(1.0, phase.y); /* Environment : Average color. */ outScattering.rgb += irradiance_volumetric(worldPosition) * s_scattering * phase_function_isotropic(); @@ -78,6 +78,6 @@ void main() /* Catch NaNs */ if (any(isnan(outScattering)) || any(isnan(outTransmittance))) { outScattering = vec4(0.0); - outTransmittance = vec4(0.0); + outTransmittance = vec4(1.0); } } |