diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-11-22 06:51:21 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-11-22 06:51:21 +0300 |
commit | 846cdf53187174ac87dd24af4b7b0d413db4ad03 (patch) | |
tree | 11139716a842f878f7d350a3cffeb6e4ecfbf02c /source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl | |
parent | ff810f08d8670b3d016e865e9b32df44c270ddaa (diff) |
Eevee : SSS : Add Translucency support.
This adds the possibility to simulate things like red ears with strong backlight or material with high scattering distances.
To enable it you need to turn on the "Subsurface Translucency" option in the "Options" tab of the Material Panel (and of course to have "regular" SSS enabled in both render settings and material options).
Since the effect is adding another overhead I prefer to make it optional. But this is open to discussion.
Be aware that the effect only works for direct lights (so no indirect/world lighting) that have shadowmaps, and is affected by the "softness" of the shadowmap and resolution.
Technical notes:
This is inspired by http://www.iryoku.com/translucency/ but goes a bit beyond that.
We do not use a sum of gaussian to apply in regards to the object thickness but we precompute a 1D kernel texture.
This texture stores the light transmited to a point at the back of an infinite slab of material of variying thickness.
We make the assumption that the slab is perpendicular to the light so that no fresnel or diffusion term is taken into account.
The light is considered constant.
If the setup is similar to the one assume during the profile baking, the realtime render matches cycles reference.
Due to these assumptions the computed transmitted light is in most cases too bright for curvy objects.
Finally we jitter the shadow map sample per pixel so we can simulate dispersion inside the medium.
Radius of the dispersion is in world space and derived by from the "soft" shadowmap parameter.
Idea for this come from this presentation http://www.iryoku.com/stare-into-the-future (slide 164).
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl index 9ee713ab483..ea9711a6cad 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl @@ -5,9 +5,9 @@ layout(std140) uniform sssProfile { vec4 kernel[MAX_SSS_SAMPLES]; vec4 radii_max_radius; + int sss_samples; }; -uniform int sampleCount; uniform float jitterThreshold; uniform sampler2D depthBuffer; uniform sampler2D sssData; @@ -59,7 +59,7 @@ void main(void) /* Center sample */ vec3 accum = sss_data.rgb * kernel[0].rgb; - for (int i = 1; i < sampleCount && i < MAX_SSS_SAMPLES; i++) { + for (int i = 1; i < sss_samples && i < MAX_SSS_SAMPLES; i++) { vec2 sample_uv = uvs + kernel[i].a * finalStep * ((abs(kernel[i].a) > jitterThreshold) ? dir : dir_rand); vec3 color = texture(sssData, sample_uv).rgb; float sample_depth = texture(depthBuffer, sample_uv).r; |