diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-08-15 10:36:23 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-08-18 16:07:17 +0300 |
commit | 95b1b7756d6e09b0bcf98c120de2b6552c1848be (patch) | |
tree | fa13963580f26979825ed7b39352ab02e4b10bf2 /source/blender/draw/engines | |
parent | f4bd416b342ba840b5c3660526e0a938b7730cce (diff) |
Eevee: Fix some problem with Glass & Diffuse BSDF with SSR
Diffuse was not outputing the right normal. (this is not a problem with SSR actually)
Glass did not have proper ssr_id and was receiving environment lighting twice.
Also it did not have proper fresnel on lamps.
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl | 20 |
1 files changed, 13 insertions, 7 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 4ee2e778c21..16b3283b624 100644 --- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl @@ -742,7 +742,7 @@ vec3 eevee_surface_glass(vec3 N, vec3 transmission_col, float roughness, float i vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared); /* Starts at 1 because 0 is world probe */ - for (int i = 1; i < MAX_PROBE && i < probe_count && spec_accum.a < 0.999 && trans_accum.a < 0.999; ++i) { + for (int i = 1; i < MAX_PROBE && i < probe_count && (spec_accum.a < 0.999 || trans_accum.a < 0.999); ++i) { CubeData cd = probes_data[i]; float fade = probe_attenuation_cube(cd, worldPosition); @@ -751,10 +751,10 @@ vec3 eevee_surface_glass(vec3 N, vec3 transmission_col, float roughness, float i if (!(ssrToggle && ssr_id == outputSsrId)) { vec3 spec = probe_evaluate_cube(float(i), cd, worldPosition, spec_dir, roughness); accumulate_light(spec, fade, spec_accum); - - spec = probe_evaluate_cube(float(i), cd, refr_pos, refr_dir, roughnessSquared); - accumulate_light(spec, fade, trans_accum); } + + spec = probe_evaluate_cube(float(i), cd, refr_pos, refr_dir, roughnessSquared); + accumulate_light(spec, fade, trans_accum); } } @@ -763,12 +763,14 @@ vec3 eevee_surface_glass(vec3 N, vec3 transmission_col, float roughness, float i if (!(ssrToggle && ssr_id == outputSsrId)) { vec3 spec = probe_evaluate_world_spec(spec_dir, roughness); accumulate_light(spec, 1.0, spec_accum); - - spec = probe_evaluate_world_spec(refr_dir, roughnessSquared); - accumulate_light(spec, 1.0, trans_accum); } } + if (trans_accum.a < 0.999) { + spec = probe_evaluate_world_spec(refr_dir, roughnessSquared); + accumulate_light(spec, 1.0, trans_accum); + } + /* Ambient Occlusion */ /* TODO : when AO will be cheaper */ float final_ao = 1.0; @@ -780,9 +782,13 @@ vec3 eevee_surface_glass(vec3 N, vec3 transmission_col, float roughness, float i float fresnel = F_eta(ior, NV); + /* Apply fresnel on lamps. */ + out_light *= vec3(fresnel); + ssr_spec = vec3(fresnel) * F_ibl(vec3(1.0), brdf_lut) * specular_occlusion(NV, final_ao, roughness); out_light += spec_accum.rgb * ssr_spec; + float btdf = get_btdf_lut(utilTex, NV, roughness, ior); out_light += vec3(1.0 - fresnel) * transmission_col * trans_accum.rgb * btdf; |