[Bf-blender-cvs] [df7f69b8735] master: Eevee: Fix SSS energy disapearing with alpha blended material

Clément Foucault noreply at git.blender.org
Thu May 23 14:39:29 CEST 2019


Commit: df7f69b8735f440f22404ab65698404deff30ed7
Author: Clément Foucault
Date:   Thu May 23 15:30:38 2019 +0200
Branches: master
https://developer.blender.org/rBdf7f69b8735f440f22404ab65698404deff30ed7

Eevee: Fix SSS energy disapearing with alpha blended material

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

M	source/blender/gpu/intern/gpu_material.c
M	source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c

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

diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index fde60fd387d..007a13a06ef 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -620,7 +620,7 @@ void GPU_material_flag_set(GPUMaterial *mat, eGPUMatFlag flag)
 
 bool GPU_material_flag_get(GPUMaterial *mat, eGPUMatFlag flag)
 {
-  return (mat->flag & flag);
+  return (mat->flag & flag) != 0;
 }
 
 GPUMaterial *GPU_material_from_nodetree_find(ListBase *gpumaterials,
@@ -684,7 +684,10 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
   if (mat->outlink) {
     /* HACK: this is only for eevee. We add the define here after the nodetree evaluation. */
     if (GPU_material_flag_get(mat, GPU_MATFLAG_SSS)) {
-      defines = BLI_string_joinN(defines, "#define USE_SSS\n");
+      defines = BLI_string_joinN(defines,
+                                 "#ifndef USE_ALPHA_BLEND\n"
+                                 "#  define USE_SSS\n"
+                                 "#endif\n");
     }
     /* Prune the unused nodes and extract attributes before compiling so the
      * generated VBOs are ready to accept the future shader. */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index 6c3e082f36a..48065cb10c9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
@@ -164,7 +164,7 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
   else if (use_subsurf && use_diffuse && !use_refract && !use_clear) {
     static char name[] = "node_bsdf_principled_subsurface";
     node_name = name;
-    flag = GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_SSS | GPU_MATFLAG_GLOSSY;
+    flag = GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_GLOSSY;
   }
   else if (!use_subsurf && !use_diffuse && use_refract && !use_clear && !socket_not_zero(4)) {
     static char name[] = "node_bsdf_principled_glass";
@@ -174,7 +174,11 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
   else {
     static char name[] = "node_bsdf_principled";
     node_name = name;
-    flag = GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_GLOSSY | GPU_MATFLAG_SSS | GPU_MATFLAG_REFRACT;
+    flag = GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_GLOSSY | GPU_MATFLAG_REFRACT;
+  }
+
+  if (use_subsurf) {
+    flag |= GPU_MATFLAG_SSS;
   }
 
   GPU_material_flag_set(mat, flag);



More information about the Bf-blender-cvs mailing list