diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-08-01 15:42:25 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-08-01 16:00:47 +0300 |
commit | e9586b14b736a4a91226437d1b4e8a576bc05794 (patch) | |
tree | f7a92ca4698eafdabd7cd597cf81d71baf7b737d | |
parent | 55c5eb33126dbf58621981b0e2ce1279bff1f835 (diff) |
Eevee: Add support of rendering curves with cryptomatte.
There were 2 errors.
1. hair code was used to draw curves
2. vertex shader wasn't aware of curves and failed to compile.
6 files changed, 27 insertions, 1 deletions
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 9744f2e3cee..30352d3d19c 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -339,6 +339,7 @@ set(GLSL_SRC engines/eevee/shaders/raytrace_lib.glsl engines/eevee/shaders/renderpass_lib.glsl engines/eevee/shaders/renderpass_postprocess_frag.glsl + engines/eevee/shaders/cryptomatte_lib.glsl engines/eevee/shaders/cryptomatte_frag.glsl engines/eevee/shaders/cryptomatte_vert.glsl engines/eevee/shaders/ltc_lib.glsl diff --git a/source/blender/draw/engines/eevee/eevee_cryptomatte.c b/source/blender/draw/engines/eevee/eevee_cryptomatte.c index 53ea66bdea0..2f4a201637f 100644 --- a/source/blender/draw/engines/eevee/eevee_cryptomatte.c +++ b/source/blender/draw/engines/eevee/eevee_cryptomatte.c @@ -249,7 +249,9 @@ void EEVEE_cryptomatte_object_curves_cache_populate(EEVEE_Data *vedata, { BLI_assert(ob->type == OB_CURVES); Material *material = BKE_object_material_get_eval(ob, CURVES_MATERIAL_NR); - eevee_cryptomatte_curves_cache_populate(vedata, sldata, ob, NULL, NULL, material); + DRWShadingGroup *grp = eevee_cryptomatte_shading_group_create( + vedata, sldata, ob, material, true); + DRW_shgroup_curves_create_sub(ob, grp, NULL); } void EEVEE_cryptomatte_particle_hair_cache_populate(EEVEE_Data *vedata, diff --git a/source/blender/draw/engines/eevee/eevee_shaders.c b/source/blender/draw/engines/eevee/eevee_shaders.c index 5709621fc05..e7b6cd636ae 100644 --- a/source/blender/draw/engines/eevee/eevee_shaders.c +++ b/source/blender/draw/engines/eevee/eevee_shaders.c @@ -181,6 +181,7 @@ extern char datatoc_closure_type_lib_glsl[]; 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_lib_glsl[]; extern char datatoc_cryptomatte_frag_glsl[]; extern char datatoc_cryptomatte_vert_glsl[]; extern char datatoc_cubemap_lib_glsl[]; @@ -304,6 +305,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, cryptomatte_lib); DRW_SHADER_LIB_ADD(e_data.lib, surface_vert); e_data.surface_lit_frag = DRW_shader_library_create_shader_string(e_data.lib, diff --git a/source/blender/draw/engines/eevee/shaders/cryptomatte_lib.glsl b/source/blender/draw/engines/eevee/shaders/cryptomatte_lib.glsl new file mode 100644 index 00000000000..0f8810ff7ac --- /dev/null +++ b/source/blender/draw/engines/eevee/shaders/cryptomatte_lib.glsl @@ -0,0 +1,19 @@ +/* NOTE: this lib is included in the cryptomatte vertex shader to work around the issue that eevee + * cannot use create infos for its static shaders. Keep in sync with draw_shader_shared.h */ +#ifdef HAIR_SHADER +/* Define the maximum number of attribute we allow in a curves UBO. + * This should be kept in sync with `GPU_ATTR_MAX` */ +# define DRW_ATTRIBUTE_PER_CURVES_MAX 15 + +struct CurvesInfos { + /* Per attribute scope, follows loading order. + * NOTE: uint as bool in GLSL is 4 bytes. + * NOTE: GLSL pad arrays of scalar to 16 bytes (std140). */ + uvec4 is_point_attribute[DRW_ATTRIBUTE_PER_CURVES_MAX]; +}; +layout(std140) uniform drw_curves +{ + CurvesInfos _drw_curves; +}; +# define drw_curves (_drw_curves) +#endif diff --git a/source/blender/draw/engines/eevee/shaders/cryptomatte_vert.glsl b/source/blender/draw/engines/eevee/shaders/cryptomatte_vert.glsl index f8dbc4772e9..14fbc98469a 100644 --- a/source/blender/draw/engines/eevee/shaders/cryptomatte_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/cryptomatte_vert.glsl @@ -3,4 +3,5 @@ #pragma BLENDER_REQUIRE(common_view_lib.glsl) #pragma BLENDER_REQUIRE(common_math_lib.glsl) #pragma BLENDER_REQUIRE(common_attribute_lib.glsl) +#pragma BLENDER_REQUIRE(cryptomatte_lib.glsl) #pragma BLENDER_REQUIRE(surface_vert.glsl) diff --git a/source/blender/gpu/intern/gpu_shader_log.cc b/source/blender/gpu/intern/gpu_shader_log.cc index 572727fa515..dbc36c5afd0 100644 --- a/source/blender/gpu/intern/gpu_shader_log.cc +++ b/source/blender/gpu/intern/gpu_shader_log.cc @@ -228,6 +228,7 @@ void Shader::print_log(Span<const char *> sources, log_line = line_end + 1; previous_location = log_item.cursor; } + // printf("%s", sources_combined); MEM_freeN(sources_combined); CLG_Severity severity = error ? CLG_SEVERITY_ERROR : CLG_SEVERITY_WARN; |