[Bf-blender-cvs] [f2b3e1f7127] blender2.8: Eevee: Fix T52480: Can't reproduce Metallic transparency with Principled + Mix Shader

Clément Foucault noreply at git.blender.org
Tue Sep 12 14:27:18 CEST 2017


Commit: f2b3e1f7127681db97501777dcb1d169fd1e86a5
Author: Clément Foucault
Date:   Tue Sep 12 14:19:57 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBf2b3e1f7127681db97501777dcb1d169fd1e86a5

Eevee: Fix T52480: Can't reproduce Metallic transparency with Principled + Mix Shader

You can now use a transparent shader as a completly transparent bsdf. And use whatever alpha mask in a mix shader between a transparent bsdf and another bsdf.

===================================================================

M	source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
M	source/blender/gpu/shaders/gpu_shader_material.glsl

===================================================================

diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
index 92d4b5aaed0..38dc886dd7d 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -568,6 +568,9 @@ struct Closure {
 	int ssr_id;
 };
 
+/* This is hacking ssr_id to tag transparent bsdf */
+#define TRANSPARENT_CLOSURE_FLAG -2
+
 #define CLOSURE_DEFAULT Closure(vec3(0.0), 1.0, vec4(0.0), vec2(0.0), -1)
 
 uniform int outputSsrId;
@@ -585,6 +588,12 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac)
 		cl.ssr_normal = cl2.ssr_normal;
 		cl.ssr_id = cl2.ssr_id;
 	}
+	if (cl1.ssr_id == TRANSPARENT_CLOSURE_FLAG) {
+		cl1.radiance = cl2.radiance;
+	}
+	if (cl2.ssr_id == TRANSPARENT_CLOSURE_FLAG) {
+		cl2.radiance = cl1.radiance;
+	}
 	cl.radiance = mix(cl1.radiance, cl2.radiance, fac);
 	cl.opacity = mix(cl1.opacity, cl2.opacity, fac);
 	return cl;
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 3a47aea405e..62ac953d64b 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2919,8 +2919,8 @@ void node_bsdf_translucent(vec4 color, vec3 N, out Closure result)
 void node_bsdf_transparent(vec4 color, out Closure result)
 {
 	/* this isn't right */
-	result.radiance = color.rgb;
-	result.opacity = color.a;
+	result.radiance = vec3(0.0);
+	result.opacity = 0.0;
 }
 
 void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out Closure result)



More information about the Bf-blender-cvs mailing list