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.
This commit is contained in:
parent
15ad75ffef
commit
2a0a7cd73d
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue