Blender V5.0
pass.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include <iosfwd>
8
9#include "util/string.h"
11
12#include "kernel/types.h"
13
14#include "graph/node.h"
15
17
18const char *pass_type_as_string(const PassType type);
19
20enum class PassMode {
23};
24const char *pass_mode_as_string(PassMode mode);
25std::ostream &operator<<(std::ostream &os, PassMode mode);
26
27struct PassInfo {
29 bool use_filter = false;
30 bool use_exposure = false;
31 bool is_written = true;
32 float scale = 1.0f;
36
37 /* Pass access for read can not happen directly and needs some sort of compositing (for example,
38 * light passes due to divide_type, or shadow catcher pass. */
39 bool use_compositing = false;
40
41 /* Used to disable albedo pass for denoising.
42 * Light and shadow catcher passes should not have discontinuity in the denoised result based on
43 * the underlying albedo. */
45
46 /* Pass supports denoising. */
47 bool support_denoise = false;
48};
49
50class Pass : public Node {
51 public:
53
56 NODE_SOCKET_API(ustring, name)
57 NODE_SOCKET_API(bool, include_albedo)
58 NODE_SOCKET_API(ustring, lightgroup)
59
60 Pass();
61
62 PassInfo get_info() const;
63
64 /* The pass is written by the render pipeline (kernel or denoiser). If the pass is written it
65 * will have pixels allocated in a RenderBuffer. Passes which are not written do not have their
66 * pixels allocated to save memory. */
67 bool is_written() const;
68
69 protected:
70 /* This has been created automatically as a requirement to various rendering functionality
71 * (such as adaptive sampling). */
73
74 public:
75 static const NodeEnum *get_type_enum();
76 static const NodeEnum *get_mode_enum();
77
79 const PassMode mode = PassMode::DENOISED,
80 const bool include_albedo = false,
81 const bool is_lightgroup = false);
82
83 static bool contains(const unique_ptr_vector<Pass> &passes, PassType type);
84
85 /* Returns nullptr if there is no pass with the given name or type+mode. */
86 static const Pass *find(const unique_ptr_vector<Pass> &passes, const string &name);
87 static const Pass *find(const unique_ptr_vector<Pass> &passes,
90 const ustring &lightgroup = ustring());
91
92 /* Returns PASS_UNUSED if there is no corresponding pass. */
93 static int get_offset(const unique_ptr_vector<Pass> &passes, const Pass *pass);
94
95 friend class Film;
96};
97
98std::ostream &operator<<(std::ostream &os, const Pass &pass);
99
100bool is_volume_guiding_pass(const PassType pass_type);
101
Definition pass.h:50
static const Pass * find(const unique_ptr_vector< Pass > &passes, const string &name)
Definition pass.cpp:413
PassInfo get_info() const
Definition pass.cpp:146
static int get_offset(const unique_ptr_vector< Pass > &passes, const Pass *pass)
Definition pass.cpp:441
static bool contains(const unique_ptr_vector< Pass > &passes, PassType type)
Definition pass.cpp:400
friend class Film
Definition pass.h:95
static const NodeEnum * get_type_enum()
Definition pass.cpp:45
NODE_DECLARE Pass()
Definition pass.cpp:144
bool is_written() const
Definition pass.cpp:151
static const NodeEnum * get_mode_enum()
Definition pass.cpp:116
bool is_auto_
Definition pass.h:72
#define CCL_NAMESPACE_END
#define NODE_SOCKET_API(type_, name)
Definition graph/node.h:55
PassType
@ PASS_NONE
#define NODE_DECLARE
Definition node_type.h:145
const char * pass_mode_as_string(PassMode mode)
Definition pass.cpp:26
PassMode
Definition pass.h:20
@ DENOISED
Definition pass.h:22
@ NOISY
Definition pass.h:21
CCL_NAMESPACE_BEGIN const char * pass_type_as_string(const PassType type)
Definition pass.cpp:12
std::ostream & operator<<(std::ostream &os, PassMode mode)
Definition pass.cpp:39
bool is_volume_guiding_pass(const PassType pass_type)
Definition pass.cpp:474
const NodeType * type
Definition graph/node.h:178
ustring name
Definition graph/node.h:177
Node(const NodeType *type, ustring name=ustring())
PassType direct_type
Definition pass.h:34
bool use_compositing
Definition pass.h:39
bool use_denoising_albedo
Definition pass.h:44
int num_components
Definition pass.h:28
float scale
Definition pass.h:32
bool support_denoise
Definition pass.h:47
bool use_filter
Definition pass.h:29
PassType divide_type
Definition pass.h:33
bool use_exposure
Definition pass.h:30
PassType indirect_type
Definition pass.h:35
bool is_written
Definition pass.h:31