Blender V5.3
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#include "eevee_sync.hh"
26
27namespace blender {
28
29extern "C" {
30struct Material;
31}
32
33namespace eevee {
34
35using namespace draw;
36
37class Instance;
38
39/* -------------------------------------------------------------------- */
42
44 private:
45 class Instance &inst_;
46
47 using CryptomatteObjectBuf = draw::StorageArrayBuffer<float2, 16>;
48
50
51 /* Cached pointer to the cryptomatte layer instances. */
52 bke::cryptomatte::CryptomatteLayer *object_layer_ = nullptr;
53 bke::cryptomatte::CryptomatteLayer *asset_layer_ = nullptr;
54 bke::cryptomatte::CryptomatteLayer *material_layer_ = nullptr;
55
57 CryptomatteObjectBuf cryptomatte_object_buf;
58
59 public:
60 Cryptomatte(Instance &inst) : inst_(inst) {};
61
62 void begin_sync();
63 void sync_object(const ObjectHandle &ob_handle);
64 void sync_material(const blender::Material *material);
65 void end_sync();
66
67 template<typename PassType> void bind_resources(PassType &pass)
68 {
69 pass.bind_ssbo(CRYPTOMATTE_BUF_SLOT, &cryptomatte_object_buf);
70 }
71
72 /* Register ID to use inside cryptomatte layer and returns associated hash as float. */
73 float register_id(const eViewLayerEEVEEPassType layer, const ID &id) const;
74 void store_metadata(RenderResult *render_result);
75};
76
78
79} // namespace eevee
80} // namespace blender
void sync_material(const blender::Material *material)
void bind_resources(PassType &pass)
float register_id(const eViewLayerEEVEEPassType layer, const ID &id) const
void store_metadata(RenderResult *render_result)
void sync_object(const ObjectHandle &ob_handle)
A running instance of the engine.
#define CRYPTOMATTE_BUF_SLOT
#define layer
PassType
std::unique_ptr< CryptomatteSession, CryptomatteSessionDeleter > CryptomatteSessionPtr
BMesh Iterators.