diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-10-24 15:49:00 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-10-27 23:49:15 +0300 |
commit | 66d8f82b832b58cba3273c0a4196fae6db0e1efd (patch) | |
tree | 682a3aba8fbd23ccd72a4e4f2a02fb36ad0a0d01 /source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl | |
parent | 1c0c63ce5b3914be2d0828260e5ac777a7596d36 (diff) |
Eevee: Overhaul the volumetric system.
The system now uses several 3D textures in order to decouple every steps of the volumetric rendering.
See https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite for more details.
On the technical side, instead of using a compute shader to populate the 3D textures we use layered rendering with a geometry shader to render 1 fullscreen triangle per 3D texture slice.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl new file mode 100644 index 00000000000..3e678bbc83f --- /dev/null +++ b/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl @@ -0,0 +1,27 @@ + +/* Based on Frosbite Unified Volumetric. + * https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */ + +/* Step 4 : Apply final integration on top of the scene color. + * Note that we do the blending ourself instead of relying + * on hardware blending which would require 2 pass. */ + +uniform sampler3D inScattering; +uniform sampler3D inTransmittance; + +uniform sampler2D inSceneColor; +uniform sampler2D inSceneDepth; + +out vec4 FragColor; + +void main() +{ + vec2 uvs = gl_FragCoord.xy / vec2(textureSize(inSceneDepth, 0)); + vec3 volume_cos = ndc_to_volume(vec3(uvs, texture(inSceneDepth, uvs).r)); + + vec3 scene_color = texture(inSceneColor, uvs).rgb; + vec3 scattering = texture(inScattering, volume_cos).rgb; + vec3 transmittance = texture(inTransmittance, volume_cos).rgb; + + FragColor = vec4(scene_color * transmittance + scattering, 1.0); +} |