Blender V5.0
eevee_cryptomatte.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
15
16#pragma once
17
18#include "DRW_gpu_wrapper.hh"
19
20#include "BKE_cryptomatte.hh"
21
22#include "draw_handle.hh"
23
24#include "eevee_defines.hh"
25
26extern "C" {
27struct Material;
28}
29
30namespace blender::eevee {
31
32using namespace draw;
33
34class Instance;
35
36/* -------------------------------------------------------------------- */
39
41 private:
42 class Instance &inst_;
43
44 using CryptomatteObjectBuf = draw::StorageArrayBuffer<float2, 16>;
45
47
48 /* Cached pointer to the cryptomatte layer instances. */
49 bke::cryptomatte::CryptomatteLayer *object_layer_ = nullptr;
50 bke::cryptomatte::CryptomatteLayer *asset_layer_ = nullptr;
51 bke::cryptomatte::CryptomatteLayer *material_layer_ = nullptr;
52
54 CryptomatteObjectBuf cryptomatte_object_buf;
55
56 public:
57 Cryptomatte(Instance &inst) : inst_(inst) {};
58
59 void begin_sync();
60 void sync_object(Object *ob, ResourceHandleRange res_handle);
61 void sync_material(const ::Material *material);
62 void end_sync();
63
64 template<typename PassType> void bind_resources(PassType &pass)
65 {
66 pass.bind_ssbo(CRYPTOMATTE_BUF_SLOT, &cryptomatte_object_buf);
67 }
68
69 /* Register ID to use inside cryptomatte layer and returns associated hash as float. */
70 float register_id(const eViewLayerEEVEEPassType layer, const ID &id) const;
71 void store_metadata(RenderResult *render_result);
72};
73
75
76} // namespace blender::eevee
eViewLayerEEVEEPassType
void bind_resources(PassType &pass)
float register_id(const eViewLayerEEVEEPassType layer, const ID &id) const
void store_metadata(RenderResult *render_result)
void sync_material(const ::Material *material)
void sync_object(Object *ob, ResourceHandleRange res_handle)
A running instance of the engine.
#define CRYPTOMATTE_BUF_SLOT
PassType
std::unique_ptr< CryptomatteSession, CryptomatteSessionDeleter > CryptomatteSessionPtr
Definition DNA_ID.h:414