diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-08-04 19:47:41 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-08-10 16:43:47 +0300 |
commit | e0078cd953e67dcf12b9d48ec3625a33ff0d1a8c (patch) | |
tree | aa2dcffaefa925f9b8888489634ce9120e0dd560 /source/blender/gpu | |
parent | aaa469a403bc726715cd3f30e122d6bf52fed3ab (diff) |
Eevee: Add Refraction via probes.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 416907c8453..a4e0f85b132 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2722,7 +2722,15 @@ void node_bsdf_anisotropic( void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, out Closure result) { +#ifdef EEVEE_ENGINE + vec3 ssr_spec; + roughness = sqrt(roughness); + vec3 L = eevee_surface_glass(N, vec3(1.0), roughness, ior, int(-2), ssr_spec); + vec3 vN = normalize(mat3(ViewMatrix) * N); + result = Closure(L * color.rgb, 1.0, vec4(ssr_spec * color.rgb, roughness), normal_encode(vN, viewCameraVec), int(-2)); +#else node_bsdf_diffuse(color, 0.0, N, result); +#endif } void node_bsdf_toon(vec4 color, float size, float tsmooth, vec3 N, out Closure result) @@ -2881,8 +2889,9 @@ 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, roughness, ior, int(-2), 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); result = Closure(L, 1.0, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id)); #endif @@ -2896,7 +2905,7 @@ void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subs void node_bsdf_translucent(vec4 color, vec3 N, out Closure result) { - node_bsdf_diffuse(color, 0.0, N, result); + node_bsdf_diffuse(color, 0.0, -N, result); } void node_bsdf_transparent(vec4 color, out Closure result) @@ -2918,6 +2927,19 @@ void node_subsurface_scattering( node_bsdf_diffuse(color, 0.0, N, result); } +void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Closure result) +{ +#ifdef EEVEE_ENGINE + vec3 ssr_spec; + roughness = sqrt(roughness); + vec3 L = eevee_surface_refraction(N, vec3(1.0), roughness, ior, int(-2), ssr_spec); + vec3 vN = normalize(mat3(ViewMatrix) * N); + result = Closure(L * color.rgb, 1.0, vec4(ssr_spec * color.rgb, roughness), normal_encode(vN, viewCameraVec), int(-2)); +#else + node_bsdf_diffuse(color, 0.0, N, result); +#endif /* EEVEE_ENGINE */ +} + /* Unsupported for now */ #ifndef EEVEE_ENGINE void node_bsdf_hair(vec4 color, float offset, float roughnessu, float roughnessv, vec3 tangent, out Closure result) @@ -2925,11 +2947,6 @@ void node_bsdf_hair(vec4 color, float offset, float roughnessu, float roughnessv result = Closure(color.rgb, color.a); } -void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Closure result) -{ - node_bsdf_diffuse(color, 0.0, N, result); -} - void node_ambient_occlusion(vec4 color, out Closure result) { result = Closure(color.rgb, color.a); |