Blender  V3.3
workbench_effect_antialiasing.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. */
3 
19 #include "ED_screen.h"
20 
21 #include "BLI_jitter_2d.h"
22 
23 #include "smaa_textures.h"
24 
25 #include "workbench_private.h"
26 
27 static struct {
28  bool init;
29  float jitter_5[5][2];
30  float jitter_8[8][2];
31  float jitter_11[11][2];
32  float jitter_16[16][2];
33  float jitter_32[32][2];
34 } e_data = {false};
35 
36 static void workbench_taa_jitter_init_order(float (*table)[2], int num)
37 {
38  BLI_jitter_init(table, num);
39 
40  /* find closest element to center */
41  int closest_index = 0;
42  float closest_squared_distance = 1.0f;
43 
44  for (int index = 0; index < num; index++) {
45  const float squared_dist = square_f(table[index][0]) + square_f(table[index][1]);
46  if (squared_dist < closest_squared_distance) {
47  closest_squared_distance = squared_dist;
48  closest_index = index;
49  }
50  }
51 
52  float closest_sample[2];
53  copy_v2_v2(closest_sample, table[closest_index]);
54  for (int index = 0; index < num; index++) {
55  /* move jitter table so that closest sample is in center */
56  sub_v2_v2(table[index], closest_sample);
57  for (int i = 0; i < 2; i++) {
58  /* Avoid samples outside range (wrap around). */
59  table[index][i] = fmodf(table[index][i] + 0.5f, 1.0f);
60  /* Recenter the distribution[-1..1]. */
61  table[index][i] = table[index][i] * 2.0f - 1.0f;
62  }
63  }
64 
65  /* swap center sample to the start of the table */
66  if (closest_index != 0) {
67  swap_v2_v2(table[0], table[closest_index]);
68  }
69 
70  /* Sort list based on farthest distance with previous. */
71  for (int i = 0; i < num - 2; i++) {
72  float f_squared_dist = 0.0;
73  int f_index = i;
74  for (int j = i + 1; j < num; j++) {
75  const float squared_dist = square_f(table[i][0] - table[j][0]) +
76  square_f(table[i][1] - table[j][1]);
77  if (squared_dist > f_squared_dist) {
78  f_squared_dist = squared_dist;
79  f_index = j;
80  }
81  }
82  swap_v2_v2(table[i + 1], table[f_index]);
83  }
84 }
85 
86 static void workbench_taa_jitter_init(void)
87 {
88  if (e_data.init == false) {
89  e_data.init = true;
95  }
96 }
97 
99 {
100  const DRWContextState *draw_ctx = DRW_context_state_get();
101  const Scene *scene = draw_ctx->scene;
102 
103  if (wpd->is_navigating || wpd->is_playback) {
104  /* Only draw using SMAA or no AA when navigating. */
105  return min_ii(wpd->preferences->viewport_aa, 1);
106  }
108  if (draw_ctx->v3d) {
109  return scene->display.viewport_aa;
110  }
111 
112  return scene->display.render_aa;
113  }
114 
115  return wpd->preferences->viewport_aa;
116 }
117 
119 {
120  WORKBENCH_StorageList *stl = vedata->stl;
121  if (stl && stl->wpd) {
122  stl->wpd->view_updated = true;
123  }
124 }
125 
126 /* This function checks if the overlay engine should need center in front depth's.
127  * When that is the case the in front depth are stored and restored. Otherwise it
128  * will be filled with the current sample data. */
130 {
131  WORKBENCH_StorageList *stl = vedata->stl;
132  const DRWContextState *draw_ctx = DRW_context_state_get();
133  const View3D *v3d = draw_ctx->v3d;
134 
135  if (!v3d || (v3d->flag2 & V3D_HIDE_OVERLAYS)) {
136  return false;
137  }
138 
139  if (stl->wpd->is_playback) {
140  return false;
141  }
142 
143  return true;
144 }
145 
147 {
148  WORKBENCH_FramebufferList *fbl = vedata->fbl;
149  WORKBENCH_TextureList *txl = vedata->txl;
150  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
152 
153  wpd->view = NULL;
154 
155  /* Reset complete drawing when navigating or during viewport playback or when
156  * leaving one of those states. In case of multires modifier the navigation
157  * mesh differs from the viewport mesh, so we need to be sure to restart. */
158  if (wpd->taa_sample != 0) {
159  if (wpd->is_navigating || wpd->is_playback) {
160  wpd->taa_sample = 0;
161  wpd->reset_next_sample = true;
162  }
163  else if (wpd->reset_next_sample) {
164  wpd->taa_sample = 0;
165  wpd->reset_next_sample = false;
166  }
167  }
168 
169  /* Reset the TAA when we have already draw a sample, but the sample count differs from previous
170  * time. This removes render artifacts when the viewport anti-aliasing in the user preferences is
171  * set to a lower value. */
172  if (wpd->taa_sample_len != wpd->taa_sample_len_previous) {
173  wpd->taa_sample = 0;
175  }
176 
177  if (wpd->view_updated) {
178  wpd->taa_sample = 0;
179  wpd->view_updated = false;
180  }
181 
182  if (wpd->taa_sample_len > 0 && wpd->valid_history == false) {
183  wpd->taa_sample = 0;
184  }
185 
186  {
187  float persmat[4][4];
188  DRW_view_persmat_get(NULL, persmat, false);
189  if (!equals_m4m4(persmat, wpd->last_mat)) {
190  copy_m4_m4(wpd->last_mat, persmat);
191  wpd->taa_sample = 0;
192  }
193  }
194 
195  if (wpd->taa_sample_len > 0) {
197 
200  const bool in_front_history = workbench_in_front_history_needed(vedata);
201  if (in_front_history) {
203  }
204  else {
206  }
207 
210 
211  GPU_framebuffer_ensure_config(&fbl->antialiasing_fb,
212  {
213  GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_tx),
214  GPU_ATTACHMENT_TEXTURE(txl->history_buffer_tx),
215  });
216  if (in_front_history) {
217  GPU_framebuffer_ensure_config(&fbl->antialiasing_in_front_fb,
218  {
219  GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_in_front_tx),
220  });
221  }
222 
223  GPU_framebuffer_ensure_config(&fbl->smaa_edge_fb,
224  {
225  GPU_ATTACHMENT_NONE,
226  GPU_ATTACHMENT_TEXTURE(wpd->smaa_edge_tx),
227  });
228 
229  GPU_framebuffer_ensure_config(&fbl->smaa_weight_fb,
230  {
231  GPU_ATTACHMENT_NONE,
232  GPU_ATTACHMENT_TEXTURE(wpd->smaa_weight_tx),
233  });
234 
235  /* TODO: could be shared for all viewports. */
236  if (txl->smaa_search_tx == NULL) {
238  "smaa_search", SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1, GPU_R8, NULL);
240 
242  "smaa_area", AREATEX_WIDTH, AREATEX_HEIGHT, 1, GPU_RG8, NULL);
244 
247  }
248  }
249  else {
250  /* Cleanup */
256  }
257 }
258 
259 static float filter_blackman_harris(float x, const float width)
260 {
261  if (x > width * 0.5f) {
262  return 0.0f;
263  }
264  x = 2.0f * M_PI * clamp_f((x / width + 0.5f), 0.0f, 1.0f);
265  return 0.35875f - 0.48829f * cosf(x) + 0.14128f * cosf(2.0f * x) - 0.01168f * cosf(3.0f * x);
266 }
267 
268 /* Compute weights for the 3x3 neighborhood using a 1.5px filter. */
269 static void workbench_antialiasing_weights_get(const float offset[2],
270  float r_weights[9],
271  float *r_weight_sum)
272 {
273  /* NOTE: If filter width is bigger than 2.0f, then we need to sample more neighborhood. */
274  const float filter_width = 2.0f;
275  *r_weight_sum = 0.0f;
276  int i = 0;
277  for (int x = -1; x <= 1; x++) {
278  for (int y = -1; y <= 1; y++, i++) {
279  float sample_co[2] = {x, y};
280  sub_v2_v2(sample_co, offset);
281  float r = len_v2(sample_co);
282  /* fclem: is radial distance ok here? */
283  float weight = filter_blackman_harris(r, filter_width);
284  *r_weight_sum += weight;
285  r_weights[i] = weight;
286  }
287  }
288 }
289 
291 {
292  WORKBENCH_TextureList *txl = vedata->txl;
293  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
294  WORKBENCH_PassList *psl = vedata->psl;
296  DRWShadingGroup *grp = NULL;
297 
298  if (wpd->taa_sample_len == 0) {
299  return;
300  }
301 
302  {
305 
307  grp = DRW_shgroup_create(shader, psl->aa_accum_ps);
308  DRW_shgroup_uniform_texture_ex(grp, "colorBuffer", dtxl->color, GPU_SAMPLER_DEFAULT);
309  DRW_shgroup_uniform_float(grp, "samplesWeights", wpd->taa_weights, 9);
311  }
312 
313  const float *size = DRW_viewport_size_get();
314  const float *sizeinv = DRW_viewport_invert_size_get();
315  const float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]};
316 
317  {
318  /* Stage 1: Edge detection. */
320 
322  grp = DRW_shgroup_create(sh, psl->aa_edge_ps);
323  DRW_shgroup_uniform_texture(grp, "colorTex", txl->history_buffer_tx);
324  DRW_shgroup_uniform_vec4_copy(grp, "viewportMetrics", metrics);
325 
326  DRW_shgroup_clear_framebuffer(grp, GPU_COLOR_BIT, 0, 0, 0, 0, 0.0f, 0x0);
328  }
329  {
330  /* Stage 2: Blend Weight/Coord. */
332 
334  grp = DRW_shgroup_create(sh, psl->aa_weight_ps);
335  DRW_shgroup_uniform_texture(grp, "edgesTex", wpd->smaa_edge_tx);
336  DRW_shgroup_uniform_texture(grp, "areaTex", txl->smaa_area_tx);
337  DRW_shgroup_uniform_texture(grp, "searchTex", txl->smaa_search_tx);
338  DRW_shgroup_uniform_vec4_copy(grp, "viewportMetrics", metrics);
339 
340  DRW_shgroup_clear_framebuffer(grp, GPU_COLOR_BIT, 0, 0, 0, 0, 0.0f, 0x0);
342  }
343  {
344  /* Stage 3: Resolve. */
346 
348  grp = DRW_shgroup_create(sh, psl->aa_resolve_ps);
349  DRW_shgroup_uniform_texture(grp, "blendTex", wpd->smaa_weight_tx);
350  DRW_shgroup_uniform_texture(grp, "colorTex", txl->history_buffer_tx);
351  DRW_shgroup_uniform_vec4_copy(grp, "viewportMetrics", metrics);
352  DRW_shgroup_uniform_float(grp, "mixFactor", &wpd->smaa_mix_factor, 1);
353  DRW_shgroup_uniform_float(grp, "taaAccumulatedWeight", &wpd->taa_weight_accum, 1);
354 
356  }
357 }
358 
360 {
361  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
362 
363  if (wpd->taa_sample_len == 0) {
364  /* AA disabled. */
365  return true;
366  }
367 
368  if (wpd->taa_sample >= wpd->taa_sample_len) {
369  /* TAA accumulation has finish. Just copy the result back */
370  return false;
371  }
372 
373  const float *viewport_size = DRW_viewport_size_get();
374  const DRWView *default_view = DRW_view_default_get();
375  float *transform_offset;
376 
377  switch (wpd->taa_sample_len) {
378  default:
379  case 5:
380  transform_offset = e_data.jitter_5[min_ii(wpd->taa_sample, 5)];
381  break;
382  case 8:
383  transform_offset = e_data.jitter_8[min_ii(wpd->taa_sample, 8)];
384  break;
385  case 11:
386  transform_offset = e_data.jitter_11[min_ii(wpd->taa_sample, 11)];
387  break;
388  case 16:
389  transform_offset = e_data.jitter_16[min_ii(wpd->taa_sample, 16)];
390  break;
391  case 32:
392  transform_offset = e_data.jitter_32[min_ii(wpd->taa_sample, 32)];
393  break;
394  }
395 
396  workbench_antialiasing_weights_get(transform_offset, wpd->taa_weights, &wpd->taa_weights_sum);
397 
398  /* construct new matrices from transform delta */
399  float winmat[4][4], viewmat[4][4], persmat[4][4];
400  DRW_view_winmat_get(default_view, winmat, false);
401  DRW_view_viewmat_get(default_view, viewmat, false);
402  DRW_view_persmat_get(default_view, persmat, false);
403 
404  window_translate_m4(winmat,
405  persmat,
406  transform_offset[0] / viewport_size[0],
407  transform_offset[1] / viewport_size[1]);
408 
409  if (wpd->view) {
410  /* When rendering just update the view. This avoids recomputing the culling. */
411  DRW_view_update_sub(wpd->view, viewmat, winmat);
412  }
413  else {
414  /* TAA is not making a big change to the matrices.
415  * Reuse the main view culling by creating a sub-view. */
416  wpd->view = DRW_view_create_sub(default_view, viewmat, winmat);
417  }
419  return true;
420 }
421 
423 {
424  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
425  WORKBENCH_FramebufferList *fbl = vedata->fbl;
426  WORKBENCH_TextureList *txl = vedata->txl;
427  WORKBENCH_PassList *psl = vedata->psl;
430 
431  if (wpd->taa_sample_len == 0) {
432  /* AA disabled. */
433  /* Just set sample to 1 to avoid rendering indefinitely. */
434  wpd->taa_sample = 1;
435  wpd->valid_history = false;
436  return;
437  }
438 
445  const bool last_sample = wpd->taa_sample + 1 == wpd->taa_sample_len;
446  const bool taa_finished = wpd->taa_sample >= wpd->taa_sample_len;
447  if (wpd->taa_sample == 0) {
448  wpd->taa_weight_accum = wpd->taa_weights_sum;
449  wpd->valid_history = true;
450 
453  /* In playback mode, we are sure the next redraw will not use the same viewmatrix.
454  * In this case no need to save the depth buffer. */
455  if (!wpd->is_playback) {
457  }
458  if (workbench_in_front_history_needed(vedata)) {
460  }
461  }
462  else {
463  if (!taa_finished) {
464  /* Accumulate result to the TAA buffer. */
467  wpd->taa_weight_accum += wpd->taa_weights_sum;
468  }
469  /* Copy back the saved depth buffer for correct overlays. */
471  if (workbench_in_front_history_needed(vedata)) {
473  }
474  }
475 
476  if (!DRW_state_is_image_render() || last_sample) {
477  /* After a certain point SMAA is no longer necessary. */
478  wpd->smaa_mix_factor = 1.0f - clamp_f(wpd->taa_sample / 4.0f, 0.0f, 1.0f);
479 
480  if (wpd->smaa_mix_factor > 0.0f) {
483 
486  }
487 
490  }
491 
492  if (!taa_finished) {
493  wpd->taa_sample++;
494  }
495 
496  if (!DRW_state_is_image_render() && wpd->taa_sample < wpd->taa_sample_len) {
498  }
499 }
void BLI_jitter_init(float(*jitarr)[2], int num)
Definition: jitter_2d.c:126
MINLINE int min_ii(int a, int b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE float square_f(float a)
#define M_PI
Definition: BLI_math_base.h:20
void window_translate_m4(float winmat[4][4], float perspmat[4][4], float x, float y)
Definition: math_geom.c:4587
bool equals_m4m4(const float mat1[4][4], const float mat2[4][4])
Definition: math_matrix.c:2531
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
MINLINE void swap_v2_v2(float a[2], float b[2])
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
#define V3D_HIDE_OVERLAYS
@ DRW_TEX_FILTER
Definition: DRW_render.h:140
#define DRW_PASS_INSTANCE_CREATE(pass, original, state)
Definition: DRW_render.h:691
@ DRW_STATE_BLEND_ADD_FULL
Definition: DRW_render.h:326
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:303
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:690
#define DRW_TEXTURE_FREE_SAFE(tex)
Definition: DRW_render.h:183
@ GPU_COLOR_BIT
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
_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 width
struct GPUShader GPUShader
Definition: GPU_shader.h:20
@ GPU_SAMPLER_DEFAULT
Definition: GPU_texture.h:26
void GPU_texture_copy(GPUTexture *dst, GPUTexture *src)
Definition: gpu_texture.cc:503
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:174
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
Definition: gpu_texture.cc:444
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
Definition: gpu_texture.cc:518
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:291
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
@ GPU_RG8
Definition: GPU_texture.h:97
@ GPU_R8
Definition: GPU_texture.h:107
@ GPU_RGBA8
Definition: GPU_texture.h:87
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
#define cosf(x)
Definition: cuda/compat.h:101
Scene scene
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
bool DRW_state_is_image_render(void)
const float * DRW_viewport_invert_size_get(void)
Definition: draw_manager.c:293
void DRW_viewport_request_redraw(void)
Definition: draw_manager.c:643
DefaultTextureList * DRW_viewport_texture_list_get(void)
Definition: draw_manager.c:638
void DRW_view_persmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
const DRWView * DRW_view_default_get(void)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, Object *ob, uint tri_count)
void DRW_view_winmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_shgroup_uniform_texture_ex(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex, eGPUSamplerState sampler_state)
DRWView * DRW_view_create_sub(const DRWView *parent_view, const float viewmat[4][4], const float winmat[4][4])
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_shgroup_clear_framebuffer(DRWShadingGroup *shgroup, eGPUFrameBufferBits channels, uchar r, uchar g, uchar b, uchar a, float depth, uchar stencil)
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_view_update_sub(DRWView *view, const float viewmat[4][4], const float winmat[4][4])
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_draw_pass(DRWPass *pass)
void DRW_view_set_active(const DRWView *view)
void DRW_texture_ensure_fullscreen_2d(GPUTexture **tex, eGPUTextureFormat format, DRWTextureFlag flags)
GPUTexture * DRW_texture_pool_query_fullscreen(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
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_gpu_kernel_postfix ccl_global float int int int int sh
#define fmodf(x, y)
Definition: metal/compat.h:230
const unsigned char searchTexBytes[]
const unsigned char areaTexBytes[]
Definition: smaa_textures.c:17
#define SEARCHTEX_HEIGHT
Definition: smaa_textures.h:22
#define SEARCHTEX_WIDTH
Definition: smaa_textures.h:21
#define AREATEX_HEIGHT
Definition: smaa_textures.h:11
#define AREATEX_WIDTH
Definition: smaa_textures.h:10
struct Scene * scene
Definition: DRW_render.h:979
struct View3D * v3d
Definition: DRW_render.h:976
struct GPUFrameBuffer * default_fb
struct GPUTexture * depth
struct GPUTexture * depth_in_front
struct GPUTexture * color
struct SceneDisplay display
WORKBENCH_FramebufferList * fbl
WORKBENCH_PassList * psl
WORKBENCH_StorageList * stl
WORKBENCH_TextureList * txl
struct GPUFrameBuffer * smaa_edge_fb
struct GPUFrameBuffer * antialiasing_fb
struct GPUFrameBuffer * antialiasing_in_front_fb
struct GPUFrameBuffer * smaa_weight_fb
struct DRWPass * aa_weight_ps
struct DRWPass * aa_accum_ps
struct DRWPass * aa_edge_ps
struct DRWPass * aa_accum_replace_ps
struct DRWPass * aa_resolve_ps
const UserDef * preferences
struct GPUTexture * smaa_edge_tx
struct GPUTexture * smaa_weight_tx
struct WORKBENCH_PrivateData * wpd
struct GPUTexture * depth_buffer_in_front_tx
struct GPUTexture * depth_buffer_tx
struct GPUTexture * smaa_search_tx
struct GPUTexture * smaa_area_tx
struct GPUTexture * history_buffer_tx
void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata)
float jitter_5[5][2]
static void workbench_taa_jitter_init_order(float(*table)[2], int num)
float jitter_16[16][2]
static void workbench_taa_jitter_init(void)
bool workbench_antialiasing_setup(WORKBENCH_Data *vedata)
void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata)
float jitter_8[8][2]
float jitter_11[11][2]
static struct @269 e_data
float jitter_32[32][2]
void workbench_antialiasing_cache_init(WORKBENCH_Data *vedata)
static float filter_blackman_harris(float x, const float width)
static bool workbench_in_front_history_needed(WORKBENCH_Data *vedata)
int workbench_antialiasing_sample_count_get(WORKBENCH_PrivateData *wpd)
void workbench_antialiasing_view_updated(WORKBENCH_Data *vedata)
static void workbench_antialiasing_weights_get(const float offset[2], float r_weights[9], float *r_weight_sum)
GPUShader * workbench_shader_antialiasing_get(int stage)
GPUShader * workbench_shader_antialiasing_accumulation_get(void)