Eevee: Fix SSS energy disapearing with alpha blended material
This commit is contained in:
		@@ -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. */
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user