Blender V5.0
eevee_depth_of_field_infos.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#ifdef GPU_SHADER
6# pragma once
8
9# include "gpu_shader_compat.hh"
10
11# include "draw_view_infos.hh"
12# include "eevee_common_infos.hh"
15
16# define DOF_BOKEH_TEXTURE true
17# define DILATE_MODE_MIN_MAX true
18#endif
19
20#include "eevee_defines.hh"
22
23GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_common)
24IMAGE(0, UFLOAT_11_11_10, read, image2D, in_tiles_fg_img)
25IMAGE(1, UFLOAT_11_11_10, read, image2D, in_tiles_bg_img)
27
28/* -------------------------------------------------------------------- */
31
32GPU_SHADER_CREATE_INFO(eevee_depth_of_field_bokeh_lut)
35TYPEDEF_SOURCE("eevee_defines.hh")
36TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
37ADDITIONAL_INFO(draw_view)
38UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
39IMAGE(0, SFLOAT_16_16, write, image2D, out_gather_lut_img)
40IMAGE(1, SFLOAT_16, write, image2D, out_scatter_lut_img)
41IMAGE(2, SFLOAT_16, write, image2D, out_resolve_lut_img)
42COMPUTE_SOURCE("eevee_depth_of_field_bokeh_lut_comp.glsl")
44
45GPU_SHADER_CREATE_INFO(eevee_depth_of_field_setup)
48TYPEDEF_SOURCE("eevee_defines.hh")
49TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
50ADDITIONAL_INFO(draw_view)
51UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
52SAMPLER(0, sampler2D, color_tx)
53SAMPLER(1, sampler2DDepth, depth_tx)
54IMAGE(0, SFLOAT_16_16_16_16, write, image2D, out_color_img)
55IMAGE(1, SFLOAT_16, write, image2D, out_coc_img)
56COMPUTE_SOURCE("eevee_depth_of_field_setup_comp.glsl")
58
59GPU_SHADER_CREATE_INFO(eevee_depth_of_field_stabilize)
62TYPEDEF_SOURCE("eevee_defines.hh")
63TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
64ADDITIONAL_INFO(draw_view)
65ADDITIONAL_INFO(eevee_velocity_camera)
66UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
67SAMPLER(0, sampler2D, coc_tx)
68SAMPLER(1, sampler2D, color_tx)
69SAMPLER(2, sampler2D, velocity_tx)
70SAMPLER(3, sampler2D, in_history_tx)
71SAMPLER(4, sampler2DDepth, depth_tx)
72PUSH_CONSTANT(bool, u_use_history)
73IMAGE(0, SFLOAT_16_16_16_16, write, image2D, out_color_img)
74IMAGE(1, SFLOAT_16, write, image2D, out_coc_img)
75IMAGE(2, SFLOAT_16_16_16_16, write, image2D, out_history_img)
76COMPUTE_SOURCE("eevee_depth_of_field_stabilize_comp.glsl")
78
79GPU_SHADER_CREATE_INFO(eevee_depth_of_field_downsample)
82TYPEDEF_SOURCE("eevee_defines.hh")
83TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
84ADDITIONAL_INFO(draw_view)
85SAMPLER(0, sampler2D, color_tx)
86SAMPLER(1, sampler2D, coc_tx)
87IMAGE(0, SFLOAT_16_16_16_16, write, image2D, out_color_img)
88COMPUTE_SOURCE("eevee_depth_of_field_downsample_comp.glsl")
90
91GPU_SHADER_CREATE_INFO(eevee_depth_of_field_reduce)
94TYPEDEF_SOURCE("eevee_defines.hh")
95TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
96ADDITIONAL_INFO(draw_view)
97UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
98SAMPLER(0, sampler2D, downsample_tx)
99STORAGE_BUF(0, write, ScatterRect, scatter_fg_list_buf[])
100STORAGE_BUF(1, write, ScatterRect, scatter_bg_list_buf[])
101STORAGE_BUF(2, read_write, DrawCommand, scatter_fg_indirect_buf)
102STORAGE_BUF(3, read_write, DrawCommand, scatter_bg_indirect_buf)
103IMAGE(0, SFLOAT_16_16_16_16, read_write, image2D, inout_color_lod0_img)
104IMAGE(1, SFLOAT_16_16_16_16, write, image2D, out_color_lod1_img)
105IMAGE(2, SFLOAT_16_16_16_16, write, image2D, out_color_lod2_img)
106IMAGE(3, SFLOAT_16_16_16_16, write, image2D, out_color_lod3_img)
107IMAGE(4, SFLOAT_16, read, image2D, in_coc_lod0_img)
108IMAGE(5, SFLOAT_16, write, image2D, out_coc_lod1_img)
109IMAGE(6, SFLOAT_16, write, image2D, out_coc_lod2_img)
110IMAGE(7, SFLOAT_16, write, image2D, out_coc_lod3_img)
111COMPUTE_SOURCE("eevee_depth_of_field_reduce_comp.glsl")
113
115
116/* -------------------------------------------------------------------- */
119
120GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_flatten)
123TYPEDEF_SOURCE("eevee_defines.hh")
124TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
125ADDITIONAL_INFO(draw_view)
126SAMPLER(0, sampler2D, coc_tx)
127IMAGE(2, UFLOAT_11_11_10, write, image2D, out_tiles_fg_img)
128IMAGE(3, UFLOAT_11_11_10, write, image2D, out_tiles_bg_img)
129COMPUTE_SOURCE("eevee_depth_of_field_tiles_flatten_comp.glsl")
131
132GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate)
133TYPEDEF_SOURCE("eevee_defines.hh")
134TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
135ADDITIONAL_INFO(draw_view)
136ADDITIONAL_INFO(eevee_depth_of_field_tiles_common)
138IMAGE(2, UFLOAT_11_11_10, write, image2D, out_tiles_fg_img)
139IMAGE(3, UFLOAT_11_11_10, write, image2D, out_tiles_bg_img)
140PUSH_CONSTANT(int, ring_count)
141PUSH_CONSTANT(int, ring_width_multiplier)
142COMPUTE_SOURCE("eevee_depth_of_field_tiles_dilate_comp.glsl")
144
145GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minabs)
147DEFINE_VALUE("DILATE_MODE_MIN_MAX", "false")
148ADDITIONAL_INFO(eevee_depth_of_field_tiles_dilate)
150
151GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minmax)
153DEFINE_VALUE("DILATE_MODE_MIN_MAX", "true")
154ADDITIONAL_INFO(eevee_depth_of_field_tiles_dilate)
156
158
159/* -------------------------------------------------------------------- */
162
163GPU_SHADER_CREATE_INFO(eevee_depth_of_field_no_lut)
164DEFINE_VALUE("DOF_BOKEH_TEXTURE", "false")
169DEFINE_VALUE("bokeh_lut_tx", "color_tx")
171
172GPU_SHADER_CREATE_INFO(eevee_depth_of_field_lut)
173DEFINE_VALUE("DOF_BOKEH_TEXTURE", "true")
174SAMPLER(5, sampler2D, bokeh_lut_tx)
176
177GPU_SHADER_CREATE_INFO(eevee_depth_of_field_background)
178DEFINE_VALUE("DOF_FOREGROUND_PASS", "false")
180GPU_SHADER_CREATE_INFO(eevee_depth_of_field_foreground)
181DEFINE_VALUE("DOF_FOREGROUND_PASS", "true")
183
184#define EEVEE_DOF_LUT_VARIATIONS(prefix, ...) \
185 CREATE_INFO_VARIANT(prefix##_lut, eevee_depth_of_field_lut, __VA_ARGS__) \
186 CREATE_INFO_VARIANT(prefix##_no_lut, eevee_depth_of_field_no_lut, __VA_ARGS__)
187
188#define EEVEE_DOF_GROUND_VARIATIONS(name, ...) \
189 EEVEE_DOF_LUT_VARIATIONS(name##_background, eevee_depth_of_field_background, __VA_ARGS__) \
190 EEVEE_DOF_LUT_VARIATIONS(name##_foreground, eevee_depth_of_field_foreground, __VA_ARGS__)
191
193
194/* -------------------------------------------------------------------- */
197
198GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather_common)
199TYPEDEF_SOURCE("eevee_defines.hh")
200TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
201ADDITIONAL_INFO(draw_view)
202ADDITIONAL_INFO(eevee_depth_of_field_tiles_common)
203ADDITIONAL_INFO(eevee_sampling_data)
204UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
206SAMPLER(0, sampler2D, color_tx)
207SAMPLER(1, sampler2D, color_bilinear_tx)
208SAMPLER(2, sampler2D, coc_tx)
209IMAGE(2, SFLOAT_16_16_16_16, write, image2D, out_color_img)
210IMAGE(3, SFLOAT_16, write, image2D, out_weight_img)
212
213GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather)
214IMAGE(4, SFLOAT_16_16, write, image2D, out_occlusion_img)
215COMPUTE_SOURCE("eevee_depth_of_field_gather_comp.glsl")
216ADDITIONAL_INFO(eevee_depth_of_field_gather_common)
218
219EEVEE_DOF_GROUND_VARIATIONS(eevee_depth_of_field_gather, eevee_depth_of_field_gather)
220
221GPU_SHADER_CREATE_INFO(eevee_depth_of_field_hole_fill)
223COMPUTE_SOURCE("eevee_depth_of_field_hole_fill_comp.glsl")
224ADDITIONAL_INFO(eevee_depth_of_field_gather_common)
225ADDITIONAL_INFO(eevee_depth_of_field_no_lut)
227
228GPU_SHADER_CREATE_INFO(eevee_depth_of_field_filter)
231TYPEDEF_SOURCE("eevee_defines.hh")
232TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
233SAMPLER(0, sampler2D, color_tx)
234SAMPLER(1, sampler2D, weight_tx)
235IMAGE(0, SFLOAT_16_16_16_16, write, image2D, out_color_img)
236IMAGE(1, SFLOAT_16, write, image2D, out_weight_img)
237COMPUTE_SOURCE("eevee_depth_of_field_filter_comp.glsl")
239
241
242/* -------------------------------------------------------------------- */
245
246GPU_SHADER_NAMED_INTERFACE_INFO(eevee_depth_of_field_scatter_flat_iface, interp_flat)
248FLAT(float4, color_and_coc1)
249FLAT(float4, color_and_coc2)
250FLAT(float4, color_and_coc3)
251FLAT(float4, color_and_coc4)
253FLAT(float, distance_scale)
255GPU_SHADER_NAMED_INTERFACE_INFO(eevee_depth_of_field_scatter_noperspective_iface,
256 interp_noperspective)
258NO_PERSPECTIVE(float2, rect_uv1)
259NO_PERSPECTIVE(float2, rect_uv2)
260NO_PERSPECTIVE(float2, rect_uv3)
261NO_PERSPECTIVE(float2, rect_uv4)
262GPU_SHADER_NAMED_INTERFACE_END(interp_noperspective)
263
264GPU_SHADER_CREATE_INFO(eevee_depth_of_field_scatter)
266TYPEDEF_SOURCE("eevee_defines.hh")
267TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
268ADDITIONAL_INFO(draw_view)
269SAMPLER(0, sampler2D, occlusion_tx)
270SAMPLER(1, sampler2D, bokeh_lut_tx)
271UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
272STORAGE_BUF(0, read, ScatterRect, scatter_list_buf[])
273FRAGMENT_OUT(0, float4, out_color)
274PUSH_CONSTANT(bool, use_bokeh_lut)
275VERTEX_OUT(eevee_depth_of_field_scatter_flat_iface)
276VERTEX_OUT(eevee_depth_of_field_scatter_noperspective_iface)
277VERTEX_SOURCE("eevee_depth_of_field_scatter_vert.glsl")
278FRAGMENT_SOURCE("eevee_depth_of_field_scatter_frag.glsl")
280
282
283/* -------------------------------------------------------------------- */
286
287GPU_SHADER_CREATE_INFO(eevee_depth_of_field_resolve)
288DEFINE_VALUE("DOF_RESOLVE_PASS", "true")
290SPECIALIZATION_CONSTANT(bool, do_debug_color, false)
291TYPEDEF_SOURCE("eevee_defines.hh")
292TYPEDEF_SOURCE("eevee_depth_of_field_shared.hh")
293ADDITIONAL_INFO(draw_view)
294ADDITIONAL_INFO(eevee_depth_of_field_tiles_common)
295ADDITIONAL_INFO(eevee_sampling_data)
296UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
297SAMPLER(0, sampler2DDepth, depth_tx)
298SAMPLER(1, sampler2D, color_tx)
299SAMPLER(2, sampler2D, color_bg_tx)
300SAMPLER(3, sampler2D, color_fg_tx)
301SAMPLER(4, sampler2D, color_hole_fill_tx)
302SAMPLER(7, sampler2D, weight_bg_tx)
303SAMPLER(8, sampler2D, weight_fg_tx)
304SAMPLER(9, sampler2D, weight_hole_fill_tx)
305SAMPLER(10, sampler2D, stable_color_tx)
306IMAGE(2, SFLOAT_16_16_16_16, write, image2D, out_color_img)
307COMPUTE_SOURCE("eevee_depth_of_field_resolve_comp.glsl")
309
310EEVEE_DOF_LUT_VARIATIONS(eevee_depth_of_field_resolve, eevee_depth_of_field_resolve)
311
#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
#define EEVEE_DOF_LUT_VARIATIONS(prefix,...)
#define EEVEE_DOF_GROUND_VARIATIONS(name,...)
#define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name)
#define GPU_SHADER_NAMED_INTERFACE_END(_inst_name)
#define GPU_SHADER_CREATE_INFO(_info)
#define GPU_SHADER_CREATE_END()
#define TYPEDEF_SOURCE(filename)
#define VERTEX_OUT(stage_interface)
#define SAMPLER(slot, type, name)
#define UNIFORM_BUF(slot, type_name, name)
#define FRAGMENT_SOURCE(filename)
#define SPECIALIZATION_CONSTANT(type, name, default_value)
#define ADDITIONAL_INFO(info_name)
#define PUSH_CONSTANT(type, name)
#define FLAT(type, name)
#define FRAGMENT_OUT(slot, type, name)
#define NO_PERSPECTIVE(type, name)
#define STORAGE_BUF(slot, qualifiers, type_name, name)
#define VERTEX_SOURCE(filename)
#define LOCAL_GROUP_SIZE(...)
#define IMAGE(slot, format, qualifiers, type, name)
#define COMPUTE_SOURCE(filename)
#define DO_STATIC_COMPILATION()
#define DEFINE_VALUE(name, value)
ImageBase< float, 2 > image2D
SamplerBase< float, 2, false, false, false, true > sampler2DDepth
SamplerBase< float, 2 > sampler2D