Blender  V2.93
workbench_effect_dof.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2016, Blender Foundation.
17  */
18 
34 #include "workbench_private.h"
35 
36 #include "BKE_camera.h"
37 #include "DEG_depsgraph_query.h"
38 
39 #include "DNA_camera_types.h"
40 
44 static void square_to_circle(float x, float y, float *r, float *T)
45 {
46  if (x > -y) {
47  if (x > y) {
48  *r = x;
49  *T = (M_PI / 4.0f) * (y / x);
50  }
51  else {
52  *r = y;
53  *T = (M_PI / 4.0f) * (2 - (x / y));
54  }
55  }
56  else {
57  if (x < y) {
58  *r = -x;
59  *T = (M_PI / 4.0f) * (4 + (y / x));
60  }
61  else {
62  *r = -y;
63  if (y != 0) {
64  *T = (M_PI / 4.0f) * (6 - (x / y));
65  }
66  else {
67  *T = 0.0f;
68  }
69  }
70  }
71 }
72 
73 #define SQUARE_UNSAFE(a) ((a) * (a))
74 #define KERNEL_RAD (3)
75 #define SAMP_LEN SQUARE_UNSAFE(KERNEL_RAD * 2 + 1)
76 
77 static void workbench_dof_setup_samples(struct GPUUniformBuf **ubo,
78  float **data,
79  float bokeh_sides,
80  float bokeh_rotation,
81  float bokeh_ratio)
82 {
83  if (*data == NULL) {
84  *data = MEM_callocN(sizeof(float[4]) * SAMP_LEN, "workbench dof samples");
85  }
86  if (*ubo == NULL) {
87  *ubo = GPU_uniformbuf_create(sizeof(float[4]) * SAMP_LEN);
88  }
89 
90  float *samp = *data;
91  for (int i = 0; i <= KERNEL_RAD; i++) {
92  for (int j = -KERNEL_RAD; j <= KERNEL_RAD; j++) {
93  for (int k = -KERNEL_RAD; k <= KERNEL_RAD; k++) {
94  if (abs(j) > i || abs(k) > i) {
95  continue;
96  }
97  if (abs(j) < i && abs(k) < i) {
98  continue;
99  }
100  float x = ((float)j) / KERNEL_RAD;
101  float y = ((float)k) / KERNEL_RAD;
102 
103  float r, T;
104  square_to_circle(x, y, &r, &T);
105  samp[2] = r;
106 
107  /* Bokeh shape parameterization. */
108  if (bokeh_sides > 1.0f) {
109  float denom = T - (2.0 * M_PI / bokeh_sides) *
110  floorf((bokeh_sides * T + M_PI) / (2.0 * M_PI));
111  r *= cosf(M_PI / bokeh_sides) / cosf(denom);
112  }
113 
114  T += bokeh_rotation;
115 
116  samp[0] = r * cosf(T) * bokeh_ratio;
117  samp[1] = r * sinf(T);
118  samp += 4;
119  }
120  }
121  }
122 
123  GPU_uniformbuf_update(*ubo, *data);
124 }
125 
127 {
128  WORKBENCH_TextureList *txl = vedata->txl;
129  WORKBENCH_StorageList *stl = vedata->stl;
130  WORKBENCH_PrivateData *wpd = stl->wpd;
131  WORKBENCH_FramebufferList *fbl = vedata->fbl;
132 
133  const DRWContextState *draw_ctx = DRW_context_state_get();
134  RegionView3D *rv3d = draw_ctx->rv3d;
135  View3D *v3d = draw_ctx->v3d;
136 
137  Object *camera;
138 
139  if (v3d && rv3d) {
140  camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL;
141  }
142  else {
143  camera = wpd->cam_original_ob;
144  }
145 
146  Camera *cam = camera != NULL ? camera->data : NULL;
147  if ((wpd->shading.flag & V3D_SHADING_DEPTH_OF_FIELD) == 0 || (cam == NULL) ||
148  ((cam->dof.flag & CAM_DOF_ENABLED) == 0)) {
149  wpd->dof_enabled = false;
150 
151  /* Cleanup. */
154  return;
155  }
156 
157  const float *full_size = DRW_viewport_size_get();
158  const int size[2] = {max_ii(1, (int)full_size[0] / 2), max_ii(1, (int)full_size[1] / 2)};
159 #if 0 /* TODO(fclem): finish COC min_max optimization. */
160  /* NOTE: We Ceil here in order to not miss any edge texel if using a NPO2 texture. */
161  int shrink_h_size[2] = {ceilf(size[0] / 8.0f), size[1]};
162  int shrink_w_size[2] = {shrink_h_size[0], ceilf(size[1] / 8.0f)};
163 #endif
164 
171 #if 0 /* TODO(fclem): finish COC min_max optimization. */
173  shrink_h_size[0], shrink_h_size[1], GPU_RG8, &draw_engine_workbench);
175  shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench);
177  shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench);
178 #endif
179 
180  GPU_framebuffer_ensure_config(&fbl->dof_downsample_fb,
181  {
182  GPU_ATTACHMENT_NONE,
183  GPU_ATTACHMENT_TEXTURE(txl->dof_source_tx),
184  GPU_ATTACHMENT_TEXTURE(txl->coc_halfres_tx),
185  });
186 #if 0 /* TODO(fclem): finish COC min_max optimization. */
187  GPU_framebuffer_ensure_config(&fbl->dof_coc_tile_h_fb,
188  {
189  GPU_ATTACHMENT_NONE,
190  GPU_ATTACHMENT_TEXTURE(wpd->coc_temp_tx),
191  });
192  GPU_framebuffer_ensure_config(&fbl->dof_coc_tile_v_fb,
193  {
194  GPU_ATTACHMENT_NONE,
195  GPU_ATTACHMENT_TEXTURE(wpd->coc_tiles_tx[0]),
196  });
197  GPU_framebuffer_ensure_config(&fbl->dof_coc_dilate_fb,
198  {
199  GPU_ATTACHMENT_NONE,
200  GPU_ATTACHMENT_TEXTURE(wpd->coc_tiles_tx[1]),
201  });
202 #endif
203  GPU_framebuffer_ensure_config(&fbl->dof_blur1_fb,
204  {
205  GPU_ATTACHMENT_NONE,
206  GPU_ATTACHMENT_TEXTURE(wpd->dof_blur_tx),
207  });
208  GPU_framebuffer_ensure_config(&fbl->dof_blur2_fb,
209  {
210  GPU_ATTACHMENT_NONE,
211  GPU_ATTACHMENT_TEXTURE(txl->dof_source_tx),
212  });
213 
214  {
215  /* Parameters */
216  float fstop = cam->dof.aperture_fstop;
217  float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
218  float focus_dist = BKE_camera_object_dof_distance(camera);
219  float focal_len = cam->lens;
220 
221  /* TODO(fclem): deduplicate with eevee */
222  const float scale_camera = 0.001f;
223  /* we want radius here for the aperture number */
224  float aperture = 0.5f * scale_camera * focal_len / fstop;
225  float focal_len_scaled = scale_camera * focal_len;
226  float sensor_scaled = scale_camera * sensor;
227 
228  if (rv3d != NULL) {
229  sensor_scaled *= rv3d->viewcamtexcofac[0];
230  }
231 
232  wpd->dof_aperturesize = aperture * fabsf(focal_len_scaled / (focus_dist - focal_len_scaled));
233  wpd->dof_distance = -focus_dist;
234  wpd->dof_invsensorsize = full_size[0] / sensor_scaled;
235 
236  wpd->dof_near_far[0] = -cam->clip_start;
237  wpd->dof_near_far[1] = -cam->clip_end;
238 
239  float blades = cam->dof.aperture_blades;
240  float rotation = cam->dof.aperture_rotation;
241  float ratio = 1.0f / cam->dof.aperture_ratio;
242 
243  if (wpd->vldata->dof_sample_ubo == NULL || blades != wpd->dof_blades ||
244  rotation != wpd->dof_rotation || ratio != wpd->dof_ratio) {
245  wpd->dof_blades = blades;
246  wpd->dof_rotation = rotation;
247  wpd->dof_ratio = ratio;
249  &wpd->vldata->dof_sample_ubo, &stl->dof_ubo_data, blades, rotation, ratio);
250  }
251  }
252 
253  wpd->dof_enabled = true;
254 }
255 
257 {
258  WORKBENCH_PassList *psl = vedata->psl;
259  WORKBENCH_TextureList *txl = vedata->txl;
260  WORKBENCH_StorageList *stl = vedata->stl;
261  WORKBENCH_PrivateData *wpd = stl->wpd;
262 
263  if (!wpd->dof_enabled) {
264  return;
265  }
266 
267  GPUShader *prepare_sh, *downsample_sh, *blur1_sh, *blur2_sh, *resolve_sh;
269  &prepare_sh, &downsample_sh, &blur1_sh, &blur2_sh, &resolve_sh);
270 
272 
273  {
274  psl->dof_down_ps = DRW_pass_create("DoF DownSample", DRW_STATE_WRITE_COLOR);
275 
276  DRWShadingGroup *grp = DRW_shgroup_create(prepare_sh, psl->dof_down_ps);
277  DRW_shgroup_uniform_texture(grp, "sceneColorTex", dtxl->color);
278  DRW_shgroup_uniform_texture(grp, "sceneDepthTex", dtxl->depth);
279  DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
280  DRW_shgroup_uniform_vec3(grp, "dofParams", &wpd->dof_aperturesize, 1);
281  DRW_shgroup_uniform_vec2(grp, "nearFar", wpd->dof_near_far, 1);
283  }
284 
285  {
286  psl->dof_down2_ps = DRW_pass_create("DoF DownSample", DRW_STATE_WRITE_COLOR);
287 
290  DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
292  }
293 #if 0 /* TODO(fclem): finish COC min_max optimization */
294  {
295  psl->dof_flatten_h_ps = DRW_pass_create("DoF Flatten Coc H", DRW_STATE_WRITE_COLOR);
296 
297  DRWShadingGroup *grp = DRW_shgroup_create(flatten_h_sh, psl->dof_flatten_h_ps);
298  DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
300  }
301  {
302  psl->dof_flatten_v_ps = DRW_pass_create("DoF Flatten Coc V", DRW_STATE_WRITE_COLOR);
303 
304  DRWShadingGroup *grp = DRW_shgroup_create(flatten_v_sh, psl->dof_flatten_v_ps);
305  DRW_shgroup_uniform_texture(grp, "inputCocTex", wpd->coc_temp_tx);
307  }
308  {
309  psl->dof_dilate_h_ps = DRW_pass_create("DoF Dilate Coc H", DRW_STATE_WRITE_COLOR);
310 
311  DRWShadingGroup *grp = DRW_shgroup_create(dilate_v_sh, psl->dof_dilate_v_ps);
312  DRW_shgroup_uniform_texture(grp, "inputCocTex", wpd->coc_tiles_tx[0]);
314  }
315  {
316  psl->dof_dilate_v_ps = DRW_pass_create("DoF Dilate Coc V", DRW_STATE_WRITE_COLOR);
317 
318  DRWShadingGroup *grp = DRW_shgroup_create(dilate_h_sh, psl->dof_dilate_h_ps);
319  DRW_shgroup_uniform_texture(grp, "inputCocTex", wpd->coc_tiles_tx[1]);
321  }
322 #endif
323  {
324  psl->dof_blur1_ps = DRW_pass_create("DoF Blur 1", DRW_STATE_WRITE_COLOR);
325 
326  /* We reuse the same noise texture. Ensure it is up to date. */
328 
329  float offset = wpd->taa_sample / (float)max_ii(1, wpd->taa_sample_len);
330  DRWShadingGroup *grp = DRW_shgroup_create(blur1_sh, psl->dof_blur1_ps);
331  DRW_shgroup_uniform_block(grp, "dofSamplesBlock", wpd->vldata->dof_sample_ubo);
332  DRW_shgroup_uniform_texture(grp, "noiseTex", wpd->vldata->cavity_jitter_tx);
333  DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
334  DRW_shgroup_uniform_texture(grp, "halfResColorTex", txl->dof_source_tx);
335  DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
336  DRW_shgroup_uniform_float_copy(grp, "noiseOffset", offset);
338  }
339  {
340  psl->dof_blur2_ps = DRW_pass_create("DoF Blur 2", DRW_STATE_WRITE_COLOR);
341 
342  DRWShadingGroup *grp = DRW_shgroup_create(blur2_sh, psl->dof_blur2_ps);
343  DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
344  DRW_shgroup_uniform_texture(grp, "blurTex", wpd->dof_blur_tx);
345  DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
347  }
348  {
349  psl->dof_resolve_ps = DRW_pass_create("DoF Resolve",
351 
352  DRWShadingGroup *grp = DRW_shgroup_create(resolve_sh, psl->dof_resolve_ps);
353  DRW_shgroup_uniform_texture(grp, "halfResColorTex", txl->dof_source_tx);
354  DRW_shgroup_uniform_texture(grp, "sceneDepthTex", dtxl->depth);
355  DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
356  DRW_shgroup_uniform_vec3(grp, "dofParams", &wpd->dof_aperturesize, 1);
357  DRW_shgroup_uniform_vec2(grp, "nearFar", wpd->dof_near_far, 1);
359  }
360 }
361 
362 static void workbench_dof_downsample_level(void *userData, int UNUSED(level))
363 {
364  WORKBENCH_PassList *psl = (WORKBENCH_PassList *)userData;
366 }
367 
369 {
370  WORKBENCH_FramebufferList *fbl = vedata->fbl;
371  WORKBENCH_StorageList *stl = vedata->stl;
372  WORKBENCH_PassList *psl = vedata->psl;
373  WORKBENCH_PrivateData *wpd = stl->wpd;
375 
376  if (!wpd->dof_enabled) {
377  return;
378  }
379 
380  DRW_stats_group_start("Depth Of Field");
381 
384 
387 
388 #if 0 /* TODO(fclem): finish COC min_max optimization */
391 
394 
397 
400 #endif
401 
404 
407 
410 
412 }
typedef float(TangentPoint)[2]
Camera data-block and utility functions.
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
Definition: camera.c:242
float BKE_camera_object_dof_distance(struct Object *ob)
Definition: camera.c:227
MINLINE int max_ii(int a, int b)
#define M_PI
Definition: BLI_math_base.h:38
#define UNUSED(x)
@ CAM_DOF_ENABLED
#define RV3D_CAMOB
@ V3D_SHADING_DEPTH_OF_FIELD
@ DRW_TEX_MIPMAP
Definition: DRW_render.h:142
@ DRW_TEX_FILTER
Definition: DRW_render.h:139
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
@ DRW_STATE_BLEND_CUSTOM
Definition: DRW_render.h:348
#define DRW_TEXTURE_FREE_SAFE(tex)
Definition: DRW_render.h:180
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
struct GPUShader GPUShader
Definition: GPU_shader.h:33
@ GPU_SAMPLER_DEFAULT
Definition: GPU_texture.h:41
@ GPU_RGBA16F
Definition: GPU_texture.h:94
@ GPU_RG8
Definition: GPU_texture.h:98
struct GPUUniformBuf GPUUniformBuf
#define GPU_uniformbuf_create(size)
void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
Definition: draw_manager.c:697
const DRWContextState * DRW_context_state_get(void)
const float * DRW_viewport_size_get(void)
Definition: draw_manager.c:439
const float * DRW_viewport_invert_size_get(void)
Definition: draw_manager.c:444
DefaultTextureList * DRW_viewport_texture_list_get(void)
Definition: draw_manager.c:702
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuf *ubo)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_uniform_vec3(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, Object *ob, uint tri_count)
void DRW_shgroup_uniform_texture_ex(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex, eGPUSamplerState sampler_state)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
DRWPass * DRW_pass_create(const char *name, DRWState state)
void DRW_shgroup_uniform_vec2(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_draw_pass(DRWPass *pass)
void DRW_stats_group_start(const char *name)
void DRW_stats_group_end(void)
void DRW_texture_ensure_2d(GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags)
GPUTexture * DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
struct GPUShader * downsample_sh
void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *gpu_fb, int max_lvl, void(*callback)(void *userData, int level), void *userData)
#define sinf(x)
#define cosf(x)
#define ceilf(x)
#define floorf(x)
#define fabsf(x)
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
#define T
float clip_end
char sensor_fit
float sensor_y
float sensor_x
float clip_start
struct CameraDOFSettings dof
struct View3D * v3d
Definition: DRW_render.h:742
struct RegionView3D * rv3d
Definition: DRW_render.h:741
struct GPUFrameBuffer * color_only_fb
struct GPUTexture * depth
struct GPUTexture * color
void * data
float viewcamtexcofac[4]
struct Object * camera
WORKBENCH_FramebufferList * fbl
WORKBENCH_PassList * psl
WORKBENCH_StorageList * stl
WORKBENCH_TextureList * txl
struct GPUFrameBuffer * dof_coc_dilate_fb
struct GPUFrameBuffer * dof_blur1_fb
struct GPUFrameBuffer * dof_coc_tile_h_fb
struct GPUFrameBuffer * dof_downsample_fb
struct GPUFrameBuffer * dof_coc_tile_v_fb
struct GPUFrameBuffer * dof_blur2_fb
struct DRWPass * dof_dilate_v_ps
struct DRWPass * dof_blur1_ps
struct DRWPass * dof_dilate_h_ps
struct DRWPass * dof_flatten_h_ps
struct DRWPass * dof_resolve_ps
struct DRWPass * dof_blur2_ps
struct DRWPass * dof_down_ps
struct DRWPass * dof_flatten_v_ps
struct DRWPass * dof_down2_ps
struct GPUTexture * dof_blur_tx
struct Object * cam_original_ob
struct GPUTexture * coc_tiles_tx[2]
struct WORKBENCH_ViewLayerData * vldata
struct GPUTexture * coc_temp_tx
struct WORKBENCH_PrivateData * wpd
struct GPUTexture * dof_source_tx
struct GPUTexture * coc_halfres_tx
struct GPUUniformBuf * dof_sample_ubo
struct GPUTexture * cavity_jitter_tx
__forceinline const avxi abs(const avxi &a)
Definition: util_avxi.h:186
void workbench_cavity_samples_ubo_ensure(WORKBENCH_PrivateData *wpd)
#define KERNEL_RAD
void workbench_dof_cache_init(WORKBENCH_Data *vedata)
void workbench_dof_draw_pass(WORKBENCH_Data *vedata)
static void square_to_circle(float x, float y, float *r, float *T)
static void workbench_dof_downsample_level(void *userData, int UNUSED(level))
static void workbench_dof_setup_samples(struct GPUUniformBuf **ubo, float **data, float bokeh_sides, float bokeh_rotation, float bokeh_ratio)
void workbench_dof_engine_init(WORKBENCH_Data *vedata)
#define SAMP_LEN
DrawEngineType draw_engine_workbench
void workbench_shader_depth_of_field_get(GPUShader **prepare_sh, GPUShader **downsample_sh, GPUShader **blur1_sh, GPUShader **blur2_sh, GPUShader **resolve_sh)