diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-10-02 20:44:44 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-10-02 20:44:44 +0300 |
commit | 5f7192018eb81af1cf406999d8d7871b4f47cd31 (patch) | |
tree | baad096703fc06f690d371a4b4d0b81e770e77ea /source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl | |
parent | 04e4a0db0dec2f52b0059c58c32fc5fa423a0407 (diff) |
Eevee : SSR : Make sure to not apply Specular Occlusion to SSR.
This makes the metals shine more.
Previous behaviour was not correct.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl index 520dc7b9624..7d142e50013 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl @@ -186,11 +186,16 @@ uniform mat4 PastViewProjectionMatrix; out vec4 fragColor; -void fallback_cubemap(vec3 N, vec3 V, vec3 W, float roughness, float roughnessSquared, inout vec4 spec_accum) +void fallback_cubemap(vec3 N, vec3 V, vec3 W, vec3 viewPosition, float roughness, float roughnessSquared, inout vec4 spec_accum) { /* Specular probes */ vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared); + vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0)); + vec3 bent_normal; + float final_ao = occlusion_compute(N, viewPosition, 1.0, rand.rg, bent_normal); + final_ao = specular_occlusion(dot(N, V), final_ao, roughness); + /* Starts at 1 because 0 is world probe */ for (int i = 1; i < MAX_PROBE && i < probe_count && spec_accum.a < 0.999; ++i) { CubeData cd = probes_data[i]; @@ -198,14 +203,14 @@ void fallback_cubemap(vec3 N, vec3 V, vec3 W, float roughness, float roughnessSq float fade = probe_attenuation_cube(cd, W); if (fade > 0.0) { - vec3 spec = probe_evaluate_cube(float(i), cd, W, spec_dir, roughness); + vec3 spec = final_ao * probe_evaluate_cube(float(i), cd, W, spec_dir, roughness); accumulate_light(spec, fade, spec_accum); } } /* World Specular */ if (spec_accum.a < 0.999) { - vec3 spec = probe_evaluate_world_spec(spec_dir, roughness); + vec3 spec = final_ao * probe_evaluate_world_spec(spec_dir, roughness); accumulate_light(spec, 1.0, spec_accum); } } @@ -436,7 +441,7 @@ void main() /* If SSR contribution is not 1.0, blend with cubemaps */ if (spec_accum.a < 1.0) { - fallback_cubemap(N, V, worldPosition, roughness, roughnessSquared, spec_accum); + fallback_cubemap(N, V, worldPosition, viewPosition, roughness, roughnessSquared, spec_accum); } fragColor = vec4(spec_accum.rgb * speccol_roughness.rgb, 1.0); |