Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee_next/eevee_cryptomatte.hh
- This file was added.
| /* SPDX-License-Identifier: GPL-2.0-or-later | ||||||||||||||||||
| * Copyright 2021 Blender Foundation. | ||||||||||||||||||
| */ | ||||||||||||||||||
| /** \file | ||||||||||||||||||
| * \ingroup eevee | ||||||||||||||||||
| * | ||||||||||||||||||
| * Cryptomatte. | ||||||||||||||||||
| * | ||||||||||||||||||
| * During rasterization, cryptomatte hashes are stored into a single array texture. | ||||||||||||||||||
| * The film pass then resamples this texture using pixel filter weighting. | ||||||||||||||||||
| * Each cryptomatte layer can hold N samples. These are stored in sequential layers | ||||||||||||||||||
| * of the array texture. The samples are sorted and merged only for final rendering. | ||||||||||||||||||
| */ | ||||||||||||||||||
fclemUnsubmitted Done Inline Actions
fclem: | ||||||||||||||||||
| #pragma once | ||||||||||||||||||
| #include "eevee_shader_shared.hh" | ||||||||||||||||||
| #include "BKE_cryptomatte.hh" | ||||||||||||||||||
| extern "C" { | ||||||||||||||||||
| struct Material; | ||||||||||||||||||
| struct CryptomatteSession; | ||||||||||||||||||
| } | ||||||||||||||||||
| namespace blender::eevee { | ||||||||||||||||||
| class Instance; | ||||||||||||||||||
| /* -------------------------------------------------------------------- */ | ||||||||||||||||||
| /** \name Cryptomatte | ||||||||||||||||||
| * \{ */ | ||||||||||||||||||
| class Cryptomatte { | ||||||||||||||||||
| private: | ||||||||||||||||||
| class Instance &inst_; | ||||||||||||||||||
| bke::cryptomatte::CryptomatteSessionPtr session_; | ||||||||||||||||||
| /* Cached pointer to the cryptomatte layer instances. */ | ||||||||||||||||||
| bke::cryptomatte::CryptomatteLayer *object_layer_ = nullptr; | ||||||||||||||||||
| bke::cryptomatte::CryptomatteLayer *asset_layer_ = nullptr; | ||||||||||||||||||
Done Inline Actionsseems to be unused fclem: seems to be unused | ||||||||||||||||||
Done Inline ActionsWill use a different way to store the data. This isn't how it is actually used anymore. jbakker: Will use a different way to store the data. This isn't how it is actually used anymore. | ||||||||||||||||||
| bke::cryptomatte::CryptomatteLayer *material_layer_ = nullptr; | ||||||||||||||||||
| /** Contains per object hashes (object and asset hash). Indexed by resource ID. */ | ||||||||||||||||||
Done Inline Actions
fclem: | ||||||||||||||||||
| CryptomatteObjectBuf cryptomatte_object_buf; | ||||||||||||||||||
Done Inline Actions
I think I would prefer if it was inside the Film structure instead. Avoiding fragmentation. Leaving this Cryptomatte struct for object data. fclem: I think I would prefer if it was inside the `Film` structure instead. Avoiding fragmentation. | ||||||||||||||||||
Done Inline ActionsYes, was already thinking of doing that. The current code separation is not clean. jbakker: Yes, was already thinking of doing that. The current code separation is not clean. | ||||||||||||||||||
| public: | ||||||||||||||||||
| Cryptomatte(Instance &inst) : inst_(inst){}; | ||||||||||||||||||
| void begin_sync(); | ||||||||||||||||||
| void sync_object(Object *ob, ResourceHandle res_handle); | ||||||||||||||||||
| void sync_material(const ::Material *material); | ||||||||||||||||||
| void end_sync(); | ||||||||||||||||||
| template<typename T> void bind_resources(draw::detail::PassBase<T> *pass) | ||||||||||||||||||
| { | ||||||||||||||||||
| pass->bind_ssbo(CRYPTOMATTE_BUF_SLOT, &cryptomatte_object_buf); | ||||||||||||||||||
| } | ||||||||||||||||||
| /* Register ID to use inside cryptomatte layer and returns associated hash as float. */ | ||||||||||||||||||
| float register_id(const eViewLayerEEVEEPassType layer, const ID &id) const; | ||||||||||||||||||
| void store_metadata(RenderResult *render_result); | ||||||||||||||||||
| }; | ||||||||||||||||||
| /** \} */ | ||||||||||||||||||
| } // namespace blender::eevee | ||||||||||||||||||