Blender V4.5
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#ifdef GPU_SHADER
6# pragma once
8
9# include "gpu_glsl_cpp_stubs.hh"
10
11# include "draw_view_info.hh"
12# include "eevee_common_info.hh"
13# include "eevee_shader_shared.hh"
14# include "eevee_velocity_info.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, GPU_R11F_G11F_B10F, read, image2D, in_tiles_fg_img)
25IMAGE(1, GPU_R11F_G11F_B10F, read, image2D, in_tiles_bg_img)
27
28/* -------------------------------------------------------------------- */
31
32GPU_SHADER_CREATE_INFO(eevee_depth_of_field_bokeh_lut)
35ADDITIONAL_INFO(eevee_shared)
36ADDITIONAL_INFO(draw_view)
37UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
38IMAGE(0, GPU_RG16F, write, image2D, out_gather_lut_img)
39IMAGE(1, GPU_R16F, write, image2D, out_scatter_lut_img)
40IMAGE(2, GPU_R16F, write, image2D, out_resolve_lut_img)
41COMPUTE_SOURCE("eevee_depth_of_field_bokeh_lut_comp.glsl")
43
44GPU_SHADER_CREATE_INFO(eevee_depth_of_field_setup)
47ADDITIONAL_INFO(eevee_shared)
48ADDITIONAL_INFO(draw_view)
49UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
50SAMPLER(0, sampler2D, color_tx)
51SAMPLER(1, sampler2DDepth, depth_tx)
52IMAGE(0, GPU_RGBA16F, write, image2D, out_color_img)
53IMAGE(1, GPU_R16F, write, image2D, out_coc_img)
54COMPUTE_SOURCE("eevee_depth_of_field_setup_comp.glsl")
56
57GPU_SHADER_CREATE_INFO(eevee_depth_of_field_stabilize)
60ADDITIONAL_INFO(eevee_shared)
61ADDITIONAL_INFO(draw_view)
62ADDITIONAL_INFO(eevee_velocity_camera)
63UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
64SAMPLER(0, sampler2D, coc_tx)
65SAMPLER(1, sampler2D, color_tx)
66SAMPLER(2, sampler2D, velocity_tx)
67SAMPLER(3, sampler2D, in_history_tx)
68SAMPLER(4, sampler2DDepth, depth_tx)
69PUSH_CONSTANT(bool, u_use_history)
70IMAGE(0, GPU_RGBA16F, write, image2D, out_color_img)
71IMAGE(1, GPU_R16F, write, image2D, out_coc_img)
72IMAGE(2, GPU_RGBA16F, write, image2D, out_history_img)
73COMPUTE_SOURCE("eevee_depth_of_field_stabilize_comp.glsl")
75
76GPU_SHADER_CREATE_INFO(eevee_depth_of_field_downsample)
79ADDITIONAL_INFO(eevee_shared)
80ADDITIONAL_INFO(draw_view)
81SAMPLER(0, sampler2D, color_tx)
82SAMPLER(1, sampler2D, coc_tx)
83IMAGE(0, GPU_RGBA16F, write, image2D, out_color_img)
84COMPUTE_SOURCE("eevee_depth_of_field_downsample_comp.glsl")
86
87GPU_SHADER_CREATE_INFO(eevee_depth_of_field_reduce)
90ADDITIONAL_INFO(eevee_shared)
91ADDITIONAL_INFO(draw_view)
92UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
93SAMPLER(0, sampler2D, downsample_tx)
94STORAGE_BUF(0, write, ScatterRect, scatter_fg_list_buf[])
95STORAGE_BUF(1, write, ScatterRect, scatter_bg_list_buf[])
96STORAGE_BUF(2, read_write, DrawCommand, scatter_fg_indirect_buf)
97STORAGE_BUF(3, read_write, DrawCommand, scatter_bg_indirect_buf)
98IMAGE(0, GPU_RGBA16F, read_write, image2D, inout_color_lod0_img)
99IMAGE(1, GPU_RGBA16F, write, image2D, out_color_lod1_img)
100IMAGE(2, GPU_RGBA16F, write, image2D, out_color_lod2_img)
101IMAGE(3, GPU_RGBA16F, write, image2D, out_color_lod3_img)
102IMAGE(4, GPU_R16F, read, image2D, in_coc_lod0_img)
103IMAGE(5, GPU_R16F, write, image2D, out_coc_lod1_img)
104IMAGE(6, GPU_R16F, write, image2D, out_coc_lod2_img)
105IMAGE(7, GPU_R16F, write, image2D, out_coc_lod3_img)
106COMPUTE_SOURCE("eevee_depth_of_field_reduce_comp.glsl")
108
110
111/* -------------------------------------------------------------------- */
114
115GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_flatten)
118ADDITIONAL_INFO(eevee_shared)
119ADDITIONAL_INFO(draw_view)
120SAMPLER(0, sampler2D, coc_tx)
121IMAGE(2, GPU_R11F_G11F_B10F, write, image2D, out_tiles_fg_img)
122IMAGE(3, GPU_R11F_G11F_B10F, write, image2D, out_tiles_bg_img)
123COMPUTE_SOURCE("eevee_depth_of_field_tiles_flatten_comp.glsl")
125
126GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate)
127ADDITIONAL_INFO(eevee_shared)
128ADDITIONAL_INFO(draw_view)
129ADDITIONAL_INFO(eevee_depth_of_field_tiles_common)
131IMAGE(2, GPU_R11F_G11F_B10F, write, image2D, out_tiles_fg_img)
132IMAGE(3, GPU_R11F_G11F_B10F, write, image2D, out_tiles_bg_img)
133PUSH_CONSTANT(int, ring_count)
134PUSH_CONSTANT(int, ring_width_multiplier)
135COMPUTE_SOURCE("eevee_depth_of_field_tiles_dilate_comp.glsl")
137
138GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minabs)
140DEFINE_VALUE("DILATE_MODE_MIN_MAX", "false")
141ADDITIONAL_INFO(eevee_depth_of_field_tiles_dilate)
143
144GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minmax)
146DEFINE_VALUE("DILATE_MODE_MIN_MAX", "true")
147ADDITIONAL_INFO(eevee_depth_of_field_tiles_dilate)
149
151
152/* -------------------------------------------------------------------- */
155
156GPU_SHADER_CREATE_INFO(eevee_depth_of_field_no_lut)
157DEFINE_VALUE("DOF_BOKEH_TEXTURE", "false")
162DEFINE_VALUE("bokeh_lut_tx", "color_tx")
164
165GPU_SHADER_CREATE_INFO(eevee_depth_of_field_lut)
166DEFINE_VALUE("DOF_BOKEH_TEXTURE", "true")
167SAMPLER(5, sampler2D, bokeh_lut_tx)
169
170GPU_SHADER_CREATE_INFO(eevee_depth_of_field_background)
171DEFINE_VALUE("DOF_FOREGROUND_PASS", "false")
173GPU_SHADER_CREATE_INFO(eevee_depth_of_field_foreground)
174DEFINE_VALUE("DOF_FOREGROUND_PASS", "true")
176
177#define EEVEE_DOF_LUT_VARIATIONS(prefix, ...) \
178 CREATE_INFO_VARIANT(prefix##_lut, eevee_depth_of_field_lut, __VA_ARGS__) \
179 CREATE_INFO_VARIANT(prefix##_no_lut, eevee_depth_of_field_no_lut, __VA_ARGS__)
180
181#define EEVEE_DOF_GROUND_VARIATIONS(name, ...) \
182 EEVEE_DOF_LUT_VARIATIONS(name##_background, eevee_depth_of_field_background, __VA_ARGS__) \
183 EEVEE_DOF_LUT_VARIATIONS(name##_foreground, eevee_depth_of_field_foreground, __VA_ARGS__)
184
186
187/* -------------------------------------------------------------------- */
190
191GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather_common)
192ADDITIONAL_INFO(eevee_shared)
193ADDITIONAL_INFO(draw_view)
194ADDITIONAL_INFO(eevee_depth_of_field_tiles_common)
195ADDITIONAL_INFO(eevee_sampling_data)
196UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
198SAMPLER(0, sampler2D, color_tx)
199SAMPLER(1, sampler2D, color_bilinear_tx)
200SAMPLER(2, sampler2D, coc_tx)
201IMAGE(2, GPU_RGBA16F, write, image2D, out_color_img)
202IMAGE(3, GPU_R16F, write, image2D, out_weight_img)
204
205GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather)
206IMAGE(4, GPU_RG16F, write, image2D, out_occlusion_img)
207COMPUTE_SOURCE("eevee_depth_of_field_gather_comp.glsl")
208ADDITIONAL_INFO(eevee_depth_of_field_gather_common)
210
211EEVEE_DOF_GROUND_VARIATIONS(eevee_depth_of_field_gather, eevee_depth_of_field_gather)
212
213GPU_SHADER_CREATE_INFO(eevee_depth_of_field_hole_fill)
215COMPUTE_SOURCE("eevee_depth_of_field_hole_fill_comp.glsl")
216ADDITIONAL_INFO(eevee_depth_of_field_gather_common)
217ADDITIONAL_INFO(eevee_depth_of_field_no_lut)
219
220GPU_SHADER_CREATE_INFO(eevee_depth_of_field_filter)
223ADDITIONAL_INFO(eevee_shared)
224SAMPLER(0, sampler2D, color_tx)
225SAMPLER(1, sampler2D, weight_tx)
226IMAGE(0, GPU_RGBA16F, write, image2D, out_color_img)
227IMAGE(1, GPU_R16F, write, image2D, out_weight_img)
228COMPUTE_SOURCE("eevee_depth_of_field_filter_comp.glsl")
230
232
233/* -------------------------------------------------------------------- */
236
237GPU_SHADER_NAMED_INTERFACE_INFO(eevee_depth_of_field_scatter_flat_iface, interp_flat)
239FLAT(float4, color_and_coc1)
240FLAT(float4, color_and_coc2)
241FLAT(float4, color_and_coc3)
242FLAT(float4, color_and_coc4)
244FLAT(float, distance_scale)
246GPU_SHADER_NAMED_INTERFACE_INFO(eevee_depth_of_field_scatter_noperspective_iface,
247 interp_noperspective)
249NO_PERSPECTIVE(float2, rect_uv1)
250NO_PERSPECTIVE(float2, rect_uv2)
251NO_PERSPECTIVE(float2, rect_uv3)
252NO_PERSPECTIVE(float2, rect_uv4)
253GPU_SHADER_NAMED_INTERFACE_END(interp_noperspective)
254
255GPU_SHADER_CREATE_INFO(eevee_depth_of_field_scatter)
257ADDITIONAL_INFO(eevee_shared)
258ADDITIONAL_INFO(draw_view)
259SAMPLER(0, sampler2D, occlusion_tx)
260SAMPLER(1, sampler2D, bokeh_lut_tx)
261UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
262STORAGE_BUF(0, read, ScatterRect, scatter_list_buf[])
263FRAGMENT_OUT(0, float4, out_color)
264PUSH_CONSTANT(bool, use_bokeh_lut)
265VERTEX_OUT(eevee_depth_of_field_scatter_flat_iface)
266VERTEX_OUT(eevee_depth_of_field_scatter_noperspective_iface)
267VERTEX_SOURCE("eevee_depth_of_field_scatter_vert.glsl")
268FRAGMENT_SOURCE("eevee_depth_of_field_scatter_frag.glsl")
270
272
273/* -------------------------------------------------------------------- */
276
277GPU_SHADER_CREATE_INFO(eevee_depth_of_field_resolve)
278DEFINE_VALUE("DOF_RESOLVE_PASS", "true")
280SPECIALIZATION_CONSTANT(bool, do_debug_color, false)
281ADDITIONAL_INFO(eevee_shared)
282ADDITIONAL_INFO(draw_view)
283ADDITIONAL_INFO(eevee_depth_of_field_tiles_common)
284ADDITIONAL_INFO(eevee_sampling_data)
285UNIFORM_BUF(6, DepthOfFieldData, dof_buf)
286SAMPLER(0, sampler2DDepth, depth_tx)
287SAMPLER(1, sampler2D, color_tx)
288SAMPLER(2, sampler2D, color_bg_tx)
289SAMPLER(3, sampler2D, color_fg_tx)
290SAMPLER(4, sampler2D, color_hole_fill_tx)
291SAMPLER(7, sampler2D, weight_bg_tx)
292SAMPLER(8, sampler2D, weight_fg_tx)
293SAMPLER(9, sampler2D, weight_hole_fill_tx)
294SAMPLER(10, sampler2D, stable_color_tx)
295IMAGE(2, GPU_RGBA16F, write, image2D, out_color_img)
296COMPUTE_SOURCE("eevee_depth_of_field_resolve_comp.glsl")
298
299EEVEE_DOF_LUT_VARIATIONS(eevee_depth_of_field_resolve, eevee_depth_of_field_resolve)
300
@ GPU_RG16F
@ GPU_R16F
@ GPU_RGBA16F
@ GPU_R11F_G11F_B10F
#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,...)
VecBase< float, 4 > float4
ImageBase< float, 2 > image2D
SamplerBase< float, 2, false, false, false, true > sampler2DDepth
SamplerBase< float, 2 > sampler2D
#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 GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name)
#define FLAT(type, name)
#define GPU_SHADER_NAMED_INTERFACE_END(_inst_name)
#define FRAGMENT_OUT(slot, type, name)
#define NO_PERSPECTIVE(type, name)
#define STORAGE_BUF(slot, qualifiers, type_name, name)
#define GPU_SHADER_CREATE_INFO(_info)
#define VERTEX_SOURCE(filename)
#define LOCAL_GROUP_SIZE(...)
#define IMAGE(slot, format, qualifiers, type, name)
#define GPU_SHADER_CREATE_END()
#define COMPUTE_SOURCE(filename)
#define DO_STATIC_COMPILATION()
#define DEFINE_VALUE(name, value)
read