diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-10-08 21:29:27 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-10-08 21:29:35 +0300 |
commit | 576c782b11f629130b1226f37d4fd467f8793247 (patch) | |
tree | 91203cd335eb7aaf69610a6a64461b2dcd4b7419 /source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl | |
parent | 47b95a295706c3092e48a227b50360748f8789be (diff) |
Fix T70586 EEVEE: principled shader alpha bleeding issues
Avoid double multiplication by alpha on ssr/sss data.
Diffstat (limited to 'source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl')
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl | 25 |
1 files changed, 16 insertions, 9 deletions
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 140213a9ed9..7af409dd410 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl @@ -113,14 +113,14 @@ void node_bsdf_principled(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = out_spec + out_refr; result.radiance += out_diff * out_sheen; /* Coarse approx. */ + result.radiance += emission.rgb; + result.radiance *= alpha; closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); mixed_ss_base_color *= alpha * (1.0 - transmission); closure_load_sss_data(sss_scalef, out_diff, mixed_ss_base_color, int(sss_id), result); - result.radiance += emission.rgb; - result.radiance *= alpha; result.transmittance = vec3(1.0 - alpha); } @@ -169,9 +169,11 @@ void node_bsdf_principled_dielectric(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = out_spec + out_diff * (diffuse + out_sheen); - closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); result.radiance += emission.rgb; result.radiance *= alpha; + + closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); + result.transmittance = vec3(1.0 - alpha); } @@ -213,9 +215,11 @@ void node_bsdf_principled_metallic(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = out_spec; - closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); result.radiance += emission.rgb; result.radiance *= alpha; + + closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); + result.transmittance = vec3(1.0 - alpha); } @@ -267,9 +271,11 @@ void node_bsdf_principled_clearcoat(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = out_spec; - closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); result.radiance += emission.rgb; result.radiance *= alpha; + + closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); + result.transmittance = vec3(1.0 - alpha); } @@ -333,14 +339,15 @@ void node_bsdf_principled_subsurface(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = out_spec; + result.radiance += out_diff * out_sheen; + result.radiance += emission.rgb; + result.radiance *= alpha; + closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); mixed_ss_base_color *= alpha * (1.0 - transmission); closure_load_sss_data(sss_scalef, out_diff, mixed_ss_base_color, int(sss_id), result); - result.radiance += out_diff * out_sheen; - result.radiance += emission.rgb; - result.radiance *= alpha; result.transmittance = vec3(1.0 - alpha); } @@ -402,9 +409,9 @@ void node_bsdf_principled_glass(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = mix(out_refr, out_spec, fresnel); - closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); result.radiance += emission.rgb; result.radiance *= alpha; + closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); result.transmittance = vec3(1.0 - alpha); } #else |