Blender  V3.3
workbench_effect_dof.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2016 Blender Foundation. */
3 
19 #include "workbench_private.h"
20 
21 #include "BKE_camera.h"
22 #include "DEG_depsgraph_query.h"
23 
24 #include "DNA_camera_types.h"
25 
29 static void square_to_circle(float x, float y, float *r, float *T)
30 {
31  if (x > -y) {
32  if (x > y) {
33  *r = x;
34  *T = M_PI_4 * (y / x);
35  }
36  else {
37  *r = y;
38  *T = M_PI_4 * (2 - (x / y));
39  }
40  }
41  else {
42  if (x < y) {
43  *r = -x;
44  *T = M_PI_4 * (4 + (y / x));
45  }
46  else {
47  *r = -y;
48  if (y != 0) {
49  *T = M_PI_4 * (6 - (x / y));
50  }
51  else {
52  *T = 0.0f;
53  }
54  }
55  }
56 }
57 
58 #define SQUARE_UNSAFE(a) ((a) * (a))
59 #define KERNEL_RAD (3)
60 #define SAMP_LEN SQUARE_UNSAFE(KERNEL_RAD * 2 + 1)
61 
62 static void workbench_dof_setup_samples(struct GPUUniformBuf **ubo,
63  float **data,
64  float bokeh_sides,
65  float bokeh_rotation,
66  float bokeh_ratio)
67 {
68  if (*data == NULL) {
69  *data = MEM_callocN(sizeof(float[4]) * SAMP_LEN, "workbench dof samples");
70  }
71  if (*ubo == NULL) {
72  *ubo = GPU_uniformbuf_create(sizeof(float[4]) * SAMP_LEN);
73  }
74 
75  float *samp = *data;
76  for (int i = 0; i <= KERNEL_RAD; i++) {
77  for (int j = -KERNEL_RAD; j <= KERNEL_RAD; j++) {
78  for (int k = -KERNEL_RAD; k <= KERNEL_RAD; k++) {
79  if (abs(j) > i || abs(k) > i) {
80  continue;
81  }
82  if (abs(j) < i && abs(k) < i) {
83  continue;
84  }
85  float x = ((float)j) / KERNEL_RAD;
86  float y = ((float)k) / KERNEL_RAD;
87 
88  float r, T;
89  square_to_circle(x, y, &r, &T);
90  samp[2] = r;
91 
92  /* Bokeh shape parameterization. */
93  if (bokeh_sides > 1.0f) {
94  float denom = T - (2.0 * M_PI / bokeh_sides) *
95  floorf((bokeh_sides * T + M_PI) / (2.0 * M_PI));
96  r *= cosf(M_PI / bokeh_sides) / cosf(denom);
97  }
98 
99  T += bokeh_rotation;
100 
101  samp[0] = r * cosf(T) * bokeh_ratio;
102  samp[1] = r * sinf(T);
103  samp += 4;
104  }
105  }
106  }
107 
108  GPU_uniformbuf_update(*ubo, *data);
109 }
110 
112 {
113  WORKBENCH_TextureList *txl = vedata->txl;
114  WORKBENCH_StorageList *stl = vedata->stl;
115  WORKBENCH_PrivateData *wpd = stl->wpd;
116  WORKBENCH_FramebufferList *fbl = vedata->fbl;
117 
118  const DRWContextState *draw_ctx = DRW_context_state_get();
119  RegionView3D *rv3d = draw_ctx->rv3d;
120  View3D *v3d = draw_ctx->v3d;
121 
122  Object *camera;
123 
124  if (v3d && rv3d) {
125  camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL;
126  }
127  else {
128  camera = wpd->cam_original_ob;
129  }
130 
131  Camera *cam = camera != NULL && camera->type == OB_CAMERA ? camera->data : NULL;
132  if ((wpd->shading.flag & V3D_SHADING_DEPTH_OF_FIELD) == 0 || (cam == NULL) ||
133  ((cam->dof.flag & CAM_DOF_ENABLED) == 0)) {
134  wpd->dof_enabled = false;
135 
136  /* Cleanup. */
139  return;
140  }
141 
142  const float *full_size = DRW_viewport_size_get();
143  const int size[2] = {max_ii(1, (int)full_size[0] / 2), max_ii(1, (int)full_size[1] / 2)};
144 #if 0 /* TODO(fclem): finish COC min_max optimization. */
145  /* NOTE: We Ceil here in order to not miss any edge texel if using a NPO2 texture. */
146  int shrink_h_size[2] = {ceilf(size[0] / 8.0f), size[1]};
147  int shrink_w_size[2] = {shrink_h_size[0], ceilf(size[1] / 8.0f)};
148 #endif
149 
156 #if 0 /* TODO(fclem): finish COC min_max optimization. */
158  shrink_h_size[0], shrink_h_size[1], GPU_RG8, &draw_engine_workbench);
160  shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench);
162  shrink_w_size[0], shrink_w_size[1], GPU_RG8, &draw_engine_workbench);
163 #endif
164 
165  GPU_framebuffer_ensure_config(&fbl->dof_downsample_fb,
166  {
167  GPU_ATTACHMENT_NONE,
168  GPU_ATTACHMENT_TEXTURE(txl->dof_source_tx),
169  GPU_ATTACHMENT_TEXTURE(txl->coc_halfres_tx),
170  });
171 #if 0 /* TODO(fclem): finish COC min_max optimization. */
172  GPU_framebuffer_ensure_config(&fbl->dof_coc_tile_h_fb,
173  {
174  GPU_ATTACHMENT_NONE,
175  GPU_ATTACHMENT_TEXTURE(wpd->coc_temp_tx),
176  });
177  GPU_framebuffer_ensure_config(&fbl->dof_coc_tile_v_fb,
178  {
179  GPU_ATTACHMENT_NONE,
180  GPU_ATTACHMENT_TEXTURE(wpd->coc_tiles_tx[0]),
181  });
182  GPU_framebuffer_ensure_config(&fbl->dof_coc_dilate_fb,
183  {
184  GPU_ATTACHMENT_NONE,
185  GPU_ATTACHMENT_TEXTURE(wpd->coc_tiles_tx[1]),
186  });
187 #endif
188  GPU_framebuffer_ensure_config(&fbl->dof_blur1_fb,
189  {
190  GPU_ATTACHMENT_NONE,
191  GPU_ATTACHMENT_TEXTURE(wpd->dof_blur_tx),
192  });
193  GPU_framebuffer_ensure_config(&fbl->dof_blur2_fb,
194  {
195  GPU_ATTACHMENT_NONE,
196  GPU_ATTACHMENT_TEXTURE(txl->dof_source_tx),
197  });
198 
199  {
200  /* Parameters */
201  float fstop = cam->dof.aperture_fstop;
202  float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
203  float focus_dist = BKE_camera_object_dof_distance(camera);
204  float focal_len = cam->lens;
205 
206  /* TODO(fclem): de-duplicate with EEVEE. */
207  const float scale_camera = 0.001f;
208  /* We want radius here for the aperture number. */
209  float aperture = 0.5f * scale_camera * focal_len / fstop;
210  float focal_len_scaled = scale_camera * focal_len;
211  float sensor_scaled = scale_camera * sensor;
212 
213  if (rv3d != NULL) {
214  sensor_scaled *= rv3d->viewcamtexcofac[0];
215  }
216 
217  wpd->dof_aperturesize = aperture * fabsf(focal_len_scaled / (focus_dist - focal_len_scaled));
218  wpd->dof_distance = -focus_dist;
219  wpd->dof_invsensorsize = full_size[0] / sensor_scaled;
220 
221  wpd->dof_near_far[0] = -cam->clip_start;
222  wpd->dof_near_far[1] = -cam->clip_end;
223 
224  float blades = cam->dof.aperture_blades;
225  float rotation = cam->dof.aperture_rotation;
226  float ratio = 1.0f / cam->dof.aperture_ratio;
227 
228  if (wpd->vldata->dof_sample_ubo == NULL || blades != wpd->dof_blades ||
229  rotation != wpd->dof_rotation || ratio != wpd->dof_ratio) {
230  wpd->dof_blades = blades;
231  wpd->dof_rotation = rotation;
232  wpd->dof_ratio = ratio;
234  &wpd->vldata->dof_sample_ubo, &stl->dof_ubo_data, blades, rotation, ratio);
235  }
236  }
237 
238  wpd->dof_enabled = true;
239 }
240 
242 {
243  WORKBENCH_PassList *psl = vedata->psl;
244  WORKBENCH_TextureList *txl = vedata->txl;
245  WORKBENCH_StorageList *stl = vedata->stl;
246  WORKBENCH_PrivateData *wpd = stl->wpd;
247 
248  if (!wpd->dof_enabled) {
249  return;
250  }
251 
252  GPUShader *prepare_sh, *downsample_sh, *blur1_sh, *blur2_sh, *resolve_sh;
254  &prepare_sh, &downsample_sh, &blur1_sh, &blur2_sh, &resolve_sh);
255 
257 
258  {
259  psl->dof_down_ps = DRW_pass_create("DoF DownSample", DRW_STATE_WRITE_COLOR);
260 
261  DRWShadingGroup *grp = DRW_shgroup_create(prepare_sh, psl->dof_down_ps);
262  DRW_shgroup_uniform_texture(grp, "sceneColorTex", dtxl->color);
263  DRW_shgroup_uniform_texture(grp, "sceneDepthTex", dtxl->depth);
264  DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
265  DRW_shgroup_uniform_vec3(grp, "dofParams", &wpd->dof_aperturesize, 1);
266  DRW_shgroup_uniform_vec2(grp, "nearFar", wpd->dof_near_far, 1);
268  }
269 
270  {
271  psl->dof_down2_ps = DRW_pass_create("DoF DownSample", DRW_STATE_WRITE_COLOR);
272 
275  DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
277  }
278 #if 0 /* TODO(fclem): finish COC min_max optimization */
279  {
280  psl->dof_flatten_h_ps = DRW_pass_create("DoF Flatten Coc H", DRW_STATE_WRITE_COLOR);
281 
282  DRWShadingGroup *grp = DRW_shgroup_create(flatten_h_sh, psl->dof_flatten_h_ps);
283  DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
285  }
286  {
287  psl->dof_flatten_v_ps = DRW_pass_create("DoF Flatten Coc V", DRW_STATE_WRITE_COLOR);
288 
289  DRWShadingGroup *grp = DRW_shgroup_create(flatten_v_sh, psl->dof_flatten_v_ps);
290  DRW_shgroup_uniform_texture(grp, "inputCocTex", wpd->coc_temp_tx);
292  }
293  {
294  psl->dof_dilate_h_ps = DRW_pass_create("DoF Dilate Coc H", DRW_STATE_WRITE_COLOR);
295 
296  DRWShadingGroup *grp = DRW_shgroup_create(dilate_v_sh, psl->dof_dilate_v_ps);
297  DRW_shgroup_uniform_texture(grp, "inputCocTex", wpd->coc_tiles_tx[0]);
299  }
300  {
301  psl->dof_dilate_v_ps = DRW_pass_create("DoF Dilate Coc V", DRW_STATE_WRITE_COLOR);
302 
303  DRWShadingGroup *grp = DRW_shgroup_create(dilate_h_sh, psl->dof_dilate_h_ps);
304  DRW_shgroup_uniform_texture(grp, "inputCocTex", wpd->coc_tiles_tx[1]);
306  }
307 #endif
308  {
309  psl->dof_blur1_ps = DRW_pass_create("DoF Blur 1", DRW_STATE_WRITE_COLOR);
310 
311  /* We reuse the same noise texture. Ensure it is up to date. */
313 
314  float offset = wpd->taa_sample / (float)max_ii(1, wpd->taa_sample_len);
315  DRWShadingGroup *grp = DRW_shgroup_create(blur1_sh, psl->dof_blur1_ps);
316  DRW_shgroup_uniform_block(grp, "samples", wpd->vldata->dof_sample_ubo);
317  DRW_shgroup_uniform_texture(grp, "noiseTex", wpd->vldata->cavity_jitter_tx);
318  DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
319  DRW_shgroup_uniform_texture(grp, "halfResColorTex", txl->dof_source_tx);
320  DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
321  DRW_shgroup_uniform_float_copy(grp, "noiseOffset", offset);
323  }
324  {
325  psl->dof_blur2_ps = DRW_pass_create("DoF Blur 2", DRW_STATE_WRITE_COLOR);
326 
327  DRWShadingGroup *grp = DRW_shgroup_create(blur2_sh, psl->dof_blur2_ps);
328  DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx);
329  DRW_shgroup_uniform_texture(grp, "blurTex", wpd->dof_blur_tx);
330  DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
332  }
333  {
334  psl->dof_resolve_ps = DRW_pass_create("DoF Resolve",
336 
337  DRWShadingGroup *grp = DRW_shgroup_create(resolve_sh, psl->dof_resolve_ps);
338  DRW_shgroup_uniform_texture(grp, "halfResColorTex", txl->dof_source_tx);
339  DRW_shgroup_uniform_texture(grp, "sceneDepthTex", dtxl->depth);
340  DRW_shgroup_uniform_vec2(grp, "invertedViewportSize", DRW_viewport_invert_size_get(), 1);
341  DRW_shgroup_uniform_vec3(grp, "dofParams", &wpd->dof_aperturesize, 1);
342  DRW_shgroup_uniform_vec2(grp, "nearFar", wpd->dof_near_far, 1);
344  }
345 }
346 
347 static void workbench_dof_downsample_level(void *userData, int UNUSED(level))
348 {
349  WORKBENCH_PassList *psl = (WORKBENCH_PassList *)userData;
351 }
352 
354 {
355  WORKBENCH_FramebufferList *fbl = vedata->fbl;
356  WORKBENCH_StorageList *stl = vedata->stl;
357  WORKBENCH_PassList *psl = vedata->psl;
358  WORKBENCH_PrivateData *wpd = stl->wpd;
360 
361  if (!wpd->dof_enabled) {
362  return;
363  }
364 
365  DRW_stats_group_start("Depth Of Field");
366 
369 
372 
373 #if 0 /* TODO(fclem): finish COC min_max optimization */
376 
379 
382 
385 #endif
386 
389 
392 
395 
397 }
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:236
float BKE_camera_object_dof_distance(const struct Object *ob)
MINLINE int max_ii(int a, int b)
#define M_PI
Definition: BLI_math_base.h:20
#define M_PI_4
Definition: BLI_math_base.h:26
#define UNUSED(x)
@ CAM_DOF_ENABLED
@ OB_CAMERA
#define RV3D_CAMOB
@ V3D_SHADING_DEPTH_OF_FIELD
@ DRW_TEX_MIPMAP
Definition: DRW_render.h:143
@ DRW_TEX_FILTER
Definition: DRW_render.h:140
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:303
@ DRW_STATE_BLEND_CUSTOM
Definition: DRW_render.h:336
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
Definition: DRW_render.h:651
#define DRW_TEXTURE_FREE_SAFE(tex)
Definition: DRW_render.h:183
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:20
@ GPU_SAMPLER_DEFAULT
Definition: GPU_texture.h:26
@ GPU_RG8
Definition: GPU_texture.h:97
struct GPUUniformBuf GPUUniformBuf
#define GPU_uniformbuf_create(size)
void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
#define sinf(x)
Definition: cuda/compat.h:102
#define cosf(x)
Definition: cuda/compat.h:101
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
Definition: draw_manager.c:633
const DRWContextState * DRW_context_state_get(void)
const float * DRW_viewport_size_get(void)
Definition: draw_manager.c:288
const float * DRW_viewport_invert_size_get(void)
Definition: draw_manager.c:293
DefaultTextureList * DRW_viewport_texture_list_get(void)
Definition: draw_manager.c:638
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
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)
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
struct GPUShader * downsample_sh
Definition: eevee_shaders.c:93
void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *gpu_fb, int max_lvl, void(*callback)(void *userData, int level), void *userData)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define T
#define ceilf(x)
Definition: metal/compat.h:225
#define floorf(x)
Definition: metal/compat.h:224
#define fabsf(x)
Definition: metal/compat.h:219
T abs(const T &a)
float clip_end
char sensor_fit
float sensor_y
float lens
float sensor_x
float clip_start
struct CameraDOFSettings dof
struct View3D * v3d
Definition: DRW_render.h:976
struct RegionView3D * rv3d
Definition: DRW_render.h:975
struct GPUFrameBuffer * color_only_fb
struct GPUTexture * depth
struct GPUTexture * color
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
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)