Eevee : Fix regression : Refraction not working

This commit is contained in:
Clément Foucault 2017-09-26 16:47:53 +02:00
parent 772944a6b4
commit 5c45fe2937
3 changed files with 7 additions and 3 deletions

View File

@ -570,6 +570,7 @@ struct Closure {
/* This is hacking ssr_id to tag transparent bsdf */
#define TRANSPARENT_CLOSURE_FLAG -2
#define REFRACT_CLOSURE_FLAG -3
#define CLOSURE_DEFAULT Closure(vec3(0.0), 1.0, vec4(0.0), vec2(0.0), -1)

View File

@ -35,7 +35,7 @@ vec4 screen_space_refraction(vec3 viewPosition, vec3 N, vec3 V, float ior, float
vec3 hit_pos = raycast(-1, viewPosition, R, ssrThickness, jitter, roughnessSquared);
if ((hit_pos.z < 0.0) && (F_eta(ior, dot(H, V)) < 1.0)) {
if ((hit_pos.z > 0.0) && (F_eta(ior, dot(H, V)) < 1.0)) {
hit_pos = get_view_space_from_depth(hit_pos.xy, hit_pos.z);
float hit_dist = distance(hit_pos, viewPosition);

View File

@ -2897,7 +2897,7 @@ void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subs
}
result = Closure(surface_color.rgb / surface_color.a, 1.0);
#else
vec3 L_trans = (transmission <= 0.0) ? vec3(0.0) : eevee_surface_glass(N, base_color.rgb * ((refractionDepth > 0.0) ? base_color.rgb : vec3(1.0)), roughness, ior, int(-2), ssr_spec);
vec3 L_trans = (transmission <= 0.0) ? vec3(0.0) : eevee_surface_glass(N, base_color.rgb * ((refractionDepth > 0.0) ? base_color.rgb : vec3(1.0)), roughness, ior, REFRACT_CLOSURE_FLAG, ssr_spec);
vec3 L = eevee_surface_clearcoat_lit(N, diffuse, f0, roughness, CN, clearcoat, clearcoat_roughness, 1.0, int(ssr_id), ssr_spec);
L = mix(L, L_trans, transmission);
vec3 vN = normalize(mat3(ViewMatrix) * N);
@ -2921,6 +2921,9 @@ void node_bsdf_transparent(vec4 color, out Closure result)
/* this isn't right */
result.radiance = vec3(0.0);
result.opacity = 0.0;
#ifdef EEVEE_ENGINE
result.ssr_id = TRANSPARENT_CLOSURE_FLAG;
#endif
}
void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out Closure result)
@ -2941,7 +2944,7 @@ void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Cl
color.rgb *= (refractionDepth > 0.0) ? color.rgb : vec3(1.0); /* Simulate 2 absorption event. */
roughness = sqrt(roughness);
vec3 L = eevee_surface_refraction(N, vec3(1.0), roughness, ior);
result = Closure(L * color.rgb, 1.0, vec4(0.0), vec2(0.0), int(-2));
result = Closure(L * color.rgb, 1.0, vec4(0.0), vec2(0.0), REFRACT_CLOSURE_FLAG);
#else
node_bsdf_diffuse(color, 0.0, N, result);
#endif /* EEVEE_ENGINE */