Blender  V2.93
workbench_effect_antialiasing.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 2020, Blender Foundation.
17  */
18 
34 #include "ED_screen.h"
35 
36 #include "BLI_jitter_2d.h"
37 
38 #include "smaa_textures.h"
39 
40 #include "workbench_private.h"
41 
42 static struct {
43  bool init;
44  float jitter_5[5][2];
45  float jitter_8[8][2];
46  float jitter_11[11][2];
47  float jitter_16[16][2];
48  float jitter_32[32][2];
49 } e_data = {false};
50 
51 static void workbench_taa_jitter_init_order(float (*table)[2], int num)
52 {
53  BLI_jitter_init(table, num);
54 
55  /* find closest element to center */
56  int closest_index = 0;
57  float closest_squared_distance = 1.0f;
58 
59  for (int index = 0; index < num; index++) {
60  const float squared_dist = square_f(table[index][0]) + square_f(table[index][1]);
61  if (squared_dist < closest_squared_distance) {
62  closest_squared_distance = squared_dist;
63  closest_index = index;
64  }
65  }
66 
67  float closest_sample[2];
68  copy_v2_v2(closest_sample, table[closest_index]);
69  for (int index = 0; index < num; index++) {
70  /* move jitter table so that closest sample is in center */
71  sub_v2_v2(table[index], closest_sample);
72  for (int i = 0; i < 2; i++) {
73  /* Avoid samples outside range (wrap around). */
74  table[index][i] = fmodf(table[index][i] + 0.5f, 1.0f);
75  /* Recenter the distribution[-1..1]. */
76  table[index][i] = table[index][i] * 2.0f - 1.0f;
77  }
78  }
79 
80  /* swap center sample to the start of the table */
81  if (closest_index != 0) {
82  swap_v2_v2(table[0], table[closest_index]);
83  }
84 
85  /* Sort list based on farthest distance with previous. */
86  for (int i = 0; i < num - 2; i++) {
87  float f_squared_dist = 0.0;
88  int f_index = i;
89  for (int j = i + 1; j < num; j++) {
90  const float squared_dist = square_f(table[i][0] - table[j][0]) +
91  square_f(table[i][1] - table[j][1]);
92  if (squared_dist > f_squared_dist) {
93  f_squared_dist = squared_dist;
94  f_index = j;
95  }
96  }
97  swap_v2_v2(table[i + 1], table[f_index]);
98  }
99 }
100 
101 static void workbench_taa_jitter_init(void)
102 {
103  if (e_data.init == false) {
104  e_data.init = true;
110  }
111 }
112 
114 {
115  const DRWContextState *draw_ctx = DRW_context_state_get();
116  const Scene *scene = draw_ctx->scene;
117 
118  if (wpd->is_navigating || wpd->is_playback) {
119  /* Only draw using SMAA or no AA when navigating. */
120  return min_ii(wpd->preferences->viewport_aa, 1);
121  }
123  if (draw_ctx->v3d) {
124  return scene->display.viewport_aa;
125  }
126 
127  return scene->display.render_aa;
128  }
129 
130  return wpd->preferences->viewport_aa;
131 }
132 
134 {
135  WORKBENCH_StorageList *stl = vedata->stl;
136  if (stl && stl->wpd) {
137  stl->wpd->view_updated = true;
138  }
139 }
140 
141 /* This function checks if the overlay engine should need center in front depth's.
142  * When that is the case the in front depth are stored and restored. Otherwise it
143  * will be filled with the current sample data. */
145 {
146  WORKBENCH_StorageList *stl = vedata->stl;
147  const DRWContextState *draw_ctx = DRW_context_state_get();
148  const View3D *v3d = draw_ctx->v3d;
149 
150  if (!v3d || (v3d->flag2 & V3D_HIDE_OVERLAYS)) {
151  return false;
152  }
153 
154  if (stl->wpd->is_playback) {
155  return false;
156  }
157 
158  return true;
159 }
160 
162 {
163  WORKBENCH_FramebufferList *fbl = vedata->fbl;
164  WORKBENCH_TextureList *txl = vedata->txl;
165  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
167 
168  wpd->view = NULL;
169 
170  /* Reset complete drawing when navigating or during viewport playback or when
171  * leaving one of those states. In case of multires modifier the navigation
172  * mesh differs from the viewport mesh, so we need to be sure to restart. */
173  if (wpd->taa_sample != 0) {
174  if (wpd->is_navigating || wpd->is_playback) {
175  wpd->taa_sample = 0;
176  wpd->reset_next_sample = true;
177  }
178  else if (wpd->reset_next_sample) {
179  wpd->taa_sample = 0;
180  wpd->reset_next_sample = false;
181  }
182  }
183 
184  /* Reset the TAA when we have already draw a sample, but the sample count differs from previous
185  * time. This removes render artifacts when the viewport anti-aliasing in the user preferences is
186  * set to a lower value. */
187  if (wpd->taa_sample_len != wpd->taa_sample_len_previous) {
188  wpd->taa_sample = 0;
190  }
191 
192  if (wpd->view_updated) {
193  wpd->taa_sample = 0;
194  wpd->view_updated = false;
195  }
196 
197  if (wpd->taa_sample_len > 0 && wpd->valid_history == false) {
198  wpd->taa_sample = 0;
199  }
200 
201  {
202  float persmat[4][4];
203  DRW_view_persmat_get(NULL, persmat, false);
204  if (!equals_m4m4(persmat, wpd->last_mat)) {
205  copy_m4_m4(wpd->last_mat, persmat);
206  wpd->taa_sample = 0;
207  }
208  }
209 
210  if (wpd->taa_sample_len > 0) {
212 
215  const bool in_front_history = workbench_in_front_history_needed(vedata);
216  if (in_front_history) {
218  }
219  else {
221  }
222 
225 
226  GPU_framebuffer_ensure_config(&fbl->antialiasing_fb,
227  {
228  GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_tx),
229  GPU_ATTACHMENT_TEXTURE(txl->history_buffer_tx),
230  });
231  if (in_front_history) {
232  GPU_framebuffer_ensure_config(&fbl->antialiasing_in_front_fb,
233  {
234  GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_in_front_tx),
235  });
236  }
237 
238  GPU_framebuffer_ensure_config(&fbl->smaa_edge_fb,
239  {
240  GPU_ATTACHMENT_NONE,
241  GPU_ATTACHMENT_TEXTURE(wpd->smaa_edge_tx),
242  });
243 
244  GPU_framebuffer_ensure_config(&fbl->smaa_weight_fb,
245  {
246  GPU_ATTACHMENT_NONE,
247  GPU_ATTACHMENT_TEXTURE(wpd->smaa_weight_tx),
248  });
249 
250  /* TODO could be shared for all viewports. */
251  if (txl->smaa_search_tx == NULL) {
253  "smaa_search", SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1, GPU_R8, NULL);
255 
257  "smaa_area", AREATEX_WIDTH, AREATEX_HEIGHT, 1, GPU_RG8, NULL);
259 
262  }
263  }
264  else {
265  /* Cleanup */
271  }
272 }
273 
274 static float filter_blackman_harris(float x, const float width)
275 {
276  if (x > width * 0.5f) {
277  return 0.0f;
278  }
279  x = 2.0f * M_PI * clamp_f((x / width + 0.5f), 0.0f, 1.0f);
280  return 0.35875f - 0.48829f * cosf(x) + 0.14128f * cosf(2.0f * x) - 0.01168f * cosf(3.0f * x);
281 }
282 
283 /* Compute weights for the 3x3 neighborhood using a 1.5px filter. */
284 static void workbench_antialiasing_weights_get(const float offset[2],
285  float r_weights[9],
286  float *r_weight_sum)
287 {
288  /* NOTE: If filter width is bigger than 2.0f, then we need to sample more neighborhood. */
289  const float filter_width = 2.0f;
290  *r_weight_sum = 0.0f;
291  int i = 0;
292  for (int x = -1; x <= 1; x++) {
293  for (int y = -1; y <= 1; y++, i++) {
294  float sample_co[2] = {x, y};
295  sub_v2_v2(sample_co, offset);
296  float r = len_v2(sample_co);
297  /* fclem: is radial distance ok here? */
298  float weight = filter_blackman_harris(r, filter_width);
299  *r_weight_sum += weight;
300  r_weights[i] = weight;
301  }
302  }
303 }
304 
306 {
307  WORKBENCH_TextureList *txl = vedata->txl;
308  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
309  WORKBENCH_PassList *psl = vedata->psl;
311  DRWShadingGroup *grp = NULL;
312 
313  if (wpd->taa_sample_len == 0) {
314  return;
315  }
316 
317  {
320 
323  DRW_shgroup_uniform_texture_ex(grp, "colorBuffer", dtxl->color, GPU_SAMPLER_DEFAULT);
324  DRW_shgroup_uniform_float(grp, "samplesWeights", wpd->taa_weights, 9);
326  }
327 
328  const float *size = DRW_viewport_size_get();
329  const float *sizeinv = DRW_viewport_invert_size_get();
330  const float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]};
331 
332  {
333  /* Stage 1: Edge detection. */
335 
337  grp = DRW_shgroup_create(sh, psl->aa_edge_ps);
338  DRW_shgroup_uniform_texture(grp, "colorTex", txl->history_buffer_tx);
339  DRW_shgroup_uniform_vec4_copy(grp, "viewportMetrics", metrics);
340 
341  DRW_shgroup_clear_framebuffer(grp, GPU_COLOR_BIT, 0, 0, 0, 0, 0.0f, 0x0);
343  }
344  {
345  /* Stage 2: Blend Weight/Coord. */
347 
349  grp = DRW_shgroup_create(sh, psl->aa_weight_ps);
350  DRW_shgroup_uniform_texture(grp, "edgesTex", wpd->smaa_edge_tx);
351  DRW_shgroup_uniform_texture(grp, "areaTex", txl->smaa_area_tx);
352  DRW_shgroup_uniform_texture(grp, "searchTex", txl->smaa_search_tx);
353  DRW_shgroup_uniform_vec4_copy(grp, "viewportMetrics", metrics);
354 
355  DRW_shgroup_clear_framebuffer(grp, GPU_COLOR_BIT, 0, 0, 0, 0, 0.0f, 0x0);
357  }
358  {
359  /* Stage 3: Resolve. */
361 
363  grp = DRW_shgroup_create(sh, psl->aa_resolve_ps);
364  DRW_shgroup_uniform_texture(grp, "blendTex", wpd->smaa_weight_tx);
365  DRW_shgroup_uniform_texture(grp, "colorTex", txl->history_buffer_tx);
366  DRW_shgroup_uniform_vec4_copy(grp, "viewportMetrics", metrics);
367  DRW_shgroup_uniform_float(grp, "mixFactor", &wpd->smaa_mix_factor, 1);
368  DRW_shgroup_uniform_float(grp, "taaAccumulatedWeight", &wpd->taa_weight_accum, 1);
369 
371  }
372 }
373 
374 /* Return true if render is not cached. */
376 {
377  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
378 
379  if (wpd->taa_sample_len == 0) {
380  /* AA disabled. */
381  return true;
382  }
383 
384  if (wpd->taa_sample >= wpd->taa_sample_len) {
385  /* TAA accumulation has finish. Just copy the result back */
386  return false;
387  }
388 
389  const float *viewport_size = DRW_viewport_size_get();
390  const DRWView *default_view = DRW_view_default_get();
391  float *transform_offset;
392 
393  switch (wpd->taa_sample_len) {
394  default:
395  case 5:
396  transform_offset = e_data.jitter_5[min_ii(wpd->taa_sample, 5)];
397  break;
398  case 8:
399  transform_offset = e_data.jitter_8[min_ii(wpd->taa_sample, 8)];
400  break;
401  case 11:
402  transform_offset = e_data.jitter_11[min_ii(wpd->taa_sample, 11)];
403  break;
404  case 16:
405  transform_offset = e_data.jitter_16[min_ii(wpd->taa_sample, 16)];
406  break;
407  case 32:
408  transform_offset = e_data.jitter_32[min_ii(wpd->taa_sample, 32)];
409  break;
410  }
411 
412  workbench_antialiasing_weights_get(transform_offset, wpd->taa_weights, &wpd->taa_weights_sum);
413 
414  /* construct new matrices from transform delta */
415  float winmat[4][4], viewmat[4][4], persmat[4][4];
416  DRW_view_winmat_get(default_view, winmat, false);
417  DRW_view_viewmat_get(default_view, viewmat, false);
418  DRW_view_persmat_get(default_view, persmat, false);
419 
420  window_translate_m4(winmat,
421  persmat,
422  transform_offset[0] / viewport_size[0],
423  transform_offset[1] / viewport_size[1]);
424 
425  if (wpd->view) {
426  /* When rendering just update the view. This avoids recomputing the culling. */
427  DRW_view_update_sub(wpd->view, viewmat, winmat);
428  }
429  else {
430  /* TAA is not making a big change to the matrices.
431  * Reuse the main view culling by creating a sub-view. */
432  wpd->view = DRW_view_create_sub(default_view, viewmat, winmat);
433  }
435  return true;
436 }
437 
439 {
440  WORKBENCH_PrivateData *wpd = vedata->stl->wpd;
441  WORKBENCH_FramebufferList *fbl = vedata->fbl;
442  WORKBENCH_TextureList *txl = vedata->txl;
443  WORKBENCH_PassList *psl = vedata->psl;
446 
447  if (wpd->taa_sample_len == 0) {
448  /* AA disabled. */
449  /* Just set sample to 1 to avoid rendering indefinitely. */
450  wpd->taa_sample = 1;
451  wpd->valid_history = false;
452  return;
453  }
454 
461  const bool last_sample = wpd->taa_sample + 1 == wpd->taa_sample_len;
462  const bool taa_finished = wpd->taa_sample >= wpd->taa_sample_len;
463  if (wpd->taa_sample == 0) {
464  wpd->taa_weight_accum = wpd->taa_weights_sum;
465  wpd->valid_history = true;
466 
469  /* In playback mode, we are sure the next redraw will not use the same viewmatrix.
470  * In this case no need to save the depth buffer. */
471  if (!wpd->is_playback) {
473  }
474  if (workbench_in_front_history_needed(vedata)) {
476  }
477  }
478  else {
479  if (!taa_finished) {
480  /* Accumulate result to the TAA buffer. */
483  wpd->taa_weight_accum += wpd->taa_weights_sum;
484  }
485  /* Copy back the saved depth buffer for correct overlays. */
487  if (workbench_in_front_history_needed(vedata)) {
489  }
490  }
491 
492  if (!DRW_state_is_image_render() || last_sample) {
493  /* After a certain point SMAA is no longer necessary. */
494  wpd->smaa_mix_factor = 1.0f - clamp_f(wpd->taa_sample / 4.0f, 0.0f, 1.0f);
495 
496  if (wpd->smaa_mix_factor > 0.0f) {
499 
502  }
503 
506  }
507 
508  if (!taa_finished) {
509  wpd->taa_sample++;
510  }
511 
512  if (!DRW_state_is_image_render() && wpd->taa_sample < wpd->taa_sample_len) {
514  }
515 }
void BLI_jitter_init(float(*jitarr)[2], int num)
Definition: jitter_2d.c:142
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:38
void window_translate_m4(float winmat[4][4], float perspmat[4][4], const float x, const float y)
Definition: math_geom.c:4877
bool equals_m4m4(const float mat1[4][4], const float mat2[4][4])
Definition: math_matrix.c:2612
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
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:139
#define DRW_PASS_INSTANCE_CREATE(pass, original, state)
Definition: DRW_render.h:594
@ DRW_STATE_BLEND_ADD_FULL
Definition: DRW_render.h:338
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:593
#define DRW_TEXTURE_FREE_SAFE(tex)
Definition: DRW_render.h:180
@ 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 GLsizei width
_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
void GPU_texture_copy(GPUTexture *dst, GPUTexture *src)
Definition: gpu_texture.cc:453
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:175
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
Definition: gpu_texture.cc:391
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
Definition: gpu_texture.cc:468
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:250
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:121
@ GPU_RGBA16F
Definition: GPU_texture.h:94
@ GPU_RG8
Definition: GPU_texture.h:98
@ GPU_R8
Definition: GPU_texture.h:108
@ GPU_RGBA8
Definition: GPU_texture.h:88
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
Scene scene
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
bool DRW_state_is_image_render(void)
const float * DRW_viewport_invert_size_get(void)
Definition: draw_manager.c:444
void DRW_viewport_request_redraw(void)
Definition: draw_manager.c:707
DefaultTextureList * DRW_viewport_texture_list_get(void)
Definition: draw_manager.c:702
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_view_set_active(DRWView *view)
void DRW_draw_pass(DRWPass *pass)
void DRW_texture_ensure_fullscreen_2d(GPUTexture **tex, eGPUTextureFormat format, DRWTextureFlag flags)
GPUTexture * DRW_texture_pool_query_fullscreen(eGPUTextureFormat format, DrawEngineType *engine_type)
#define cosf(x)
#define fmodf(x, y)
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
#define SEARCHTEX_HEIGHT
static const unsigned char searchTexBytes[]
#define SEARCHTEX_WIDTH
#define AREATEX_HEIGHT
Definition: smaa_textures.h:32
static const unsigned char areaTexBytes[]
Definition: smaa_textures.h:43
#define AREATEX_WIDTH
Definition: smaa_textures.h:31
struct Scene * scene
Definition: DRW_render.h:745
struct View3D * v3d
Definition: DRW_render.h:742
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 @256 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)