diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-01-26 23:57:44 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-01-27 00:03:58 +0300 |
commit | 4226c484bdbe7336f1221094916fcdfb12850034 (patch) | |
tree | 33428e72be40105c222ca77935ee1554b702facc /source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc | |
parent | 55a6a8900aec81e94f4d82401d6051e3b5507c0e (diff) | |
parent | af87b6d8cb75d9d625378dee25d726a0d55f75c6 (diff) |
Merge branch 'draw-viewport-data' into eevee-rewrite
# Conflicts:
# release/scripts/startup/bl_ui/properties_data_camera.py
# source/blender/blenkernel/BKE_camera.h
# source/blender/blenkernel/BKE_node.h
# source/blender/blenkernel/intern/camera.c
# source/blender/blenlib/BLI_float2.hh
# source/blender/blenlib/BLI_float3.hh
# source/blender/blenlib/BLI_float4.hh
# source/blender/blenlib/BLI_math_geom.h
# source/blender/blenlib/intern/math_geom.c
# source/blender/draw/CMakeLists.txt
# source/blender/draw/engines/basic/basic_engine.c
# source/blender/draw/engines/eevee/eevee_cryptomatte.c
# source/blender/draw/engines/eevee/eevee_effects.c
# source/blender/draw/engines/eevee/eevee_engine.c
# source/blender/draw/engines/eevee/eevee_lightcache.c
# source/blender/draw/engines/eevee/eevee_lightcache.h
# source/blender/draw/engines/eevee/eevee_lightprobes.c
# source/blender/draw/engines/eevee/eevee_lights.c
# source/blender/draw/engines/eevee/eevee_materials.c
# source/blender/draw/engines/eevee/eevee_motion_blur.c
# source/blender/draw/engines/eevee/eevee_occlusion.c
# source/blender/draw/engines/eevee/eevee_private.h
# source/blender/draw/engines/eevee/eevee_render.c
# source/blender/draw/engines/eevee/eevee_renderpasses.c
# source/blender/draw/engines/eevee/eevee_sampling.c
# source/blender/draw/engines/eevee/eevee_screen_raytrace.c
# source/blender/draw/engines/eevee/eevee_shaders.c
# source/blender/draw/engines/eevee/eevee_shadows.c
# source/blender/draw/engines/eevee/eevee_shadows_cube.c
# source/blender/draw/engines/eevee/eevee_temporal_sampling.c
# source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
# source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
# source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
# source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
# source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
# source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl
# source/blender/draw/engines/eevee/shaders/effect_reflection_resolve_frag.glsl
# source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
# source/blender/draw/engines/eevee/shaders/random_lib.glsl
# source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
# source/blender/draw/engines/eevee/shaders/surface_lib.glsl
# source/blender/draw/engines/eevee/shaders/surface_vert.glsl
# source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
# source/blender/draw/engines/external/external_engine.c
# source/blender/draw/engines/gpencil/gpencil_engine.c
# source/blender/draw/engines/image/image_engine.c
# source/blender/draw/engines/overlay/overlay_engine.c
# source/blender/draw/engines/select/select_engine.c
# source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
# source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl
# source/blender/draw/engines/workbench/workbench_engine.c
# source/blender/draw/engines/workbench/workbench_shader.c
# source/blender/draw/intern/DRW_render.h
# source/blender/draw/intern/draw_debug.h
# source/blender/draw/intern/draw_manager_data.c
# source/blender/draw/intern/draw_manager_exec.c
# source/blender/draw/intern/draw_view_data.h
# source/blender/gpu/CMakeLists.txt
# source/blender/gpu/GPU_material.h
# source/blender/gpu/GPU_shader.h
# source/blender/gpu/GPU_state.h
# source/blender/gpu/GPU_vertex_buffer.h
# source/blender/gpu/intern/gpu_codegen.c
# source/blender/gpu/intern/gpu_material.c
# source/blender/gpu/intern/gpu_material_library.h
# source/blender/gpu/intern/gpu_node_graph.c
# source/blender/gpu/intern/gpu_texture_private.hh
# source/blender/gpu/intern/gpu_vertex_buffer.cc
# source/blender/gpu/opengl/gl_shader.cc
# source/blender/gpu/shaders/gpu_shader_common_obinfos_lib.glsl
# source/blender/gpu/shaders/material/gpu_shader_material_shader_to_rgba.glsl
# source/blender/nodes/shader/node_shader_tree.cc
# source/blender/nodes/shader/nodes/node_shader_background.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
# source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
# source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc
# source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc
# source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc
# source/blender/nodes/shader/nodes/node_shader_emission.cc
# source/blender/nodes/shader/nodes/node_shader_holdout.cc
# source/blender/nodes/shader/nodes/node_shader_output_material.cc
# source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
# source/blender/nodes/shader/nodes/node_shader_tex_coord.cc
# source/blender/nodes/shader/nodes/node_shader_vector_transform.cc
# source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc
# source/blender/nodes/shader/nodes/node_shader_volume_principled.cc
# source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc
# source/blender/render/RE_pipeline.h
# source/blender/render/intern/initrender.c
Diffstat (limited to 'source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc')
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc | 102 |
1 files changed, 60 insertions, 42 deletions
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc index 6657267b016..40b467d608a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc @@ -38,8 +38,10 @@ #include <optional> +/* -------------------------------------------------------------------- */ /** \name Cryptomatte * \{ */ + static blender::bke::cryptomatte::CryptomatteSessionPtr cryptomatte_init_from_node_render( const bNode &node, const bool use_meta_data) { @@ -134,8 +136,7 @@ static void cryptomatte_add(const Scene &scene, return; } - CryptomatteEntry *entry = static_cast<CryptomatteEntry *>( - MEM_callocN(sizeof(CryptomatteEntry), __func__)); + CryptomatteEntry *entry = MEM_cnew<CryptomatteEntry>(__func__); entry->encoded_hash = encoded_hash; blender::bke::cryptomatte::CryptomatteSessionPtr session = cryptomatte_init_from_node( scene, node, true); @@ -156,16 +157,6 @@ static void cryptomatte_remove(NodeCryptomatte &n, float encoded_hash) MEM_freeN(entry); } -static bNodeSocketTemplate cmp_node_cryptomatte_in[] = { - {SOCK_RGBA, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f}, {-1, ""}}; - -static bNodeSocketTemplate cmp_node_cryptomatte_out[] = { - {SOCK_RGBA, N_("Image")}, - {SOCK_FLOAT, N_("Matte")}, - {SOCK_RGBA, N_("Pick")}, - {-1, ""}, -}; - void ntreeCompositCryptomatteSyncFromAdd(const Scene *scene, bNode *node) { BLI_assert(ELEM(node->type, CMP_NODE_CRYPTOMATTE, CMP_NODE_CRYPTOMATTE_LEGACY)); @@ -197,8 +188,7 @@ void ntreeCompositCryptomatteUpdateLayerNames(const Scene *scene, bNode *node) if (session) { for (blender::StringRef layer_name : blender::bke::cryptomatte::BKE_cryptomatte_layer_names_get(*session)) { - CryptomatteLayer *layer = static_cast<CryptomatteLayer *>( - MEM_callocN(sizeof(CryptomatteLayer), __func__)); + CryptomatteLayer *layer = MEM_cnew<CryptomatteLayer>(__func__); layer_name.copy(layer->name); BLI_addtail(&n->runtime.layers, layer); } @@ -241,10 +231,21 @@ CryptomatteSession *ntreeCompositCryptomatteSession(const Scene *scene, bNode *n return session_ptr.release(); } +namespace blender::nodes::node_composite_cryptomatte_cc { + +static bNodeSocketTemplate cmp_node_cryptomatte_in[] = { + {SOCK_RGBA, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f}, {-1, ""}}; + +static bNodeSocketTemplate cmp_node_cryptomatte_out[] = { + {SOCK_RGBA, N_("Image")}, + {SOCK_FLOAT, N_("Matte")}, + {SOCK_RGBA, N_("Pick")}, + {-1, ""}, +}; + static void node_init_cryptomatte(bNodeTree *UNUSED(ntree), bNode *node) { - NodeCryptomatte *user = static_cast<NodeCryptomatte *>( - MEM_callocN(sizeof(NodeCryptomatte), __func__)); + NodeCryptomatte *user = MEM_cnew<NodeCryptomatte>(__func__); node->storage = user; } @@ -297,44 +298,40 @@ static bool node_poll_cryptomatte(bNodeType *UNUSED(ntype), } if (scene == nullptr) { - *r_disabled_hint = - "The node tree must be the compositing node tree of any scene in the file"; + *r_disabled_hint = TIP_( + "The node tree must be the compositing node tree of any scene in the file"); } return scene != nullptr; } - *r_disabled_hint = "Not a compositor node tree"; + *r_disabled_hint = TIP_("Not a compositor node tree"); return false; } -void register_node_type_cmp_cryptomatte(void) +} // namespace blender::nodes::node_composite_cryptomatte_cc + +void register_node_type_cmp_cryptomatte() { + namespace file_ns = blender::nodes::node_composite_cryptomatte_cc; + static bNodeType ntype; - cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE, "Cryptomatte", NODE_CLASS_MATTE, 0); - node_type_socket_templates(&ntype, cmp_node_cryptomatte_in, cmp_node_cryptomatte_out); + cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE, "Cryptomatte", NODE_CLASS_MATTE); + node_type_socket_templates( + &ntype, file_ns::cmp_node_cryptomatte_in, file_ns::cmp_node_cryptomatte_out); node_type_size(&ntype, 240, 100, 700); - node_type_init(&ntype, node_init_cryptomatte); - ntype.initfunc_api = node_init_api_cryptomatte; - ntype.poll = node_poll_cryptomatte; - node_type_storage(&ntype, "NodeCryptomatte", node_free_cryptomatte, node_copy_cryptomatte); + node_type_init(&ntype, file_ns::node_init_cryptomatte); + ntype.initfunc_api = file_ns::node_init_api_cryptomatte; + ntype.poll = file_ns::node_poll_cryptomatte; + node_type_storage( + &ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte); nodeRegisterType(&ntype); } /** \} */ +/* -------------------------------------------------------------------- */ /** \name Cryptomatte Legacy * \{ */ -static void node_init_cryptomatte_legacy(bNodeTree *ntree, bNode *node) -{ - node_init_cryptomatte(ntree, node); - - nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, "image", "Image"); - - /* Add three inputs by default, as recommended by the Cryptomatte specification. */ - ntreeCompositCryptomatteAddSocket(ntree, node); - ntreeCompositCryptomatteAddSocket(ntree, node); - ntreeCompositCryptomatteAddSocket(ntree, node); -} bNodeSocket *ntreeCompositCryptomatteAddSocket(bNodeTree *ntree, bNode *node) { @@ -361,14 +358,35 @@ int ntreeCompositCryptomatteRemoveSocket(bNodeTree *ntree, bNode *node) return 1; } -void register_node_type_cmp_cryptomatte_legacy(void) +namespace blender::nodes::node_composite_cryptomatte_cc { + +static void node_init_cryptomatte_legacy(bNodeTree *ntree, bNode *node) +{ + namespace file_ns = blender::nodes::node_composite_cryptomatte_cc; + file_ns::node_init_cryptomatte(ntree, node); + + nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, "image", "Image"); + + /* Add three inputs by default, as recommended by the Cryptomatte specification. */ + ntreeCompositCryptomatteAddSocket(ntree, node); + ntreeCompositCryptomatteAddSocket(ntree, node); + ntreeCompositCryptomatteAddSocket(ntree, node); +} + +} // namespace blender::nodes::node_composite_cryptomatte_cc + +void register_node_type_cmp_cryptomatte_legacy() { + namespace legacy_file_ns = blender::nodes::node_composite_cryptomatte_cc; + namespace file_ns = blender::nodes::node_composite_cryptomatte_cc; + static bNodeType ntype; - cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE_LEGACY, "Cryptomatte", NODE_CLASS_MATTE, 0); - node_type_socket_templates(&ntype, nullptr, cmp_node_cryptomatte_out); - node_type_init(&ntype, node_init_cryptomatte_legacy); - node_type_storage(&ntype, "NodeCryptomatte", node_free_cryptomatte, node_copy_cryptomatte); + cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE_LEGACY, "Cryptomatte", NODE_CLASS_MATTE); + node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_cryptomatte_out); + node_type_init(&ntype, file_ns::node_init_cryptomatte_legacy); + node_type_storage( + &ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte); nodeRegisterType(&ntype); } |