Blender V4.3
eevee_depth_of_field_info.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "eevee_defines.hh"
7
8/* -------------------------------------------------------------------- */
12GPU_SHADER_CREATE_INFO(eevee_depth_of_field_bokeh_lut)
13 .do_static_compilation(true)
14 .local_group_size(DOF_BOKEH_LUT_SIZE, DOF_BOKEH_LUT_SIZE)
15 .additional_info("eevee_shared", "draw_view")
16 .uniform_buf(6, "DepthOfFieldData", "dof_buf")
17 .image(0, GPU_RG16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_gather_lut_img")
18 .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_scatter_lut_img")
19 .image(2, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_resolve_lut_img")
20 .compute_source("eevee_depth_of_field_bokeh_lut_comp.glsl");
21
22GPU_SHADER_CREATE_INFO(eevee_depth_of_field_setup)
23 .do_static_compilation(true)
25 .additional_info("eevee_shared", "draw_view")
26 .uniform_buf(6, "DepthOfFieldData", "dof_buf")
27 .sampler(0, ImageType::FLOAT_2D, "color_tx")
28 .sampler(1, ImageType::DEPTH_2D, "depth_tx")
29 .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img")
30 .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_img")
31 .compute_source("eevee_depth_of_field_setup_comp.glsl");
32
33GPU_SHADER_CREATE_INFO(eevee_depth_of_field_stabilize)
34 .do_static_compilation(true)
36 .additional_info("eevee_shared", "draw_view", "eevee_velocity_camera")
37 .uniform_buf(6, "DepthOfFieldData", "dof_buf")
38 .sampler(0, ImageType::FLOAT_2D, "coc_tx")
39 .sampler(1, ImageType::FLOAT_2D, "color_tx")
40 .sampler(2, ImageType::FLOAT_2D, "velocity_tx")
41 .sampler(3, ImageType::FLOAT_2D, "in_history_tx")
42 .sampler(4, ImageType::DEPTH_2D, "depth_tx")
43 .push_constant(Type::BOOL, "u_use_history")
44 .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img")
45 .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_img")
46 .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_history_img")
47 .compute_source("eevee_depth_of_field_stabilize_comp.glsl");
48
49GPU_SHADER_CREATE_INFO(eevee_depth_of_field_downsample)
50 .do_static_compilation(true)
52 .additional_info("eevee_shared", "draw_view")
53 .sampler(0, ImageType::FLOAT_2D, "color_tx")
54 .sampler(1, ImageType::FLOAT_2D, "coc_tx")
55 .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img")
56 .compute_source("eevee_depth_of_field_downsample_comp.glsl");
57
58GPU_SHADER_CREATE_INFO(eevee_depth_of_field_reduce)
59 .do_static_compilation(true)
61 .additional_info("eevee_shared", "draw_view")
62 .uniform_buf(6, "DepthOfFieldData", "dof_buf")
63 .sampler(0, ImageType::FLOAT_2D, "downsample_tx")
64 .storage_buf(0, Qualifier::WRITE, "ScatterRect", "scatter_fg_list_buf[]")
65 .storage_buf(1, Qualifier::WRITE, "ScatterRect", "scatter_bg_list_buf[]")
66 .storage_buf(2, Qualifier::READ_WRITE, "DrawCommand", "scatter_fg_indirect_buf")
67 .storage_buf(3, Qualifier::READ_WRITE, "DrawCommand", "scatter_bg_indirect_buf")
68 .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "inout_color_lod0_img")
69 .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_lod1_img")
70 .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_lod2_img")
71 .image(3, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_lod3_img")
72 .image(4, GPU_R16F, Qualifier::READ, ImageType::FLOAT_2D, "in_coc_lod0_img")
73 .image(5, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_lod1_img")
74 .image(6, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_lod2_img")
75 .image(7, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_lod3_img")
76 .compute_source("eevee_depth_of_field_reduce_comp.glsl");
77
80/* -------------------------------------------------------------------- */
84GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_flatten)
85 .do_static_compilation(true)
87 .additional_info("eevee_shared", "draw_view")
88 .sampler(0, ImageType::FLOAT_2D, "coc_tx")
89 .image(2, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_fg_img")
90 .image(3, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_bg_img")
91 .compute_source("eevee_depth_of_field_tiles_flatten_comp.glsl");
92
93GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate)
94 .additional_info("eevee_shared", "draw_view", "eevee_depth_of_field_tiles_common")
96 .image(2, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_fg_img")
97 .image(3, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_bg_img")
98 .push_constant(Type::INT, "ring_count")
99 .push_constant(Type::INT, "ring_width_multiplier")
100 .compute_source("eevee_depth_of_field_tiles_dilate_comp.glsl");
101
102GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minabs)
103 .do_static_compilation(true)
104 .define("DILATE_MODE_MIN_MAX", "false")
105 .additional_info("eevee_depth_of_field_tiles_dilate");
106
107GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minmax)
108 .do_static_compilation(true)
109 .define("DILATE_MODE_MIN_MAX", "true")
110 .additional_info("eevee_depth_of_field_tiles_dilate");
111
113 .image(0, GPU_R11F_G11F_B10F, Qualifier::READ, ImageType::FLOAT_2D, "in_tiles_fg_img")
114 .image(1, GPU_R11F_G11F_B10F, Qualifier::READ, ImageType::FLOAT_2D, "in_tiles_bg_img");
115
118/* -------------------------------------------------------------------- */
123 .define("DOF_BOKEH_TEXTURE", "false")
128 .define("bokeh_lut_tx", "color_tx");
129
130GPU_SHADER_CREATE_INFO(eevee_depth_of_field_lut)
131 .define("DOF_BOKEH_TEXTURE", "true")
132 .sampler(5, ImageType::FLOAT_2D, "bokeh_lut_tx");
133
134GPU_SHADER_CREATE_INFO(eevee_depth_of_field_background).define("DOF_FOREGROUND_PASS", "false");
135GPU_SHADER_CREATE_INFO(eevee_depth_of_field_foreground).define("DOF_FOREGROUND_PASS", "true");
136
137#define EEVEE_DOF_FINAL_VARIATION(name, ...) \
138 GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true);
139
140#define EEVEE_DOF_LUT_VARIATIONS(prefix, ...) \
141 EEVEE_DOF_FINAL_VARIATION(prefix##_lut, "eevee_depth_of_field_lut", __VA_ARGS__) \
142 EEVEE_DOF_FINAL_VARIATION(prefix##_no_lut, "eevee_depth_of_field_no_lut", __VA_ARGS__)
143
144#define EEVEE_DOF_GROUND_VARIATIONS(name, ...) \
145 EEVEE_DOF_LUT_VARIATIONS(name##_background, "eevee_depth_of_field_background", __VA_ARGS__) \
146 EEVEE_DOF_LUT_VARIATIONS(name##_foreground, "eevee_depth_of_field_foreground", __VA_ARGS__)
147
150/* -------------------------------------------------------------------- */
154GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather_common)
155 .additional_info("eevee_shared",
156 "draw_view",
157 "eevee_depth_of_field_tiles_common",
158 "eevee_sampling_data")
159 .uniform_buf(6, "DepthOfFieldData", "dof_buf")
161 .sampler(0, ImageType::FLOAT_2D, "color_tx")
162 .sampler(1, ImageType::FLOAT_2D, "color_bilinear_tx")
163 .sampler(2, ImageType::FLOAT_2D, "coc_tx")
164 .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img")
165 .image(3, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_weight_img");
166
167GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather)
168 .image(4, GPU_RG16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_occlusion_img")
169 .compute_source("eevee_depth_of_field_gather_comp.glsl")
170 .additional_info("eevee_depth_of_field_gather_common");
171
172EEVEE_DOF_GROUND_VARIATIONS(eevee_depth_of_field_gather, "eevee_depth_of_field_gather")
173
174GPU_SHADER_CREATE_INFO(eevee_depth_of_field_hole_fill)
176 .compute_source("eevee_depth_of_field_hole_fill_comp.glsl")
177 .additional_info("eevee_depth_of_field_gather_common", "eevee_depth_of_field_no_lut");
178
179GPU_SHADER_CREATE_INFO(eevee_depth_of_field_filter)
183 .sampler(0, ImageType::FLOAT_2D, "color_tx")
184 .sampler(1, ImageType::FLOAT_2D, "weight_tx")
185 .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img")
186 .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_weight_img")
187 .compute_source("eevee_depth_of_field_filter_comp.glsl");
188
191/* -------------------------------------------------------------------- */
195GPU_SHADER_INTERFACE_INFO(eevee_depth_of_field_scatter_flat_iface, "interp_flat")
197 .flat(Type::VEC4, "color_and_coc1")
198 .flat(Type::VEC4, "color_and_coc2")
199 .flat(Type::VEC4, "color_and_coc3")
200 .flat(Type::VEC4, "color_and_coc4")
202 .flat(Type::FLOAT, "distance_scale");
203GPU_SHADER_INTERFACE_INFO(eevee_depth_of_field_scatter_noperspective_iface, "interp_noperspective")
205 .no_perspective(Type::VEC2, "rect_uv1")
206 .no_perspective(Type::VEC2, "rect_uv2")
207 .no_perspective(Type::VEC2, "rect_uv3")
208 .no_perspective(Type::VEC2, "rect_uv4");
209
210GPU_SHADER_CREATE_INFO(eevee_depth_of_field_scatter)
213 .sampler(0, ImageType::FLOAT_2D, "occlusion_tx")
214 .sampler(1, ImageType::FLOAT_2D, "bokeh_lut_tx")
216 .storage_buf(0, Qualifier::READ, "ScatterRect", "scatter_list_buf[]")
217 .fragment_out(0, Type::VEC4, "out_color")
218 .push_constant(Type::BOOL, "use_bokeh_lut")
219 .vertex_out(eevee_depth_of_field_scatter_flat_iface)
220 .vertex_out(eevee_depth_of_field_scatter_noperspective_iface)
221 .vertex_source("eevee_depth_of_field_scatter_vert.glsl")
222 .fragment_source("eevee_depth_of_field_scatter_frag.glsl");
223
226/* -------------------------------------------------------------------- */
230GPU_SHADER_CREATE_INFO(eevee_depth_of_field_resolve)
231 .define("DOF_RESOLVE_PASS", "true")
233 .specialization_constant(Type::BOOL, "do_debug_color", false)
238 .uniform_buf(6, "DepthOfFieldData", "dof_buf")
239 .sampler(0, ImageType::DEPTH_2D, "depth_tx")
240 .sampler(1, ImageType::FLOAT_2D, "color_tx")
241 .sampler(2, ImageType::FLOAT_2D, "color_bg_tx")
242 .sampler(3, ImageType::FLOAT_2D, "color_fg_tx")
243 .sampler(4, ImageType::FLOAT_2D, "color_hole_fill_tx")
244 .sampler(7, ImageType::FLOAT_2D, "weight_bg_tx")
245 .sampler(8, ImageType::FLOAT_2D, "weight_fg_tx")
246 .sampler(9, ImageType::FLOAT_2D, "weight_hole_fill_tx")
247 .sampler(10, ImageType::FLOAT_2D, "stable_color_tx")
248 .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img")
249 .compute_source("eevee_depth_of_field_resolve_comp.glsl");
250
251EEVEE_DOF_LUT_VARIATIONS(eevee_depth_of_field_resolve, "eevee_depth_of_field_resolve")
252
vertex_source("basic_depth_pointcloud_vert.glsl") .additional_info("draw_pointcloud")
output_img push_constant(Type::FLOAT, "subtrahend") .define("TYPE"
gbuf_header_tx eevee_sampling_data
direct_radiance_1_tx direct_radiance_3_tx indirect_radiance_2_tx radiance_feedback_img fragment_out(0, Type::VEC4, "out_combined") .additional_info("eevee_shared"
gbuf_header_tx eevee_shared
fragment_source("eevee_deferred_tile_classify_frag.glsl") .additional_info("eevee_shared"
#define DOF_DEFAULT_GROUP_SIZE
#define DOF_REDUCE_GROUP_SIZE
#define DOF_TILES_DILATE_GROUP_SIZE
#define DOF_FILTER_GROUP_SIZE
#define DOF_STABILIZE_GROUP_SIZE
#define DOF_BOKEH_LUT_SIZE
#define DOF_GATHER_GROUP_SIZE
#define DOF_RESOLVE_GROUP_SIZE
#define DOF_TILES_FLATTEN_GROUP_SIZE
flat(Type::VEC4, "color_and_coc1") .flat(Type no_perspective(Type::VEC2, "rect_uv1") .no_perspective(Type draw_view bokeh_lut_tx uniform_buf(6, "DepthOfFieldData", "dof_buf") .storage_buf(0
DOF_BOKEH_LUT_SIZE dof_buf GPU_R16F
DOF_BOKEH_LUT_SIZE additional_info("eevee_shared", "draw_view") .uniform_buf(6
DOF_RESOLVE_GROUP_SIZE specialization_constant(Type::BOOL, "do_debug_color", false) .additional_info("eevee_shared"
DOF_BOKEH_LUT_SIZE DepthOfFieldData
DOF_REDUCE_GROUP_SIZE dof_buf scatter_fg_list_buf[] storage_buf(1, Qualifier::WRITE, "ScatterRect", "scatter_bg_list_buf[]") .storage_buf(2
DOF_DEFAULT_GROUP_SIZE dof_buf sampler(0, ImageType::FLOAT_2D, "color_tx") .sampler(1
DOF_TILES_FLATTEN_GROUP_SIZE coc_tx GPU_R11F_G11F_B10F
#define EEVEE_DOF_LUT_VARIATIONS(prefix,...)
#define EEVEE_DOF_GROUND_VARIATIONS(name,...)
dof_buf color_tx coc_tx out_weight_img
dof_buf local_group_size(DOF_GATHER_GROUP_SIZE, DOF_GATHER_GROUP_SIZE) .sampler(0
do_static_compilation(true) .local_group_size(DOF_BOKEH_LUT_SIZE
DOF_DEFAULT_GROUP_SIZE dof_buf depth_tx out_coc_img compute_source("eevee_depth_of_field_setup_comp.glsl")
DOF_REDUCE_GROUP_SIZE dof_buf ScatterRect
DOF_RESOLVE_GROUP_SIZE eevee_depth_of_field_tiles_common
DOF_RESOLVE_GROUP_SIZE draw_view
DOF_STABILIZE_GROUP_SIZE dof_buf color_tx in_history_tx sampler(4, ImageType::DEPTH_2D, "depth_tx") .push_constant(Type DOF_DEFAULT_GROUP_SIZE color_tx GPU_RGBA16F
define("DOF_BOKEH_TEXTURE", "false") .define("bokeh_lut_tx"
out_color vertex_out(eevee_debug_irradiance_grid_iface) .sampler(0
no_perspective(Type::VEC2, "out_texel_xy")
#define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name)
#define GPU_SHADER_CREATE_INFO(_info)
@ FLOAT