diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-11-08 15:07:22 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-11-08 21:20:40 +0300 |
commit | 1250ace641814098ed8e6715f6e69c5cbd46f8dd (patch) | |
tree | a921f3eaae6c3682f6334584899ba89ce53e9233 /source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl | |
parent | de8c2336adf56061c4ae29c28cfc001d08d300f2 (diff) |
Eevee: Fix refraction materials
Fix refraction depth not working without ScreenSpace Refraction.
Fix ScreenSpace Refraction masking reflections.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl index 164b6da68bf..091709ebdd1 100644 --- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl @@ -330,37 +330,55 @@ void CLOSURE_NAME( /* ---------------------------- */ #if defined(CLOSURE_GLOSSY) || defined(CLOSURE_REFRACTION) - #ifdef CLOSURE_REFRACTION - #define ACCUM refr_accum + #if defined(CLOSURE_GLOSSY) && defined(CLOSURE_REFRACTION) + #define GLASS_ACCUM 1 + #define ACCUM min(refr_accum.a, spec_accum.a) + #elif defined(CLOSURE_REFRACTION) + #define GLASS_ACCUM 0 + #define ACCUM refr_accum.a #else - #define ACCUM spec_accum + #define GLASS_ACCUM 0 + #define ACCUM spec_accum.a #endif /* Starts at 1 because 0 is world probe */ - for (int i = 1; ACCUM.a < 0.999 && i < prbNumRenderCube && i < MAX_PROBE; ++i) { + for (int i = 1; ACCUM < 0.999 && i < prbNumRenderCube && i < MAX_PROBE; ++i) { float fade = probe_attenuation_cube(i, worldPosition); if (fade > 0.0) { - #ifdef CLOSURE_GLOSSY - if (!(ssrToggle && ssr_id == outputSsrId)) { - vec3 spec = probe_evaluate_cube(i, worldPosition, spec_dir, roughness); - accumulate_light(spec, fade, spec_accum); - } + #if GLASS_ACCUM + if (spec_accum.a < 0.999) { #endif + #ifdef CLOSURE_GLOSSY + if (!(ssrToggle && ssr_id == outputSsrId)) { + vec3 spec = probe_evaluate_cube(i, worldPosition, spec_dir, roughness); + accumulate_light(spec, fade, spec_accum); + } + #endif - #ifdef CLOSURE_CLEARCOAT - vec3 C_spec = probe_evaluate_cube(i, worldPosition, C_spec_dir, C_roughness); - accumulate_light(C_spec, fade, C_spec_accum); + #ifdef CLOSURE_CLEARCOAT + vec3 C_spec = probe_evaluate_cube(i, worldPosition, C_spec_dir, C_roughness); + accumulate_light(C_spec, fade, C_spec_accum); + #endif + #if GLASS_ACCUM + } #endif - #ifdef CLOSURE_REFRACTION - vec3 trans = probe_evaluate_cube(i, refr_pos, refr_dir, roughnessSquared); - accumulate_light(trans, fade, refr_accum); + #if GLASS_ACCUM + if (refr_accum.a < 0.999) { + #endif + #ifdef CLOSURE_REFRACTION + vec3 trans = probe_evaluate_cube(i, refr_pos, refr_dir, roughnessSquared); + accumulate_light(trans, fade, refr_accum); + #endif + #if GLASS_ACCUM + } #endif } } + #undef GLASS_ACCUM #undef ACCUM /* ---------------------------- */ |