diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-12 14:56:48 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-12 14:58:14 +0300 |
commit | 092cbacd8f5d5ca52141f3e052c4853e6b90419f (patch) | |
tree | 51465e6e35ae18c45b9bf6f1c594093936d29623 /source/blender/draw | |
parent | 2e8089b6bf50f50bd552d10962a877884c552a22 (diff) |
Fix T98026 EEVEE: Refression Crash when rendering Cryptomatte passes
This was because the main `surface_vert.glsl` was changed to accomodate the
needs of the `ShaderCreateInfo` but was still used by the cryptomatte
shader. The fix is to include the same libraries as the material shaders
and bypass `attrib_load()`.
Diffstat (limited to 'source/blender/draw')
4 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index ed90e77572e..1ff7585165b 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -333,6 +333,7 @@ set(GLSL_SRC engines/eevee/shaders/renderpass_lib.glsl engines/eevee/shaders/renderpass_postprocess_frag.glsl engines/eevee/shaders/cryptomatte_frag.glsl + engines/eevee/shaders/cryptomatte_vert.glsl engines/eevee/shaders/ltc_lib.glsl engines/eevee/shaders/ssr_lib.glsl engines/eevee/shaders/surface_frag.glsl diff --git a/source/blender/draw/engines/eevee/eevee_cryptomatte.c b/source/blender/draw/engines/eevee/eevee_cryptomatte.c index 50302eaa87a..b17efe4b68d 100644 --- a/source/blender/draw/engines/eevee/eevee_cryptomatte.c +++ b/source/blender/draw/engines/eevee/eevee_cryptomatte.c @@ -189,11 +189,8 @@ void EEVEE_cryptomatte_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat } } -static DRWShadingGroup *eevee_cryptomatte_shading_group_create(EEVEE_Data *vedata, - EEVEE_ViewLayerData *UNUSED(sldata), - Object *ob, - Material *material, - bool is_hair) +static DRWShadingGroup *eevee_cryptomatte_shading_group_create( + EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob, Material *material, bool is_hair) { const DRWContextState *draw_ctx = DRW_context_state_get(); const ViewLayer *view_layer = draw_ctx->view_layer; @@ -229,6 +226,7 @@ static DRWShadingGroup *eevee_cryptomatte_shading_group_create(EEVEE_Data *vedat DRWShadingGroup *grp = DRW_shgroup_create(EEVEE_shaders_cryptomatte_sh_get(is_hair), psl->cryptomatte_ps); DRW_shgroup_uniform_vec4_copy(grp, "cryptohash", cryptohash); + DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo); return grp; } diff --git a/source/blender/draw/engines/eevee/eevee_shaders.c b/source/blender/draw/engines/eevee/eevee_shaders.c index 85cc7f65126..105600d2333 100644 --- a/source/blender/draw/engines/eevee/eevee_shaders.c +++ b/source/blender/draw/engines/eevee/eevee_shaders.c @@ -183,6 +183,7 @@ extern char datatoc_closure_eval_volume_lib_glsl[]; extern char datatoc_common_uniforms_lib_glsl[]; extern char datatoc_common_utiltex_lib_glsl[]; extern char datatoc_cryptomatte_frag_glsl[]; +extern char datatoc_cryptomatte_vert_glsl[]; extern char datatoc_cubemap_lib_glsl[]; extern char datatoc_default_frag_glsl[]; extern char datatoc_lookdev_world_frag_glsl[]; @@ -305,6 +306,7 @@ static void eevee_shader_library_ensure(void) DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_refraction_lib); DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_surface_lib); DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_volume_lib); + DRW_SHADER_LIB_ADD(e_data.lib, surface_vert); e_data.surface_lit_frag = DRW_shader_library_create_shader_string(e_data.lib, datatoc_surface_frag_glsl); @@ -718,7 +720,7 @@ GPUShader *EEVEE_shaders_cryptomatte_sh_get(bool is_hair) if (e_data.cryptomatte_sh[index] == NULL) { DynStr *ds = BLI_dynstr_new(); BLI_dynstr_append(ds, SHADER_DEFINES); - + BLI_dynstr_append(ds, "#define attrib_load(a) \n"); if (is_hair) { BLI_dynstr_append(ds, "#define HAIR_SHADER\n"); } @@ -727,7 +729,7 @@ GPUShader *EEVEE_shaders_cryptomatte_sh_get(bool is_hair) } char *defines = BLI_dynstr_get_cstring(ds); e_data.cryptomatte_sh[index] = DRW_shader_create_with_shaderlib( - datatoc_surface_vert_glsl, NULL, datatoc_cryptomatte_frag_glsl, e_data.lib, defines); + datatoc_cryptomatte_vert_glsl, NULL, datatoc_cryptomatte_frag_glsl, e_data.lib, defines); BLI_dynstr_free(ds); MEM_freeN(defines); } diff --git a/source/blender/draw/engines/eevee/shaders/cryptomatte_vert.glsl b/source/blender/draw/engines/eevee/shaders/cryptomatte_vert.glsl new file mode 100644 index 00000000000..f8dbc4772e9 --- /dev/null +++ b/source/blender/draw/engines/eevee/shaders/cryptomatte_vert.glsl @@ -0,0 +1,6 @@ + +#pragma BLENDER_REQUIRE(closure_type_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) +#pragma BLENDER_REQUIRE(common_math_lib.glsl) +#pragma BLENDER_REQUIRE(common_attribute_lib.glsl) +#pragma BLENDER_REQUIRE(surface_vert.glsl) |