From b526221315e5734306ef3bf5e520529d7f9e24a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 16 May 2019 16:43:41 +0200 Subject: Eevee: Remove the Subsurface Render checkbox This is to simplify the usage of SSS. Now it automatically detect if there is any SSS material in the view and allocate the needed buffer if any. --- source/blender/gpu/intern/gpu_material.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/blender/gpu/intern/gpu_material.c') diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 4f90155b88c..fde60fd387d 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -36,6 +36,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BLI_string.h" +#include "BLI_string_utils.h" #include "BKE_main.h" #include "BKE_node.h" @@ -125,7 +126,6 @@ struct GPUMaterial { enum { GPU_DOMAIN_SURFACE = (1 << 0), GPU_DOMAIN_VOLUME = (1 << 1), - GPU_DOMAIN_SSS = (1 << 2), }; /* Functions */ @@ -682,6 +682,10 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene, SET_FLAG_FROM_TEST(mat->domain, has_volume_output, GPU_DOMAIN_VOLUME); 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"); + } /* Prune the unused nodes and extract attributes before compiling so the * generated VBOs are ready to accept the future shader. */ GPU_nodes_prune(&mat->nodes, mat->outlink); @@ -697,6 +701,10 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene, frag_lib, defines); + if (GPU_material_flag_get(mat, GPU_MATFLAG_SSS)) { + MEM_freeN((char *)defines); + } + if (mat->pass == NULL) { /* We had a cache hit and the shader has already failed to compile. */ mat->status = GPU_MAT_FAILED; -- cgit v1.2.3