diff options
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl | 21 | ||||
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl | 11 |
2 files changed, 22 insertions, 10 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl index ba02ae6d886..6788b34c938 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl @@ -6,8 +6,8 @@ void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, - float use_multiscatter, - float ssr_id, + const float do_multiscatter, + const float ssr_id, out Closure result) { CLOSURE_VARS_DECLARE_2(Glossy, Refraction); @@ -23,11 +23,16 @@ void node_bsdf_glass(vec4 color, result = CLOSURE_DEFAULT; - float fresnel = F_eta(in_Refraction_1.ior, dot(in_Glossy_0.N, cameraVec)); + float NV = dot(in_Refraction_1.N, cameraVec); + + float fresnel = (do_multiscatter != 0.0) ? + btdf_lut(NV, in_Refraction_1.roughness, in_Refraction_1.ior).y : + F_eta(in_Refraction_1.ior, NV); + + vec2 split_sum = brdf_lut(NV, in_Glossy_0.roughness); + vec3 brdf = (do_multiscatter != 0.0) ? F_brdf_multi_scatter(vec3(1.0), vec3(1.0), split_sum) : + F_brdf_single_scatter(vec3(1.0), vec3(1.0), split_sum); - vec2 split_sum = brdf_lut(dot(in_Glossy_0.N, cameraVec), in_Glossy_0.roughness); - vec3 brdf = (use_multiscatter != 0.0) ? F_brdf_multi_scatter(vec3(1.0), vec3(1.0), split_sum) : - F_brdf_single_scatter(vec3(1.0), vec3(1.0), split_sum); out_Glossy_0.radiance = closure_mask_ssr_radiance(out_Glossy_0.radiance, ssr_id); out_Glossy_0.radiance *= brdf; out_Glossy_0.radiance = render_pass_glossy_mask(vec3(1.0), out_Glossy_0.radiance); @@ -35,6 +40,10 @@ void node_bsdf_glass(vec4 color, closure_load_ssr_data( out_Glossy_0.radiance, in_Glossy_0.roughness, in_Glossy_0.N, ssr_id, result); + float btdf = (do_multiscatter != 0.0) ? + 1.0 : + btdf_lut(NV, in_Refraction_1.roughness, in_Refraction_1.ior).x; + out_Refraction_1.radiance *= btdf; out_Refraction_1.radiance = render_pass_glossy_mask(vec3(1.0), out_Refraction_1.radiance); out_Refraction_1.radiance *= color.rgb * (1.0 - fresnel); /* Simulate 2nd absorption event. */ diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl index 15958dcf65e..139dcb33222 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl @@ -70,7 +70,6 @@ void node_bsdf_principled(vec4 base_color, in_Refraction_3.N = N; /* Normalized during eval. */ in_Refraction_3.roughness = do_multiscatter != 0.0 ? roughness : transmission_roughness; in_Refraction_3.ior = ior; - CLOSURE_EVAL_FUNCTION_4(node_bsdf_principled, Diffuse, Glossy, Glossy, Refraction); @@ -92,9 +91,9 @@ void node_bsdf_principled(vec4 base_color, vec3 base_color_tint = tint_from_color(base_color.rgb); - /* TODO(fclem) This isn't good for rough glass using multiscatter (since the fresnel is applied - * on each microfacet in cycles). */ - float fresnel = F_eta(in_Refraction_3.ior, NV); + float fresnel = (do_multiscatter != 0.0) ? + btdf_lut(NV, in_Glossy_1.roughness, in_Refraction_3.ior).y : + F_eta(in_Refraction_3.ior, NV); { /* Glossy reflections. @@ -159,7 +158,11 @@ void node_bsdf_principled(vec4 base_color, } if (transmission > 1e-5) { + float btdf = (do_multiscatter != 0.0) ? + 1.0 : + btdf_lut(NV, in_Refraction_3.roughness, in_Refraction_3.ior).x; /* TODO(fclem) This could be going to a transmission render pass instead. */ + out_Refraction_3.radiance *= btdf; out_Refraction_3.radiance = render_pass_glossy_mask(vec3(1), out_Refraction_3.radiance); out_Refraction_3.radiance *= base_color.rgb; /* Simulate 2nd transmission event. */ |