Blender V4.5
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
19
20#pragma once
21
23
24namespace blender::eevee {
25
26class Instance;
27
28/* -------------------------------------------------------------------- */
31
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_ = 0.0f;
135 float fx_max_coc_ = 0.0f;
137 bool do_jitter_ = false;
139 bool use_bokeh_lut_ = false;
140
142 float fx_radius_ = 0.0f;
144 float jitter_radius_ = 0.0f;
146 float focus_distance_ = 0.0f;
148 int2 extent_ = int2(0);
149
150 bool enabled_ = false;
151
152 public:
153 DepthOfField(Instance &inst) : inst_(inst){};
155
156 void init();
157
158 void sync();
159
163 void jitter_apply(float4x4 &winmat, float4x4 &viewmat);
164
169 void render(View &view,
170 GPUTexture **input_tx,
171 GPUTexture **output_tx,
172 DepthOfFieldBuffer &dof_buffer);
173
174 bool postfx_enabled() const
175 {
176 return fx_radius_ > 0.0f;
177 }
178
179 bool enabled() const
180 {
181 return enabled_;
182 }
183
184 private:
185 void bokeh_lut_pass_sync();
186 void setup_pass_sync();
187 void stabilize_pass_sync();
188 void downsample_pass_sync();
189 void reduce_pass_sync();
190 void tiles_flatten_pass_sync();
191 void tiles_dilate_pass_sync();
192 void gather_pass_sync();
193 void filter_pass_sync();
194 void scatter_pass_sync();
195 void hole_fill_pass_sync();
196 void resolve_pass_sync();
197
202 void update_sample_table();
203};
204
206
207} // namespace blender::eevee
static AppView * view
int32_t bool32_t
void jitter_apply(float4x4 &winmat, float4x4 &viewmat)
A running instance of the engine.
detail::Pass< command::DrawCommandBuf > PassSimple
draw::UniformBuffer< DepthOfFieldData > DepthOfFieldDataBuf
draw::StorageBuffer< DrawCommand, true > DrawIndirectBuf
draw::StorageArrayBuffer< ScatterRect, 16, true > DepthOfFieldScatterListBuf
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< int32_t, 3 > int3