Blender  V2.93
eevee_motion_blur.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 
25 #include "DRW_render.h"
26 
27 #include "BLI_rand.h"
28 #include "BLI_string_utils.h"
29 
30 #include "BKE_animsys.h"
31 #include "BKE_camera.h"
32 #include "BKE_object.h"
33 #include "BKE_screen.h"
34 
35 #include "DNA_anim_types.h"
36 #include "DNA_camera_types.h"
37 #include "DNA_mesh_types.h"
38 #include "DNA_modifier_types.h"
39 #include "DNA_particle_types.h"
40 #include "DNA_rigidbody_types.h"
41 #include "DNA_screen_types.h"
42 
43 #include "ED_screen.h"
44 
45 #include "DEG_depsgraph.h"
46 #include "DEG_depsgraph_query.h"
47 
48 #include "GPU_batch.h"
49 #include "GPU_texture.h"
50 #include "eevee_private.h"
51 
53 {
54  EEVEE_StorageList *stl = vedata->stl;
55  EEVEE_FramebufferList *fbl = vedata->fbl;
56  EEVEE_EffectsInfo *effects = stl->effects;
57 
58  const DRWContextState *draw_ctx = DRW_context_state_get();
59  Scene *scene = draw_ctx->scene;
60 
61  /* Viewport not supported for now. */
63  return 0;
64  }
65 
67 
68  if ((effects->motion_blur_max > 0) && (scene->eevee.flag & SCE_EEVEE_MOTION_BLUR_ENABLED)) {
70  int mb_step = effects->motion_blur_step;
71  DRW_view_viewmat_get(NULL, effects->motion_blur.camera[mb_step].viewmat, false);
72  DRW_view_persmat_get(NULL, effects->motion_blur.camera[mb_step].persmat, false);
73  DRW_view_persmat_get(NULL, effects->motion_blur.camera[mb_step].persinv, true);
74  }
75 
76  const float *fs_size = DRW_viewport_size_get();
77  const int tx_size[2] = {
78  1 + ((int)fs_size[0] / EEVEE_VELOCITY_TILE_SIZE),
79  1 + ((int)fs_size[1] / EEVEE_VELOCITY_TILE_SIZE),
80  };
81 
83  tx_size[0], fs_size[1], GPU_RGBA16, &draw_engine_eevee_type);
84  GPU_framebuffer_ensure_config(&fbl->velocity_tiles_fb[0],
85  {
86  GPU_ATTACHMENT_NONE,
87  GPU_ATTACHMENT_TEXTURE(effects->velocity_tiles_x_tx),
88  });
89 
91  tx_size[0], tx_size[1], GPU_RGBA16, &draw_engine_eevee_type);
92  GPU_framebuffer_ensure_config(&fbl->velocity_tiles_fb[1],
93  {
94  GPU_ATTACHMENT_NONE,
95  GPU_ATTACHMENT_TEXTURE(effects->velocity_tiles_tx),
96  });
97 
99  }
100  return 0;
101 }
102 
103 void EEVEE_motion_blur_step_set(EEVEE_Data *vedata, int step)
104 {
105  BLI_assert(step < 3);
106  vedata->stl->effects->motion_blur_step = step;
107 }
108 
110 {
111  EEVEE_EffectsInfo *effects = vedata->stl->effects;
113  int mb_step = effects->motion_blur_step;
114  DRW_view_viewmat_get(NULL, effects->motion_blur.camera[mb_step].viewmat, false);
115  DRW_view_persmat_get(NULL, effects->motion_blur.camera[mb_step].persmat, false);
116  DRW_view_persmat_get(NULL, effects->motion_blur.camera[mb_step].persinv, true);
117  }
118 
121 }
122 
124 {
125  EEVEE_PassList *psl = vedata->psl;
126  EEVEE_StorageList *stl = vedata->stl;
127  EEVEE_EffectsInfo *effects = stl->effects;
128  EEVEE_MotionBlurData *mb_data = &effects->motion_blur;
130  const DRWContextState *draw_ctx = DRW_context_state_get();
131  Scene *scene = draw_ctx->scene;
132 
133  if ((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0) {
134  const float *fs_size = DRW_viewport_size_get();
135  const int tx_size[2] = {
138  };
139 
141 
142  DRWShadingGroup *grp;
143  {
146 
147  /* Create max velocity tiles in 2 passes. One for X and one for Y */
149  grp = DRW_shgroup_create(sh, psl->velocity_tiles_x);
150  DRW_shgroup_uniform_texture(grp, "velocityBuffer", effects->velocity_tx);
151  DRW_shgroup_uniform_ivec2_copy(grp, "velocityBufferSize", (int[2]){fs_size[0], fs_size[1]});
152  DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
153  DRW_shgroup_uniform_vec2(grp, "viewportSizeInv", DRW_viewport_invert_size_get(), 1);
154  DRW_shgroup_uniform_ivec2_copy(grp, "gatherStep", (int[2]){1, 0});
156 
157  grp = DRW_shgroup_create(sh, psl->velocity_tiles);
158  DRW_shgroup_uniform_texture(grp, "velocityBuffer", effects->velocity_tiles_x_tx);
159  DRW_shgroup_uniform_ivec2_copy(grp, "velocityBufferSize", (int[2]){tx_size[0], fs_size[1]});
160  DRW_shgroup_uniform_ivec2_copy(grp, "gatherStep", (int[2]){0, 1});
162 
163  /* Expand max tiles by keeping the max tile in each tile neighborhood. */
166  for (int i = 0; i < 2; i++) {
167  GPUTexture *tile_tx = (i == 0) ? effects->velocity_tiles_tx : effects->velocity_tiles_x_tx;
169  grp = DRW_shgroup_create(sh_expand, psl->velocity_tiles_expand[i]);
170  DRW_shgroup_uniform_ivec2_copy(grp, "velocityBufferSize", tx_size);
171  DRW_shgroup_uniform_texture(grp, "velocityBuffer", tile_tx);
172  DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
173  DRW_shgroup_uniform_vec2(grp, "viewportSizeInv", DRW_viewport_invert_size_get(), 1);
175  }
176  }
177  {
180  int expand_steps = 1 + (max_ii(0, effects->motion_blur_max - 1) / EEVEE_VELOCITY_TILE_SIZE);
181  GPUTexture *tile_tx = (expand_steps & 1) ? effects->velocity_tiles_x_tx :
182  effects->velocity_tiles_tx;
183 
186  DRW_shgroup_uniform_texture_ref_ex(grp, "colorBuffer", &effects->source_buffer, state);
187  DRW_shgroup_uniform_texture_ref_ex(grp, "depthBuffer", &dtxl->depth, state);
188  DRW_shgroup_uniform_texture_ref_ex(grp, "velocityBuffer", &effects->velocity_tx, state);
189  DRW_shgroup_uniform_texture(grp, "tileMaxBuffer", tile_tx);
191  DRW_shgroup_uniform_vec2(grp, "nearFar", effects->motion_blur_near_far, 1);
193  DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
194  DRW_shgroup_uniform_vec2(grp, "viewportSizeInv", DRW_viewport_invert_size_get(), 1);
195  DRW_shgroup_uniform_ivec2_copy(grp, "tileBufferSize", tx_size);
197  }
198  {
200 
202  psl->velocity_object);
203  DRW_shgroup_uniform_mat4(grp, "prevViewProjMatrix", mb_data->camera[MB_PREV].persmat);
204  DRW_shgroup_uniform_mat4(grp, "currViewProjMatrix", mb_data->camera[MB_CURR].persmat);
205  DRW_shgroup_uniform_mat4(grp, "nextViewProjMatrix", mb_data->camera[MB_NEXT].persmat);
206 
208 
210  psl->velocity_hair);
211  DRW_shgroup_uniform_mat4(grp, "prevViewProjMatrix", mb_data->camera[MB_PREV].persmat);
212  DRW_shgroup_uniform_mat4(grp, "currViewProjMatrix", mb_data->camera[MB_CURR].persmat);
213  DRW_shgroup_uniform_mat4(grp, "nextViewProjMatrix", mb_data->camera[MB_NEXT].persmat);
214 
216  }
217 
219  }
220  else {
221  psl->motion_blur = NULL;
222  psl->velocity_object = NULL;
223  psl->velocity_hair = NULL;
224  }
225 }
226 
228  EEVEE_Data *vedata,
229  Object *ob,
230  ParticleSystem *psys,
231  ModifierData *md)
232 {
233  EEVEE_PassList *psl = vedata->psl;
234  EEVEE_StorageList *stl = vedata->stl;
235  EEVEE_EffectsInfo *effects = stl->effects;
236  DRWShadingGroup *grp = NULL;
237 
238  if (!DRW_state_is_scene_render() || psl->velocity_hair == NULL) {
239  return;
240  }
241 
242  /* For now we assume hair objects are always moving. */
244  &effects->motion_blur, ob, true);
245 
246  if (mb_data) {
247  int mb_step = effects->motion_blur_step;
248  /* Store transform */
249  DRW_hair_duplimat_get(ob, psys, md, mb_data->obmat[mb_step]);
250 
252  int psys_id = (md != NULL) ? BLI_findindex(&ob->modifiers, md) : 0;
253 
254  if (psys_id >= mb_hair->psys_len) {
255  /* This should never happen. It means the modifier list was changed by frame evaluation. */
256  BLI_assert(0);
257  return;
258  }
259 
260  if (mb_step == MB_CURR) {
261  /* Fill missing matrices if the object was hidden in previous or next frame. */
262  if (is_zero_m4(mb_data->obmat[MB_PREV])) {
263  copy_m4_m4(mb_data->obmat[MB_PREV], mb_data->obmat[MB_CURR]);
264  }
265  if (is_zero_m4(mb_data->obmat[MB_NEXT])) {
266  copy_m4_m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR]);
267  }
268 
269  GPUTexture *tex_prev = mb_hair->psys[psys_id].hair_pos_tx[MB_PREV];
270  GPUTexture *tex_next = mb_hair->psys[psys_id].hair_pos_tx[MB_NEXT];
271 
272  grp = DRW_shgroup_hair_create_sub(ob, psys, md, effects->motion_blur.hair_grp);
273  DRW_shgroup_uniform_mat4(grp, "prevModelMatrix", mb_data->obmat[MB_PREV]);
274  DRW_shgroup_uniform_mat4(grp, "currModelMatrix", mb_data->obmat[MB_CURR]);
275  DRW_shgroup_uniform_mat4(grp, "nextModelMatrix", mb_data->obmat[MB_NEXT]);
276  DRW_shgroup_uniform_texture(grp, "prvBuffer", tex_prev);
277  DRW_shgroup_uniform_texture(grp, "nxtBuffer", tex_next);
278  DRW_shgroup_uniform_bool(grp, "useDeform", &mb_hair->use_deform, 1);
279  }
280  else {
281  /* Store vertex position buffer. */
282  mb_hair->psys[psys_id].hair_pos[mb_step] = DRW_hair_pos_buffer_get(ob, psys, md);
283  mb_hair->use_deform = true;
284  }
285  }
286 }
287 
289  EEVEE_Data *vedata,
290  Object *ob)
291 {
292  EEVEE_PassList *psl = vedata->psl;
293  EEVEE_StorageList *stl = vedata->stl;
294  EEVEE_EffectsInfo *effects = stl->effects;
295  DRWShadingGroup *grp = NULL;
296 
297  if (!DRW_state_is_scene_render() || psl->velocity_object == NULL) {
298  return;
299  }
300 
301  RigidBodyOb *rbo = ob->rigidbody_object;
302 
303  /* active rigidbody objects only, as only those are affected by sim. */
304  const bool has_rigidbody = (rbo && (rbo->type == RBO_TYPE_ACTIVE));
305 #if 0
306  /* For now we assume dupli objects are moving. */
307  const bool is_dupli = (ob->base_flag & BASE_FROM_DUPLI) != 0;
308  const bool object_moves = is_dupli || has_rigidbody || BKE_object_moves_in_time(ob, true);
309 #else
310  /* BKE_object_moves_in_time does not work in some cases.
311  * Better detect non moving object after evaluation. */
312  const bool object_moves = true;
313 #endif
314  const bool is_deform = BKE_object_is_deform_modified(DRW_context_state_get()->scene, ob) ||
315  (has_rigidbody && (rbo->flag & RBO_FLAG_USE_DEFORM) != 0);
316 
317  if (!(object_moves || is_deform)) {
318  return;
319  }
320 
322  &effects->motion_blur, ob, false);
323 
324  if (mb_data) {
325  int mb_step = effects->motion_blur_step;
326  /* Store transform */
327  copy_m4_m4(mb_data->obmat[mb_step], ob->obmat);
328 
330  ob);
331 
332  if (mb_step == MB_CURR) {
334  if (batch == NULL) {
335  return;
336  }
337 
338  /* Fill missing matrices if the object was hidden in previous or next frame. */
339  if (is_zero_m4(mb_data->obmat[MB_PREV])) {
340  copy_m4_m4(mb_data->obmat[MB_PREV], mb_data->obmat[MB_CURR]);
341  }
342  if (is_zero_m4(mb_data->obmat[MB_NEXT])) {
343  copy_m4_m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR]);
344  }
345 
346  if (mb_geom->use_deform) {
347  /* Keep to modify later (after init). */
348  mb_geom->batch = batch;
349  }
350 
351  /* Avoid drawing object that has no motions since object_moves is always true. */
352  if (!mb_geom->use_deform && /* Object deformation can happen without transform. */
353  equals_m4m4(mb_data->obmat[MB_PREV], mb_data->obmat[MB_CURR]) &&
354  equals_m4m4(mb_data->obmat[MB_NEXT], mb_data->obmat[MB_CURR])) {
355  return;
356  }
357 
359  psl->velocity_object);
360  DRW_shgroup_uniform_mat4(grp, "prevModelMatrix", mb_data->obmat[MB_PREV]);
361  DRW_shgroup_uniform_mat4(grp, "currModelMatrix", mb_data->obmat[MB_CURR]);
362  DRW_shgroup_uniform_mat4(grp, "nextModelMatrix", mb_data->obmat[MB_NEXT]);
363  DRW_shgroup_uniform_bool(grp, "useDeform", &mb_geom->use_deform, 1);
364 
365  DRW_shgroup_call(grp, batch, ob);
366  }
367  else if (is_deform) {
368  /* Store vertex position buffer. */
369  mb_geom->vbo[mb_step] = DRW_cache_object_pos_vertbuf_get(ob);
370  mb_geom->use_deform = (mb_geom->vbo[mb_step] != NULL);
371  }
372  else {
373  mb_geom->vbo[mb_step] = NULL;
374  mb_geom->use_deform = false;
375  }
376  }
377 }
378 
380  GPUVertBuf *vbo1,
381  GPUVertBuf *vbo2)
382 {
383 
384  for (int i = 0; i < GPU_BATCH_VBO_MAX_LEN; i++) {
385  if (ELEM(batch->verts[i], vbo1, vbo2)) {
386  /* Avoid double reference of the VBOs. */
387  batch->verts[i] = NULL;
388  }
389  }
390 }
391 
393 {
394  EEVEE_StorageList *stl = vedata->stl;
395  EEVEE_EffectsInfo *effects = stl->effects;
396  GHashIterator ghi;
397 
398  if ((effects->enabled_effects & EFFECT_MOTION_BLUR) == 0) {
399  return;
400  }
401 
402  int mb_step = effects->motion_blur_step;
403 
404  if (mb_step != MB_CURR) {
405  /* Push instances attributes to the GPU. */
407 
408  /* Need to be called after DRW_render_instance_buffer_finish() */
409  /* Also we weed to have a correct fbo bound for DRW_hair_update */
410  GPU_framebuffer_bind(vedata->fbl->main_fb);
411  DRW_hair_update();
412 
414  }
415 
416  for (BLI_ghashIterator_init(&ghi, effects->motion_blur.geom);
417  BLI_ghashIterator_done(&ghi) == false;
418  BLI_ghashIterator_step(&ghi)) {
420  EEVEE_HairMotionData *mb_hair = (EEVEE_HairMotionData *)mb_geom;
421 
422  if (!mb_geom->use_deform) {
423  continue;
424  }
425 
426  switch (mb_geom->type) {
428  if (mb_step == MB_CURR) {
429  /* TODO(fclem): Check if vertex count mismatch. */
430  mb_hair->use_deform = true;
431  }
432  else {
433  for (int i = 0; i < mb_hair->psys_len; i++) {
434  if (mb_hair->psys[i].hair_pos[mb_step] == NULL) {
435  continue;
436  }
437  mb_hair->psys[i].hair_pos[mb_step] = GPU_vertbuf_duplicate(
438  mb_hair->psys[i].hair_pos[mb_step]);
439 
440  /* Create vbo immediately to bind to texture buffer. */
441  GPU_vertbuf_use(mb_hair->psys[i].hair_pos[mb_step]);
442 
443  mb_hair->psys[i].hair_pos_tx[mb_step] = GPU_texture_create_from_vertbuf(
444  "hair_pos_motion_blur", mb_hair->psys[i].hair_pos[mb_step]);
445  }
446  }
447  break;
448 
450  if (mb_step == MB_CURR) {
451  /* Modify batch to have data from adjacent frames. */
452  GPUBatch *batch = mb_geom->batch;
453  for (int i = 0; i < MB_CURR; i++) {
454  GPUVertBuf *vbo = mb_geom->vbo[i];
455  if (vbo && batch) {
457  /* Vertex count mismatch, disable deform motion blur. */
458  mb_geom->use_deform = false;
459  }
460 
461  if (mb_geom->use_deform == false) {
463  batch, mb_geom->vbo[MB_PREV], mb_geom->vbo[MB_NEXT]);
464 
467  break;
468  }
469 
470  GPU_batch_vertbuf_add_ex(batch, vbo, false);
471  }
472  }
473  }
474  else {
475  GPUVertBuf *vbo = mb_geom->vbo[mb_step];
476  if (vbo) {
477  /* Use the vbo to perform the copy on the GPU. */
478  GPU_vertbuf_use(vbo);
479  /* Perform a copy to avoid losing it after RE_engine_frame_set(). */
480  mb_geom->vbo[mb_step] = vbo = GPU_vertbuf_duplicate(vbo);
481  /* Find and replace "pos" attrib name. */
483  int attrib_id = GPU_vertformat_attr_id_get(format, "pos");
484  GPU_vertformat_attr_rename(format, attrib_id, (mb_step == MB_PREV) ? "prv" : "nxt");
485  }
486  else {
487  /* This might happen if the object visibility has been animated. */
488  mb_geom->use_deform = false;
489  }
490  }
491  break;
492 
493  default:
494  BLI_assert(0);
495  break;
496  }
497  }
498 }
499 
501 {
502  EEVEE_StorageList *stl = vedata->stl;
503  EEVEE_EffectsInfo *effects = stl->effects;
504 
505  GHashIterator ghi;
506 
507  BLI_assert((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0);
508 
509  /* Camera Data. */
510  effects->motion_blur.camera[MB_PREV] = effects->motion_blur.camera[MB_NEXT];
511 
512  /* Object Data. */
513  for (BLI_ghashIterator_init(&ghi, effects->motion_blur.object);
514  BLI_ghashIterator_done(&ghi) == false;
515  BLI_ghashIterator_step(&ghi)) {
517 
518  copy_m4_m4(mb_data->obmat[MB_PREV], mb_data->obmat[MB_NEXT]);
519  }
520 
521  /* Deformation Data. */
522  for (BLI_ghashIterator_init(&ghi, effects->motion_blur.geom);
523  BLI_ghashIterator_done(&ghi) == false;
524  BLI_ghashIterator_step(&ghi)) {
526  EEVEE_HairMotionData *mb_hair = (EEVEE_HairMotionData *)mb_geom;
527 
528  switch (mb_geom->type) {
530  for (int i = 0; i < mb_hair->psys_len; i++) {
533  mb_hair->psys[i].hair_pos[MB_PREV] = mb_hair->psys[i].hair_pos[MB_NEXT];
534  mb_hair->psys[i].hair_pos_tx[MB_PREV] = mb_hair->psys[i].hair_pos_tx[MB_NEXT];
535  mb_hair->psys[i].hair_pos[MB_NEXT] = NULL;
536  mb_hair->psys[i].hair_pos_tx[MB_NEXT] = NULL;
537  }
538  break;
539 
541  if (mb_geom->batch != NULL) {
543  mb_geom->batch, mb_geom->vbo[MB_PREV], mb_geom->vbo[MB_NEXT]);
544  }
546  mb_geom->vbo[MB_PREV] = mb_geom->vbo[MB_NEXT];
547  mb_geom->vbo[MB_NEXT] = NULL;
548 
549  if (mb_geom->vbo[MB_PREV]) {
550  GPUVertBuf *vbo = mb_geom->vbo[MB_PREV];
552  int attrib_id = GPU_vertformat_attr_id_get(format, "nxt");
553  GPU_vertformat_attr_rename(format, attrib_id, "prv");
554  }
555  break;
556 
557  default:
558  BLI_assert(0);
559  break;
560  }
561  }
562 }
563 
565 {
566  EEVEE_PassList *psl = vedata->psl;
567  EEVEE_TextureList *txl = vedata->txl;
568  EEVEE_FramebufferList *fbl = vedata->fbl;
569  EEVEE_StorageList *stl = vedata->stl;
570  EEVEE_EffectsInfo *effects = stl->effects;
571 
572  /* Motion Blur */
573  if ((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0) {
574  /* Create velocity max tiles in 2 passes. One for each dimension. */
577 
580 
581  /* Expand the tiles by reading the neighborhood. Do as many passes as required. */
582  int buf = 0;
583  for (int i = effects->motion_blur_max; i > 0; i -= EEVEE_VELOCITY_TILE_SIZE) {
585 
586  /* Change viewport to avoid invoking more pixel shaders than necessary since in one of the
587  * buffer the texture is way bigger in height. This avoid creating another texture and
588  * reduce VRAM usage. */
589  int w = GPU_texture_width(effects->velocity_tiles_tx);
590  int h = GPU_texture_height(effects->velocity_tiles_tx);
591  GPU_framebuffer_viewport_set(fbl->velocity_tiles_fb[buf], 0, 0, w, h);
592 
594 
596 
597  buf = buf ? 0 : 1;
598  }
599 
602  SWAP_BUFFERS();
603  }
604 }
Camera data-block and utility functions.
General operations, lookup, etc. for blender objects.
int BKE_object_is_deform_modified(struct Scene *scene, struct Object *ob)
Definition: object.c:5018
bool BKE_object_moves_in_time(const struct Object *object, bool recurse_parent)
#define BLI_assert(a)
Definition: BLI_assert.h:58
void BLI_ghashIterator_step(GHashIterator *ghi)
Definition: BLI_ghash.c:1086
BLI_INLINE bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:158
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:150
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
Definition: BLI_ghash.c:1065
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
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
bool is_zero_m4(const float mat[4][4])
Definition: math_matrix.c:2601
Random number functions.
#define UNUSED(x)
#define ELEM(...)
@ BASE_FROM_DUPLI
Types and defines for representing Rigid Body entities.
@ RBO_TYPE_ACTIVE
@ RBO_FLAG_USE_DEFORM
@ SCE_EEVEE_MOTION_BLUR_ENABLED
@ DRW_STATE_DEPTH_EQUAL
Definition: DRW_render.h:324
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:593
#define DRW_shgroup_call(shgroup, geom, ob)
Definition: DRW_render.h:420
#define DRW_TEXTURE_FREE_SAFE(tex)
Definition: DRW_render.h:180
GPUBatch
Definition: GPU_batch.h:93
int GPU_batch_vertbuf_add_ex(GPUBatch *, GPUVertBuf *, bool own_vbo)
Definition: gpu_batch.cc:192
#define GPU_BATCH_VBO_MAX_LEN
Definition: GPU_batch.h:35
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
struct GPUShader GPUShader
Definition: GPU_shader.h:33
eGPUSamplerState
Definition: GPU_texture.h:40
int GPU_texture_height(const GPUTexture *tex)
Definition: gpu_texture.cc:532
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
GPUTexture * GPU_texture_create_from_vertbuf(const char *name, struct GPUVertBuf *vert)
Definition: gpu_texture.cc:315
int GPU_texture_width(const GPUTexture *tex)
Definition: gpu_texture.cc:527
@ GPU_RGBA16
Definition: GPU_texture.h:95
const GPUVertFormat * GPU_vertbuf_get_format(const GPUVertBuf *verts)
uint GPU_vertbuf_get_vertex_len(const GPUVertBuf *verts)
struct GPUVertBuf GPUVertBuf
GPUVertBuf * GPU_vertbuf_duplicate(GPUVertBuf *verts)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
void GPU_vertbuf_use(GPUVertBuf *)
void GPU_vertformat_attr_rename(GPUVertFormat *format, int attr, const char *new_name)
int GPU_vertformat_attr_id_get(const GPUVertFormat *, const char *name)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
Scene scene
GPUVertBuf * DRW_cache_object_pos_vertbuf_get(Object *ob)
Definition: draw_cache.c:911
GPUBatch * DRW_cache_object_surface_get(Object *ob)
Definition: draw_cache.c:886
void DRW_hair_duplimat_get(struct Object *object, struct ParticleSystem *psys, struct ModifierData *md, float(*dupli_mat)[4])
void DRW_hair_update(void)
Definition: draw_hair.c:300
struct GPUVertBuf * DRW_hair_pos_buffer_get(struct Object *object, struct ParticleSystem *psys, struct ModifierData *md)
Definition: draw_hair.c:175
struct DRWShadingGroup * DRW_shgroup_hair_create_sub(struct Object *object, struct ParticleSystem *psys, struct ModifierData *md, struct DRWShadingGroup *shgrp)
Definition: draw_hair.c:222
void DRW_render_instance_buffer_finish(void)
const DRWContextState * DRW_context_state_get(void)
void DRW_cache_restart(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
bool DRW_state_is_scene_render(void)
DefaultTextureList * DRW_viewport_texture_list_get(void)
Definition: draw_manager.c:702
float DRW_view_near_distance_get(const DRWView *view)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
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)
void DRW_shgroup_uniform_ivec2_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
void DRW_pass_link(DRWPass *first, DRWPass *second)
bool DRW_view_is_persp_get(const DRWView *view)
void DRW_shgroup_uniform_texture_ref_ex(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex, eGPUSamplerState sampler_state)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, Object *ob, uint tri_count)
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
float DRW_view_far_distance_get(const DRWView *view)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float(*value)[4])
void DRW_shgroup_uniform_vec2(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_draw_pass(DRWPass *pass)
GPUTexture * DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
GPUBatch * batch
Definition: drawnode.c:3779
EEVEE_GeometryMotionData * EEVEE_motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb, Object *ob)
Definition: eevee_data.c:196
void EEVEE_motion_blur_data_init(EEVEE_MotionBlurData *mb)
Definition: eevee_data.c:102
EEVEE_HairMotionData * EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb, Object *ob)
Definition: eevee_data.c:201
EEVEE_ObjectMotionData * EEVEE_motion_blur_object_data_get(EEVEE_MotionBlurData *mb, Object *ob, bool hair)
Definition: eevee_data.c:124
DrawEngineType draw_engine_eevee_type
Definition: eevee_engine.c:622
struct GPUTexture * EEVEE_materials_get_util_tex(void)
void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata)
static void eevee_motion_blur_sync_camera(EEVEE_Data *vedata)
void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata)
void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
static void motion_blur_remove_vbo_reference_from_batch(GPUBatch *batch, GPUVertBuf *vbo1, GPUVertBuf *vbo2)
void EEVEE_motion_blur_step_set(EEVEE_Data *vedata, int step)
void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata, Object *ob)
void EEVEE_motion_blur_draw(EEVEE_Data *vedata)
int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)
void EEVEE_motion_blur_hair_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata, Object *ob, ParticleSystem *psys, ModifierData *md)
struct GPUShader * EEVEE_shaders_effect_motion_blur_sh_get(void)
#define SWAP_BUFFERS()
#define EEVEE_VELOCITY_TILE_SIZE
Definition: eevee_private.h:89
struct GPUShader * EEVEE_shaders_effect_motion_blur_velocity_tiles_sh_get(void)
struct GPUShader * EEVEE_shaders_effect_motion_blur_hair_sh_get(void)
#define MB_PREV
@ EEVEE_MOTION_DATA_HAIR
@ EEVEE_MOTION_DATA_MESH
@ EFFECT_MOTION_BLUR
@ EFFECT_VELOCITY_BUFFER
@ EFFECT_POST_BUFFER
#define MB_NEXT
struct GPUShader * EEVEE_shaders_effect_motion_blur_velocity_tiles_expand_sh_get(void)
#define MB_CURR
struct GPUShader * EEVEE_shaders_effect_motion_blur_object_sh_get(void)
void GPU_framebuffer_viewport_reset(GPUFrameBuffer *gpu_fb)
void GPU_framebuffer_viewport_set(GPUFrameBuffer *gpu_fb, int x, int y, int width, int height)
#define fabsf(x)
format
Definition: logImageCore.h:47
static ulong state[N]
struct Scene * scene
Definition: DRW_render.h:745
struct GPUTexture * depth
EEVEE_TextureList * txl
EEVEE_StorageList * stl
EEVEE_PassList * psl
EEVEE_FramebufferList * fbl
struct GPUTexture * source_buffer
float motion_blur_near_far[2]
struct GPUTexture * velocity_tiles_x_tx
struct GPUFrameBuffer * target_buffer
struct GPUTexture * velocity_tiles_tx
EEVEE_EffectsFlag enabled_effects
struct GPUTexture * velocity_tx
struct EEVEE_MotionBlurData motion_blur
struct GPUFrameBuffer * main_fb
struct GPUFrameBuffer * velocity_tiles_fb[2]
struct GPUVertBuf * vbo[2]
eEEVEEMotionData type
struct GPUBatch * batch
struct EEVEE_HairMotionData::@201 psys[0]
struct GPUTexture * hair_pos_tx[2]
struct GPUVertBuf * hair_pos[2]
struct GHash * geom
struct EEVEE_MotionBlurData::@200 camera[3]
struct GHash * object
DRWShadingGroup * hair_grp
float obmat[3][4][4]
struct DRWPass * velocity_object
struct DRWPass * velocity_tiles
struct DRWPass * motion_blur
struct DRWPass * velocity_tiles_expand[2]
struct DRWPass * velocity_tiles_x
struct DRWPass * velocity_hair
struct EEVEE_EffectsInfo * effects
short base_flag
ListBase modifiers
struct RigidBodyOb * rigidbody_object
float obmat[4][4]
float motion_blur_depth_scale
struct SceneEEVEE eevee