diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-06-27 15:40:29 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-06-27 15:41:35 +0300 |
commit | 2a22b8af04eb2edccfd3d378b8e279bec54639e0 (patch) | |
tree | a87fc64f39a65f46b1cacd1927c3896c332fce8c /source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl | |
parent | 1f4e9754c02891076ffe5c29a2d7c030aace219c (diff) |
Eevee: Make use of dual source blending for volumetric resolve
This simplify the code and add an example use of dual source
blending.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl index 580b53231a0..40eb3da42d1 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl @@ -145,15 +145,13 @@ vec3 irradiance_volumetric(vec3 wpos) uniform sampler3D inScattering; uniform sampler3D inTransmittance; -vec4 volumetric_resolve(vec4 scene_color, vec2 frag_uvs, float frag_depth) +void volumetric_resolve(vec2 frag_uvs, + float frag_depth, + out vec3 transmittance, + out vec3 scattering) { vec3 volume_cos = ndc_to_volume(vec3(frag_uvs, frag_depth)); - vec3 scattering = texture(inScattering, volume_cos).rgb; - vec3 transmittance = texture(inTransmittance, volume_cos).rgb; - - /* Approximate volume alpha by using a monochromatic transmitance - * and adding it to the scene alpha. */ - float final_alpha = mix(1.0, scene_color.a, dot(transmittance, vec3(1.0 / 3.0))); - return vec4(scene_color.rgb * transmittance + scattering, final_alpha); + scattering = texture(inScattering, volume_cos).rgb; + transmittance = texture(inTransmittance, volume_cos).rgb; } |