Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-05 22:09:04 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-06 14:05:21 +0300
commit2a0a7cd73d99340b348a0298cc709a9c3f663ee9 (patch)
treef754ce355a5390d5893cfc5c5f996c28b919d54c /source/blender
parent15ad75ffefca8d0fa800fddd8c57e9d578dfa0f4 (diff)
Eevee: Fix missing UBO bound if using a muted Shader to RGB node with SSS
This is a nasty bug. Because the node does not get properlly tagged as SSS (sss_id is 0) but is still evaluated (so tagging the GPUMaterial as having SSS). The sssProfile UBO is still declared and we need to bind something to it.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c22
-rw-r--r--source/blender/gpu/GPU_material.h1
-rw-r--r--source/blender/gpu/intern/gpu_material.c5
3 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index db3a6ec50cb..eee1e716da1 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -66,6 +66,8 @@ static struct {
struct GPUTexture *util_tex;
struct GPUTexture *noise_tex;
+ struct GPUUniformBuffer *dummy_sss_profile;
+
uint sss_count;
float alpha_hash_offset;
@@ -433,6 +435,11 @@ static void create_default_shader(int options)
MEM_freeN(frag_str);
}
+static void eevee_init_dummys(void)
+{
+ e_data.dummy_sss_profile = GPU_material_create_sss_profile_ubo();
+}
+
static void eevee_init_noise_texture(void)
{
e_data.noise_tex = DRW_texture_create_2D(64, 64, GPU_RGBA16F, 0, (float *)blue_noise);
@@ -621,6 +628,7 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E
eevee_init_util_texture();
eevee_init_noise_texture();
+ eevee_init_dummys();
}
if (!DRW_state_is_image_render() &&
@@ -1245,6 +1253,19 @@ static void material_opaque(
printf("Error: Too many different Subsurface shader in the scene.\n");
}
}
+ else {
+ if (use_translucency) {
+ /* NOTE: This is a nasty workaround, because the sss profile might not have been generated
+ * but the UBO is still declared in this case even if not used. But rendering without a
+ * bound UBO might result in crashes on certain platform. */
+ DRW_shgroup_uniform_block(*shgrp, "sssProfile", e_data.dummy_sss_profile);
+ }
+ }
+ }
+ else {
+ if (use_translucency) {
+ DRW_shgroup_uniform_block(*shgrp, "sssProfile", e_data.dummy_sss_profile);
+ }
}
break;
}
@@ -1776,6 +1797,7 @@ void EEVEE_materials_free(void)
DRW_SHADER_FREE_SAFE(e_data.update_noise_sh);
DRW_TEXTURE_FREE_SAFE(e_data.util_tex);
DRW_TEXTURE_FREE_SAFE(e_data.noise_tex);
+ DRW_UBO_FREE_SAFE(e_data.dummy_sss_profile);
}
void EEVEE_draw_default_passes(EEVEE_PassList *psl)
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index b724299935b..265ba15dc39 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -194,6 +194,7 @@ GPUMaterialStatus GPU_material_status(GPUMaterial *mat);
struct GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material);
void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs);
+struct GPUUniformBuffer *GPU_material_create_sss_profile_ubo(void);
void GPU_material_vertex_attributes(
GPUMaterial *material,
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 986003c99e6..fa267102088 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -568,6 +568,11 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material, int
return material->sss_profile;
}
+struct GPUUniformBuffer *GPU_material_create_sss_profile_ubo(void)
+{
+ return GPU_uniformbuffer_create(sizeof(GPUSssKernelData), NULL, NULL);
+}
+
#undef SSS_EXPONENT
#undef SSS_SAMPLES