[Bf-blender-cvs] [96e8dadda0b] blender-v2.91-release: Fix T82385 EEVEE: Alpha Clip shadows actually using Alpha Hashed shadows

Clément Foucault noreply at git.blender.org
Wed Nov 4 17:16:35 CET 2020


Commit: 96e8dadda0b2dda7ce771b1eba2d901a056a039f
Author: Clément Foucault
Date:   Wed Nov 4 17:16:06 2020 +0100
Branches: blender-v2.91-release
https://developer.blender.org/rB96e8dadda0b2dda7ce771b1eba2d901a056a039f

Fix T82385 EEVEE: Alpha Clip shadows actually using Alpha Hashed shadows

The shadow path was not using the alpha threshold.

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

M	source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl
M	source/blender/nodes/shader/nodes/node_shader_output_material.c

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

diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl
index 4cb00c15b78..14271f9d107 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_output_material.glsl
@@ -1,5 +1,9 @@
-void node_output_material(
-    Closure surface, Closure volume, vec3 displacement, float alpha_threshold, out Closure result)
+void node_output_material(Closure surface,
+                          Closure volume,
+                          vec3 displacement,
+                          float alpha_threshold,
+                          float shadow_threshold,
+                          out Closure result)
 {
 #ifdef VOLUMETRICS
   result = volume;
@@ -7,9 +11,9 @@ void node_output_material(
   result = surface;
 #  if defined(USE_ALPHA_HASH)
   /* Alpha clip emulation. */
-  if (alpha_threshold >= 0.0) {
+  if ((rayType != EEVEE_RAY_SHADOW) ? (alpha_threshold >= 0.0) : (shadow_threshold >= 0.0)) {
     float alpha = saturate(1.0 - avg(result.transmittance));
-    result.transmittance = vec3(step(alpha, alpha_threshold));
+    result.transmittance = vec3(step(alpha, max(alpha_threshold, shadow_threshold)));
   }
 #  endif
 #endif
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
index 578262e9f17..fb0b6e7b263 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c
@@ -45,18 +45,29 @@ static int node_shader_gpu_output_material(GPUMaterial *mat,
                                            GPUNodeStack *in,
                                            GPUNodeStack *out)
 {
-  GPUNodeLink *outlink, *alpha_threshold_link;
-
+  GPUNodeLink *outlink, *alpha_threshold_link, *shadow_threshold_link;
   Material *ma = GPU_material_get_material(mat);
-  if (ma && ma->blend_method == MA_BM_CLIP) {
-    alpha_threshold_link = GPU_uniform(&ma->alpha_threshold);
+
+  static float no_alpha_threshold = -1.0f;
+  if (ma) {
+    alpha_threshold_link = GPU_uniform((ma->blend_method == MA_BM_CLIP) ? &ma->alpha_threshold :
+                                                                          &no_alpha_threshold);
+    shadow_threshold_link = GPU_uniform((ma->blend_shadow == MA_BS_CLIP) ? &ma->alpha_threshold :
+                                                                           &no_alpha_threshold);
   }
   else {
-    static float no_alpha_threshold = -1.0f;
     alpha_threshold_link = GPU_uniform(&no_alpha_threshold);
+    shadow_threshold_link = GPU_uniform(&no_alpha_threshold);
   }
 
-  GPU_stack_link(mat, node, "node_output_material", in, out, alpha_threshold_link, &outlink);
+  GPU_stack_link(mat,
+                 node,
+                 "node_output_material",
+                 in,
+                 out,
+                 alpha_threshold_link,
+                 shadow_threshold_link,
+                 &outlink);
   GPU_material_output_link(mat, outlink);
 
   return true;



More information about the Bf-blender-cvs mailing list