Blender V4.3
eevee_depth_of_field.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
20#pragma once
21
23
24namespace blender::eevee {
25
26class Instance;
27
28/* -------------------------------------------------------------------- */
42
44 private:
45 class Instance &inst_;
46
48 GPUTexture *input_color_tx_ = nullptr;
49 GPUTexture *output_color_tx_ = nullptr;
50
52 TextureFromPool bokeh_gather_lut_tx_ = {"dof_bokeh_gather_lut"};
53 TextureFromPool bokeh_resolve_lut_tx_ = {"dof_bokeh_resolve_lut"};
54 TextureFromPool bokeh_scatter_lut_tx_ = {"dof_bokeh_scatter_lut"};
55 PassSimple bokeh_lut_ps_ = {"BokehLut"};
56
58 TextureFromPool setup_coc_tx_ = {"dof_setup_coc"};
59 TextureFromPool setup_color_tx_ = {"dof_setup_color"};
60 int3 dispatch_setup_size_ = int3(-1);
61 PassSimple setup_ps_ = {"Setup"};
62
64 Texture reduced_coc_tx_ = {"dof_reduced_coc"};
65 Texture reduced_color_tx_ = {"dof_reduced_color"};
66
68 TextureFromPool stabilize_output_tx_ = {"dof_taa"};
69 GPUTexture *stabilize_input_ = nullptr;
70 bool32_t stabilize_valid_history_ = false;
71 int3 dispatch_stabilize_size_ = int3(-1);
72 PassSimple stabilize_ps_ = {"Stabilize"};
73
75 TextureFromPool downsample_tx_ = {"dof_downsample"};
76 int3 dispatch_downsample_size_ = int3(-1);
77 PassSimple downsample_ps_ = {"Downsample"};
78
80 DepthOfFieldScatterListBuf scatter_fg_list_buf_;
81 DepthOfFieldScatterListBuf scatter_bg_list_buf_;
82 DrawIndirectBuf scatter_fg_indirect_buf_;
83 DrawIndirectBuf scatter_bg_indirect_buf_;
84 int3 dispatch_reduce_size_ = int3(-1);
85 PassSimple reduce_ps_ = {"Reduce"};
86
90 int3 dispatch_tiles_flatten_size_ = int3(-1);
91 PassSimple tiles_flatten_ps_ = {"TilesFlatten"};
92
94 int tiles_dilate_ring_count_ = -1;
95 int tiles_dilate_ring_width_mul_ = -1;
96 int3 dispatch_tiles_dilate_size_ = int3(-1);
97 PassSimple tiles_dilate_minmax_ps_ = {"TilesDilateMinmax"};
98 PassSimple tiles_dilate_minabs_ps_ = {"TilesDilateMinabs"};
99
103 SwapChain<TextureFromPool, 2> weight_bg_tx_;
104 SwapChain<TextureFromPool, 2> weight_fg_tx_;
105 TextureFromPool occlusion_tx_ = {"dof_occlusion"};
106 int3 dispatch_gather_size_ = int3(-1);
107 PassSimple gather_fg_ps_ = {"GatherFg"};
108 PassSimple gather_bg_ps_ = {"GatherBg"};
109
111 TextureFromPool hole_fill_color_tx_ = {"dof_color_hole_fill"};
112 TextureFromPool hole_fill_weight_tx_ = {"dof_weight_hole_fill"};
113 PassSimple hole_fill_ps_ = {"HoleFill"};
114
116 int3 dispatch_filter_size_ = int3(-1);
117 PassSimple filter_fg_ps_ = {"FilterFg"};
118 PassSimple filter_bg_ps_ = {"FilterBg"};
119
121 Framebuffer scatter_fg_fb_ = {"dof_scatter_fg"};
122 Framebuffer scatter_bg_fb_ = {"dof_scatter_bg"};
123 PassSimple scatter_fg_ps_ = {"ScatterFg"};
124 PassSimple scatter_bg_ps_ = {"ScatterBg"};
125
127 GPUTexture *resolve_stable_color_tx_ = nullptr;
128 int3 dispatch_resolve_size_ = int3(-1);
129 PassSimple resolve_ps_ = {"Resolve"};
130
132
134 float user_overblur_;
135 float fx_max_coc_;
137 bool do_jitter_;
139 bool use_bokeh_lut_;
140
142 float fx_radius_;
144 float jitter_radius_;
146 float focus_distance_;
148 int2 extent_;
149
150 public:
151 DepthOfField(Instance &inst) : inst_(inst){};
153
154 void init();
155
156 void sync();
157
161 void jitter_apply(float4x4 &winmat, float4x4 &viewmat);
162
167 void render(View &view,
168 GPUTexture **input_tx,
169 GPUTexture **output_tx,
170 DepthOfFieldBuffer &dof_buffer);
171
172 bool postfx_enabled() const
173 {
174 return fx_radius_ > 0.0f;
175 }
176
177 private:
178 void bokeh_lut_pass_sync();
179 void setup_pass_sync();
180 void stabilize_pass_sync();
181 void downsample_pass_sync();
182 void reduce_pass_sync();
183 void tiles_flatten_pass_sync();
184 void tiles_dilate_pass_sync();
185 void gather_pass_sync();
186 void filter_pass_sync();
187 void scatter_pass_sync();
188 void hole_fill_pass_sync();
189 void resolve_pass_sync();
190
195 void update_sample_table();
196};
197
200} // namespace blender::eevee
int32_t bool32_t
void jitter_apply(float4x4 &winmat, float4x4 &viewmat)
A running instance of the engine.
VecBase< int32_t, 3 > int3