1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
#include "gpu_shader_create_info.hh"
/* -------------------------------------------------------------------- */
/** \name Setup
* \{ */
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_bokeh_lut)
.do_static_compilation(true)
.additional_info("eevee_shared")
.uniform_buf(0, "DepthOfFieldData", "dof_buf")
.fragment_out(0, Type::VEC2, "out_gather_lut")
.fragment_out(1, Type::FLOAT, "out_scatter_lut")
.fragment_out(2, Type::FLOAT, "out_resolve_lut")
.fragment_source("eevee_depth_of_field_bokeh_lut_frag.glsl")
.additional_info("draw_fullscreen");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_setup)
.do_static_compilation(true)
.additional_info("eevee_shared")
.uniform_buf(0, "DepthOfFieldData", "dof_buf")
.sampler(0, ImageType::FLOAT_2D, "color_tx", Frequency::PASS)
.sampler(1, ImageType::DEPTH_2D, "depth_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_color")
.fragment_out(1, Type::VEC2, "out_coc")
.fragment_source("eevee_depth_of_field_setup_frag.glsl")
.additional_info("draw_fullscreen");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_filter)
.do_static_compilation(true)
.additional_info("eevee_shared")
.sampler(0, ImageType::FLOAT_2D, "color_tx", Frequency::PASS)
.sampler(1, ImageType::FLOAT_2D, "weight_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_color")
.fragment_out(1, Type::FLOAT, "out_weight")
.fragment_source("eevee_depth_of_field_filter_frag.glsl")
.additional_info("draw_fullscreen");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_reduce_copy)
.do_static_compilation(true)
.additional_info("eevee_shared")
.uniform_buf(0, "DepthOfFieldData", "dof_buf")
.sampler(0, ImageType::FLOAT_2D, "color_tx", Frequency::PASS)
.sampler(1, ImageType::FLOAT_2D, "coc_tx", Frequency::PASS)
.sampler(2, ImageType::FLOAT_2D, "downsampled_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_color_gather")
.fragment_out(1, Type::FLOAT, "out_coc")
.fragment_out(2, Type::VEC3, "out_color_scatter")
.fragment_source("eevee_depth_of_field_reduce_copy_frag.glsl")
.additional_info("draw_fullscreen");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_reduce_downsample)
.do_static_compilation(true)
.additional_info("eevee_shared")
.sampler(0, ImageType::FLOAT_2D, "color_tx", Frequency::PASS)
.sampler(1, ImageType::FLOAT_2D, "coc_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_color")
.fragment_source("eevee_depth_of_field_reduce_downsample_frag.glsl")
.additional_info("draw_fullscreen");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_reduce_recursive)
.do_static_compilation(true)
.additional_info("eevee_shared")
.uniform_buf(0, "DepthOfFieldData", "dof_buf")
.uniform_buf(1, "SamplingData", "sampling_buf")
.sampler(0, ImageType::DEPTH_2D, "color_tx", Frequency::PASS)
.sampler(1, ImageType::FLOAT_2D, "coc_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_color")
.fragment_out(1, Type::FLOAT, "out_coc")
.fragment_source("eevee_depth_of_field_reduce_recursive_frag.glsl")
.additional_info("draw_fullscreen");
/** \} */
/* -------------------------------------------------------------------- */
/** \name Variations
* \{ */
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_no_lut)
.define("DOF_BOKEH_TEXTURE", "false")
/**
* WORKAROUND(@fclem): This is to keep the code as is for now. The bokeh_lut_tx is referenced
* even if not used after optimisation. But we don't want to include it in the create infos.
*/
.define("bokeh_lut_tx", "color_tx");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_lut)
.define("DOF_BOKEH_TEXTURE", "true")
.sampler(5, ImageType::FLOAT_2D, "bokeh_lut_tx", Frequency::PASS);
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_background).define("DOF_FOREGROUND_PASS", "false");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_foreground).define("DOF_FOREGROUND_PASS", "true");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_hq).define("DOF_SLIGHT_FOCUS_DENSITY", "4");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_lq).define("DOF_SLIGHT_FOCUS_DENSITY", "2");
#define EEVEE_DOF_FINAL_VARIATION(name, ...) \
GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true);
#define EEVEE_DOF_LUT_VARIATIONS(prefix, ...) \
EEVEE_DOF_FINAL_VARIATION(prefix##_lut, "eevee_depth_of_field_lut", __VA_ARGS__) \
EEVEE_DOF_FINAL_VARIATION(prefix, "eevee_depth_of_field_no_lut", __VA_ARGS__)
#define EEVEE_DOF_GROUND_VARIATIONS(name, ...) \
EEVEE_DOF_LUT_VARIATIONS(name##_background, "eevee_depth_of_field_background", __VA_ARGS__) \
EEVEE_DOF_LUT_VARIATIONS(name##_foreground, "eevee_depth_of_field_foreground", __VA_ARGS__)
#define EEVEE_DOF_HQ_VARIATIONS(name, ...) \
EEVEE_DOF_LUT_VARIATIONS(name##_hq, "eevee_depth_of_field_hq", __VA_ARGS__) \
EEVEE_DOF_LUT_VARIATIONS(name##_lq, "eevee_depth_of_field_lq", __VA_ARGS__)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Gather
* \{ */
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather)
.additional_info("eevee_shared")
.uniform_buf(0, "DepthOfFieldData", "dof_buf")
.uniform_buf(1, "SamplingData", "sampling_buf")
.sampler(0, ImageType::FLOAT_2D, "color_tx", Frequency::PASS)
.sampler(1, ImageType::FLOAT_2D, "color_bilinear_tx", Frequency::PASS)
.sampler(2, ImageType::FLOAT_2D, "coc_tx", Frequency::PASS)
.sampler(3, ImageType::FLOAT_2D, "tiles_fg_tx", Frequency::PASS)
.sampler(4, ImageType::FLOAT_2D, "tiles_bg_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_color")
.fragment_out(1, Type::FLOAT, "out_weight")
.fragment_out(2, Type::VEC2, "out_occlusion")
.fragment_source("eevee_depth_of_field_gather_frag.glsl")
.additional_info("draw_fullscreen");
EEVEE_DOF_GROUND_VARIATIONS(eevee_depth_of_field_gather, "eevee_depth_of_field_gather")
/** \} */
/* -------------------------------------------------------------------- */
/** \name Gather Holefill
* \{ */
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather_holefill)
.additional_info("eevee_shared")
.uniform_buf(0, "DepthOfFieldData", "dof_buf")
.uniform_buf(1, "SamplingData", "sampling_buf")
.sampler(0, ImageType::FLOAT_2D, "color_tx", Frequency::PASS)
.sampler(1, ImageType::FLOAT_2D, "color_bilinear_tx", Frequency::PASS)
.sampler(2, ImageType::FLOAT_2D, "coc_tx", Frequency::PASS)
.sampler(3, ImageType::FLOAT_2D, "tiles_fg_tx", Frequency::PASS)
.sampler(4, ImageType::FLOAT_2D, "tiles_bg_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_color")
.fragment_out(1, Type::FLOAT, "out_weight")
.fragment_source("eevee_depth_of_field_gather_holefill_frag.glsl")
.additional_info("draw_fullscreen", "eevee_depth_of_field_no_lut");
/** \} */
/* -------------------------------------------------------------------- */
/** \name Scatter
* \{ */
GPU_SHADER_INTERFACE_INFO(eevee_depth_of_field_scatter_iface, "")
/** Colors, weights, and Circle of confusion radii for the 4 pixels to scatter. */
.flat(Type::VEC4, "color1")
.flat(Type::VEC4, "color2")
.flat(Type::VEC4, "color3")
.flat(Type::VEC4, "color4")
.flat(Type::VEC4, "weights")
.flat(Type::VEC4, "cocs")
/** Sprite center position. In pixels. */
.flat(Type::VEC2, "spritepos")
/** MaxCoC. */
.flat(Type::FLOAT, "spritesize");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_scatter)
.additional_info("eevee_shared")
.uniform_buf(0, "DepthOfFieldData", "dof_buf")
.sampler(0, ImageType::FLOAT_2D, "color_tx")
.sampler(1, ImageType::DEPTH_2D, "depth_tx")
.sampler(2, ImageType::FLOAT_2D, "occlusion_tx")
.sampler(3, ImageType::FLOAT_2D, "coc_tx")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_out(eevee_depth_of_field_scatter_iface)
.vertex_source("eevee_depth_of_field_scatter_vert.glsl")
.fragment_source("eevee_depth_of_field_scatter_frag.glsl");
EEVEE_DOF_GROUND_VARIATIONS(eevee_depth_of_field_scatter, "eevee_depth_of_field_scatter")
/** \} */
/* -------------------------------------------------------------------- */
/** \name Resolve
* \{ */
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_resolve)
.define("DOF_RESOLVE_PASS", "true")
.additional_info("eevee_shared")
.uniform_buf(0, "DepthOfFieldData", "dof_buf")
.uniform_buf(1, "SamplingData", "sampling_buf")
.sampler(0, ImageType::DEPTH_2D, "depth_tx")
.sampler(1, ImageType::FLOAT_2D, "color_tx")
.sampler(2, ImageType::FLOAT_2D, "color_bg_tx")
.sampler(3, ImageType::FLOAT_2D, "color_fg_tx")
.sampler(4, ImageType::FLOAT_2D, "color_holefill_tx")
.sampler(7, ImageType::FLOAT_2D, "tiles_bg_tx")
.sampler(8, ImageType::FLOAT_2D, "tiles_fg_tx")
.sampler(9, ImageType::FLOAT_2D, "weight_bg_tx")
.sampler(10, ImageType::FLOAT_2D, "weight_fg_tx")
.sampler(11, ImageType::FLOAT_2D, "weight_holefill_tx")
.fragment_out(0, Type::VEC4, "out_color")
.fragment_source("eevee_depth_of_field_resolve_frag.glsl")
.additional_info("draw_fullscreen");
EEVEE_DOF_HQ_VARIATIONS(eevee_depth_of_field_resolve, "eevee_depth_of_field_resolve")
/** \} */
/* -------------------------------------------------------------------- */
/** \name Circle-Of-Confusion Tiles
* \{ */
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate)
.additional_info("eevee_shared")
.sampler(0, ImageType::FLOAT_2D, "tiles_fg_tx", Frequency::PASS)
.sampler(1, ImageType::FLOAT_2D, "tiles_bg_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_tile_fg")
.fragment_out(1, Type::VEC3, "out_tile_bg")
.push_constant(Type::INT, "ring_count")
.push_constant(Type::INT, "ring_width_multiplier")
.push_constant(Type::BOOL, "dilate_slight_focus")
.fragment_source("eevee_depth_of_field_tiles_dilate_frag.glsl")
.additional_info("draw_fullscreen");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minabs)
.do_static_compilation(true)
.define("DILATE_MODE_MIN_MAX", "false")
.additional_info("eevee_depth_of_field_tiles_dilate");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minmax)
.do_static_compilation(true)
.define("DILATE_MODE_MIN_MAX", "true")
.additional_info("eevee_depth_of_field_tiles_dilate");
GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_flatten)
.do_static_compilation(true)
.additional_info("eevee_shared")
.sampler(0, ImageType::FLOAT_2D, "coc_tx", Frequency::PASS)
.fragment_out(0, Type::VEC4, "out_tile_fg")
.fragment_out(1, Type::VEC3, "out_tile_bg")
.fragment_source("eevee_depth_of_field_tiles_flatten_frag.glsl")
.additional_info("draw_fullscreen");
/** \} */
|