Blender  V3.3
gpencil_engine.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2017 Blender Foundation. */
3 
7 #include "DRW_engine.h"
8 #include "DRW_render.h"
9 
10 #include "BKE_gpencil.h"
11 #include "BKE_gpencil_modifier.h"
12 #include "BKE_lib_id.h"
13 #include "BKE_main.h"
14 #include "BKE_object.h"
15 #include "BKE_paint.h"
16 #include "BKE_shader_fx.h"
17 
18 #include "BKE_camera.h"
19 #include "BKE_global.h" /* for G.debug */
20 
21 #include "BLI_link_utils.h"
22 #include "BLI_listbase.h"
23 #include "BLI_memblock.h"
24 
25 #include "DNA_camera_types.h"
26 #include "DNA_gpencil_types.h"
27 #include "DNA_screen_types.h"
28 #include "DNA_view3d_types.h"
29 
30 #include "GPU_texture.h"
31 #include "GPU_uniform_buffer.h"
32 
33 #include "gpencil_engine.h"
34 
35 #include "DEG_depsgraph_query.h"
36 
37 #include "ED_screen.h"
38 #include "ED_view3d.h"
39 
40 #include "UI_resources.h"
41 
42 /* *********** FUNCTIONS *********** */
43 
44 void GPENCIL_engine_init(void *ved)
45 {
46  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
47  GPENCIL_StorageList *stl = vedata->stl;
48  GPENCIL_TextureList *txl = vedata->txl;
49  GPENCIL_FramebufferList *fbl = vedata->fbl;
53  const View3D *v3d = ctx->v3d;
54 
55  if (!stl->pd) {
56  stl->pd = MEM_callocN(sizeof(GPENCIL_PrivateData), "GPENCIL_PrivateData");
57  }
58 
59  if (txl->dummy_texture == NULL) {
60  const float pixels[1][4] = {{1.0f, 0.0f, 1.0f, 1.0f}};
61  txl->dummy_texture = DRW_texture_create_2d(1, 1, GPU_RGBA8, DRW_TEX_WRAP, (float *)pixels);
62  }
63 
65 
66  /* Resize and reset memblocks. */
73 
74  stl->pd->gp_light_pool = vldata->gp_light_pool;
75  stl->pd->gp_material_pool = vldata->gp_material_pool;
76  stl->pd->gp_maskbit_pool = vldata->gp_maskbit_pool;
77  stl->pd->gp_object_pool = vldata->gp_object_pool;
78  stl->pd->gp_layer_pool = vldata->gp_layer_pool;
79  stl->pd->gp_vfx_pool = vldata->gp_vfx_pool;
80  stl->pd->view_layer = ctx->view_layer;
81  stl->pd->scene = ctx->scene;
82  stl->pd->v3d = ctx->v3d;
83  stl->pd->last_light_pool = NULL;
84  stl->pd->last_material_pool = NULL;
85  stl->pd->tobjects.first = NULL;
86  stl->pd->tobjects.last = NULL;
87  stl->pd->tobjects_infront.first = NULL;
88  stl->pd->tobjects_infront.last = NULL;
89  stl->pd->sbuffer_tobjects.first = NULL;
90  stl->pd->sbuffer_tobjects.last = NULL;
91  stl->pd->dummy_tx = txl->dummy_texture;
93  stl->pd->draw_wireframe = (v3d && v3d->shading.type == OB_WIRE) && !stl->pd->draw_depth_only;
94  stl->pd->scene_depth_tx = stl->pd->draw_depth_only ? txl->dummy_texture : dtxl->depth;
95  stl->pd->scene_fb = dfbl->default_fb;
96  stl->pd->is_render = txl->render_depth_tx || (v3d && v3d->shading.type == OB_RENDER);
97  stl->pd->is_viewport = (v3d != NULL);
100  /* Small HACK: we don't want the global pool to be reused,
101  * so we set the last light pool to NULL. */
102  stl->pd->last_light_pool = NULL;
103 
104  bool use_scene_lights = false;
105  bool use_scene_world = false;
106 
107  if (v3d) {
108  use_scene_lights = V3D_USES_SCENE_LIGHTS(v3d);
109 
110  use_scene_world = V3D_USES_SCENE_WORLD(v3d);
111 
112  stl->pd->v3d_color_type = (v3d->shading.type == OB_SOLID) ? v3d->shading.color_type : -1;
113  /* Special case: If Vertex Paint mode, use always Vertex mode. */
114  if (v3d->shading.type == OB_SOLID && ctx->obact && ctx->obact->type == OB_GPENCIL &&
115  ctx->obact->mode == OB_MODE_VERTEX_GPENCIL) {
117  }
118 
120 
121  /* For non active frame, use only lines in multiedit mode. */
122  const bool overlays_on = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0;
123  stl->pd->use_multiedit_lines_only = overlays_on &&
124  (v3d->gp_flag & V3D_GP_SHOW_MULTIEDIT_LINES) != 0;
125 
126  const bool shmode_xray_support = v3d->shading.type <= OB_SOLID;
127  stl->pd->xray_alpha = (shmode_xray_support && XRAY_ENABLED(v3d)) ? XRAY_ALPHA(v3d) : 1.0f;
128  }
129  else if (stl->pd->is_render) {
130  use_scene_lights = true;
131  use_scene_world = true;
132  stl->pd->use_multiedit_lines_only = false;
133  stl->pd->xray_alpha = 1.0f;
134  stl->pd->v3d_color_type = -1;
135  }
136 
137  stl->pd->use_lighting = (v3d && v3d->shading.type > OB_SOLID) || stl->pd->is_render;
138  stl->pd->use_lights = use_scene_lights;
139 
140  if (txl->render_depth_tx != NULL) {
141  stl->pd->scene_depth_tx = txl->render_depth_tx;
142  stl->pd->scene_fb = fbl->render_fb;
143  }
144 
145  gpencil_light_ambient_add(stl->pd->shadeless_light_pool, (float[3]){1.0f, 1.0f, 1.0f});
146 
147  World *world = ctx->scene->world;
148  if (world != NULL && use_scene_world) {
150  }
151  else if (v3d) {
152  float world_light[3];
153  copy_v3_fl(world_light, v3d->shading.studiolight_intensity);
154  gpencil_light_ambient_add(stl->pd->global_light_pool, world_light);
155  }
156 
157  float viewmatinv[4][4];
158  DRW_view_viewmat_get(NULL, viewmatinv, true);
159  copy_v3_v3(stl->pd->camera_z_axis, viewmatinv[2]);
160  copy_v3_v3(stl->pd->camera_pos, viewmatinv[3]);
161  stl->pd->camera_z_offset = dot_v3v3(viewmatinv[3], viewmatinv[2]);
162 
163  if (ctx && ctx->rv3d && v3d) {
164  stl->pd->camera = (ctx->rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL;
165  }
166  else {
167  stl->pd->camera = NULL;
168  }
169 }
170 
171 void GPENCIL_cache_init(void *ved)
172 {
173  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
174  GPENCIL_PassList *psl = vedata->psl;
175  GPENCIL_TextureList *txl = vedata->txl;
176  GPENCIL_FramebufferList *fbl = vedata->fbl;
177  GPENCIL_PrivateData *pd = vedata->stl->pd;
178  DRWShadingGroup *grp;
179 
180  const DRWContextState *draw_ctx = DRW_context_state_get();
181  pd->cfra = (int)DEG_get_ctime(draw_ctx->depsgraph);
183  pd->use_layer_fb = false;
184  pd->use_object_fb = false;
185  pd->use_mask_fb = false;
186  /* Always use high precision for render. */
187  pd->use_signed_fb = !pd->is_viewport;
188 
189  if (draw_ctx->v3d) {
190  const bool hide_overlay = ((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) != 0);
191  const bool show_onion = ((draw_ctx->v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) != 0);
192  const bool playing = (draw_ctx->evil_C != NULL) ?
194  NULL :
195  false;
196  pd->do_onion = show_onion && !hide_overlay && !playing;
197  pd->playing = playing;
198  /* Save simplify flags (can change while drawing, so it's better to save). */
199  Scene *scene = draw_ctx->scene;
200  pd->simplify_fill = GPENCIL_SIMPLIFY_FILL(scene, playing);
201  pd->simplify_fx = GPENCIL_SIMPLIFY_FX(scene, playing) ||
202  (draw_ctx->v3d->shading.type < OB_RENDER);
203 
204  /* Fade Layer. */
205  const bool is_fade_layer = ((!hide_overlay) && (!pd->is_render) &&
206  (draw_ctx->v3d->gp_flag & V3D_GP_FADE_NOACTIVE_LAYERS));
207  pd->fade_layer_opacity = (is_fade_layer) ? draw_ctx->v3d->overlay.gpencil_fade_layer : -1.0f;
209  /* Fade GPencil Objects. */
210  const bool is_fade_object = ((!hide_overlay) && (!pd->is_render) &&
211  (draw_ctx->v3d->gp_flag & V3D_GP_FADE_OBJECTS) &&
212  (draw_ctx->v3d->gp_flag & V3D_GP_FADE_NOACTIVE_GPENCIL));
213  pd->fade_gp_object_opacity = (is_fade_object) ? draw_ctx->v3d->overlay.gpencil_paper_opacity :
214  -1.0f;
215  pd->fade_3d_object_opacity = ((!hide_overlay) && (!pd->is_render) &&
216  (draw_ctx->v3d->gp_flag & V3D_GP_FADE_OBJECTS)) ?
217  draw_ctx->v3d->overlay.gpencil_paper_opacity :
218  -1.0f;
219  }
220  else {
221  pd->do_onion = true;
222  Scene *scene = draw_ctx->scene;
224  pd->simplify_fx = GPENCIL_SIMPLIFY_FX(scene, false);
225  pd->fade_layer_opacity = -1.0f;
226  pd->playing = false;
227  }
228 
229  {
230  pd->sbuffer_stroke = NULL;
231  pd->sbuffer_gpd = NULL;
232  pd->sbuffer_layer = NULL;
233  pd->stroke_batch = NULL;
234  pd->fill_batch = NULL;
235  pd->do_fast_drawing = false;
236 
237  pd->obact = draw_ctx->obact;
238  if (pd->obact && pd->obact->type == OB_GPENCIL && !(pd->draw_depth_only)) {
239  /* Check if active object has a temp stroke data. */
240  bGPdata *gpd = (bGPdata *)pd->obact->data;
241  if (gpd->runtime.sbuffer_used > 0) {
242  pd->sbuffer_gpd = gpd;
245  pd->do_fast_drawing = false; /* TODO: option. */
246  }
247  }
248  }
249 
250  if (pd->do_fast_drawing) {
252  const float *size = DRW_viewport_size_get();
256 
257  GPU_framebuffer_ensure_config(&fbl->snapshot_fb,
258  {
259  GPU_ATTACHMENT_TEXTURE(txl->snapshot_depth_tx),
260  GPU_ATTACHMENT_TEXTURE(txl->snapshot_color_tx),
261  GPU_ATTACHMENT_TEXTURE(txl->snapshot_reveal_tx),
262  });
263  }
264  else {
265  /* Free unneeded buffers. */
266  GPU_FRAMEBUFFER_FREE_SAFE(fbl->snapshot_fb);
270  }
271 
272  {
275 
277  grp = DRW_shgroup_create(sh, psl->merge_depth_ps);
278  DRW_shgroup_uniform_texture_ref(grp, "depthBuf", &pd->depth_tx);
279  DRW_shgroup_uniform_bool(grp, "strokeOrder3d", &pd->is_stroke_order_3d, 1);
280  DRW_shgroup_uniform_vec4(grp, "gpModelMatrix", pd->object_bound_mat[0], 4);
282  }
283  {
286 
288  grp = DRW_shgroup_create(sh, psl->mask_invert_ps);
290  }
291 
292  Camera *cam = (pd->camera != NULL && pd->camera->type == OB_CAMERA) ? pd->camera->data : NULL;
293 
294  /* Pseudo DOF setup. */
295  if (cam && (cam->dof.flag & CAM_DOF_ENABLED)) {
296  const float *vp_size = DRW_viewport_size_get();
297  float fstop = cam->dof.aperture_fstop;
298  float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
299  float focus_dist = BKE_camera_object_dof_distance(pd->camera);
300  float focal_len = cam->lens;
301 
302  const float scale_camera = 0.001f;
303  /* We want radius here for the aperture number. */
304  float aperture = 0.5f * scale_camera * focal_len / fstop;
305  float focal_len_scaled = scale_camera * focal_len;
306  float sensor_scaled = scale_camera * sensor;
307 
308  if (draw_ctx->rv3d != NULL) {
309  sensor_scaled *= draw_ctx->rv3d->viewcamtexcofac[0];
310  }
311 
312  pd->dof_params[1] = aperture * fabsf(focal_len_scaled / (focus_dist - focal_len_scaled));
313  pd->dof_params[1] *= vp_size[0] / sensor_scaled;
314  pd->dof_params[0] = -focus_dist * pd->dof_params[1];
315  }
316  else {
317  /* Disable DoF blur scaling. */
318  pd->camera = NULL;
319  }
320 }
321 
322 #define DRAW_NOW 2
323 
324 typedef struct gpIterPopulateData {
330  /* Last material UBO bound. Used to avoid unneeded buffer binding. */
333  /* Last texture bound. */
336  /* Offset in the material pool to the first material of this object. */
337  int mat_ofs;
338  /* Is the sbuffer call need to be issued. */
340  /* Indices to do correct insertion of the sbuffer stroke. */
343  /* Infos for call batching. */
344  struct GPUBatch *geom;
348 
349 #define DISABLE_BATCHING 0
350 
352 {
353 #if !DISABLE_BATCHING
354  if (iter->geom != NULL) {
355  if (iter->instancing) {
356  DRW_shgroup_call_instance_range(iter->grp, iter->ob, iter->geom, iter->vfirst, iter->vcount);
357  }
358  else {
359  DRW_shgroup_call_range(iter->grp, iter->ob, iter->geom, iter->vfirst, iter->vcount);
360  }
361  }
362 #endif
363 
364  iter->geom = NULL;
365  iter->vfirst = -1;
366  iter->vcount = 0;
367 }
368 
369 /* Group draw-calls that are consecutive and with the same type. Reduces GPU driver overhead. */
371  gpIterPopulateData *iter, struct GPUBatch *geom, bool instancing, int v_first, int v_count)
372 {
373 #if DISABLE_BATCHING
374  if (instancing) {
375  DRW_shgroup_call_instance_range(iter->grp, iter->ob, geom, v_first, v_count);
376  }
377  else {
378  DRW_shgroup_call_range(iter->grp, iter->ob, geom, v_first, v_count);
379  }
380 #endif
381 
382  int last = iter->vfirst + iter->vcount;
383  /* Interrupt draw-call grouping if the sequence is not consecutive. */
384  if ((geom != iter->geom) || (v_first - last > 3)) {
386  }
387  iter->geom = geom;
388  iter->instancing = instancing;
389  if (iter->vfirst == -1) {
390  iter->vfirst = v_first;
391  }
392  iter->vcount = v_first + v_count - iter->vfirst;
393 }
394 
396  bGPDframe *gpf,
397  bGPDstroke *gps,
398  void *thunk);
399 
401 {
402  iter->do_sbuffer_call = DRAW_NOW;
403  /* In order to draw the sbuffer stroke correctly mixed with other strokes,
404  * we need to offset the stroke index of the sbuffer stroke and the subsequent strokes.
405  * Remember, sbuffer stroke indices start from 0. So we add last index to avoid
406  * masking issues. */
407  iter->grp = DRW_shgroup_create_sub(iter->grp);
408  DRW_shgroup_uniform_block(iter->grp, "materials", iter->ubo_mat);
409  DRW_shgroup_uniform_float_copy(iter->grp, "gpStrokeIndexOffset", iter->stroke_index_last);
410 
411  const DRWContextState *ctx = DRW_context_state_get();
412  ToolSettings *ts = ctx->scene->toolsettings;
414  /* In this case we can't do correct projection during stroke. We just disable depth test. */
415  DRW_shgroup_uniform_texture(iter->grp, "gpSceneDepthTexture", iter->pd->dummy_tx);
416  }
417 
420 
421  iter->stroke_index_offset = iter->pd->sbuffer_stroke->totpoints + 1;
422  iter->do_sbuffer_call = 0;
423 }
424 
426  bGPDframe *gpf,
427  bGPDstroke *UNUSED(gps),
428  void *thunk)
429 {
430  gpIterPopulateData *iter = (gpIterPopulateData *)thunk;
431  GPENCIL_PrivateData *pd = iter->pd;
432  bGPdata *gpd = (bGPdata *)iter->ob->data;
433 
435 
436  if (iter->do_sbuffer_call) {
438  }
439  else {
440  iter->do_sbuffer_call = !pd->do_fast_drawing && (gpd == pd->sbuffer_gpd) &&
441  (gpl == pd->sbuffer_layer) &&
442  (gpf == NULL || gpf->runtime.onion_id == 0.0f);
443  }
444 
445  GPENCIL_tLayer *tgp_layer = gpencil_layer_cache_add(pd, iter->ob, gpl, gpf, iter->tgp_ob);
446 
447  const bool use_lights = pd->use_lighting && ((gpl->flag & GP_LAYER_USE_LIGHTS) != 0) &&
448  (iter->ob->dtx & OB_USE_GPENCIL_LIGHTS);
449 
450  iter->ubo_lights = (use_lights) ? pd->global_light_pool->ubo : pd->shadeless_light_pool->ubo;
451 
453 
454  /* Iterator dependent uniforms. */
455  DRWShadingGroup *grp = iter->grp = tgp_layer->base_shgrp;
456  DRW_shgroup_uniform_block(grp, "lights", iter->ubo_lights);
457  DRW_shgroup_uniform_block(grp, "materials", iter->ubo_mat);
458  DRW_shgroup_uniform_texture(grp, "gpFillTexture", iter->tex_fill);
459  DRW_shgroup_uniform_texture(grp, "gpStrokeTexture", iter->tex_stroke);
460  DRW_shgroup_uniform_int_copy(grp, "gpMaterialOffset", iter->mat_ofs);
461  DRW_shgroup_uniform_float_copy(grp, "gpStrokeIndexOffset", iter->stroke_index_offset);
462 }
463 
465  bGPDframe *gpf,
466  bGPDstroke *gps,
467  void *thunk)
468 {
469  gpIterPopulateData *iter = (gpIterPopulateData *)thunk;
470 
471  bGPdata *gpd = iter->ob->data;
472  MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(iter->ob, gps->mat_nr + 1);
473 
474  const bool is_render = iter->pd->is_render;
475  bool hide_material = (gp_style->flag & GP_MATERIAL_HIDE) != 0;
476  bool show_stroke = ((gp_style->flag & GP_MATERIAL_STROKE_SHOW) != 0) ||
477  (!is_render && ((gps->flag & GP_STROKE_NOFILL) != 0));
478  bool show_fill = (gps->tot_triangles > 0) && ((gp_style->flag & GP_MATERIAL_FILL_SHOW) != 0) &&
479  (!iter->pd->simplify_fill) && ((gps->flag & GP_STROKE_NOFILL) == 0);
480  bool only_lines = !GPENCIL_PAINT_MODE(gpd) && gpl && gpf && gpl->actframe != gpf &&
482  bool is_onion = gpl && gpf && gpf->runtime.onion_id != 0;
483  bool hide_onion = is_onion && ((gp_style->flag & GP_MATERIAL_HIDE_ONIONSKIN) != 0);
484  if ((hide_material) || (!show_stroke && !show_fill) || (only_lines && !is_onion) ||
485  (hide_onion)) {
486  return;
487  }
488 
489  GPUUniformBuf *ubo_mat;
490  GPUTexture *tex_stroke, *tex_fill;
492  iter->matpool, iter->mat_ofs + gps->mat_nr, &tex_stroke, &tex_fill, &ubo_mat);
493 
494  bool resource_changed = (iter->ubo_mat != ubo_mat) ||
495  (tex_fill && (iter->tex_fill != tex_fill)) ||
496  (tex_stroke && (iter->tex_stroke != tex_stroke));
497 
498  if (resource_changed) {
500 
501  iter->grp = DRW_shgroup_create_sub(iter->grp);
502  if (iter->ubo_mat != ubo_mat) {
503  DRW_shgroup_uniform_block(iter->grp, "materials", ubo_mat);
504  iter->ubo_mat = ubo_mat;
505  }
506  if (tex_fill) {
507  DRW_shgroup_uniform_texture(iter->grp, "gpFillTexture", tex_fill);
508  iter->tex_fill = tex_fill;
509  }
510  if (tex_stroke) {
511  DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", tex_stroke);
512  iter->tex_stroke = tex_stroke;
513  }
514  }
515 
516  bool do_sbuffer = (iter->do_sbuffer_call == DRAW_NOW);
517 
518  if (show_fill) {
519  GPUBatch *geom = do_sbuffer ? DRW_cache_gpencil_sbuffer_fill_get(iter->ob) :
520  DRW_cache_gpencil_fills_get(iter->ob, iter->pd->cfra);
521  int vfirst = gps->runtime.fill_start * 3;
522  int vcount = gps->tot_triangles * 3;
523  gpencil_drawcall_add(iter, geom, false, vfirst, vcount);
524  }
525 
526  if (show_stroke) {
527  GPUBatch *geom = do_sbuffer ? DRW_cache_gpencil_sbuffer_stroke_get(iter->ob) :
528  DRW_cache_gpencil_strokes_get(iter->ob, iter->pd->cfra);
529  /* Start one vert before to have gl_InstanceID > 0 (see shader). */
530  int vfirst = gps->runtime.stroke_start - 1;
531  /* Include "potential" cyclic vertex and start adj vertex (see shader). */
532  int vcount = gps->totpoints + 1 + 1;
533  gpencil_drawcall_add(iter, geom, true, vfirst, vcount);
534  }
535 
536  iter->stroke_index_last = gps->runtime.stroke_start + gps->totpoints + 1;
537 }
538 
540 {
541  bGPdata *gpd = (bGPdata *)iter->ob->data;
542  if (gpd != iter->pd->sbuffer_gpd) {
543  return;
544  }
545 
546  GPENCIL_TextureList *txl = vedata->txl;
547  GPUTexture *depth_texture = iter->pd->scene_depth_tx;
548  GPENCIL_tObject *last_tgp_ob = iter->pd->tobjects.last;
549  /* Create another temp object that only contain the stroke. */
550  iter->tgp_ob = gpencil_object_cache_add(iter->pd, iter->ob);
551  /* Remove from the main list. */
552  iter->pd->tobjects.last = last_tgp_ob;
553  last_tgp_ob->next = NULL;
554  /* Add to sbuffer tgpobject list. */
555  BLI_LINKS_APPEND(&iter->pd->sbuffer_tobjects, iter->tgp_ob);
556  /* Remove depth test with scene (avoid self occlusion). */
557  iter->pd->scene_depth_tx = txl->dummy_texture;
558 
560  iter->pd->sbuffer_layer, iter->pd->sbuffer_layer->actframe, NULL, iter);
561 
562  const DRWContextState *ctx = DRW_context_state_get();
563  ToolSettings *ts = ctx->scene->toolsettings;
565  /* In this case we can't do correct projection during stroke. We just disable depth test. */
566  DRW_shgroup_uniform_texture(iter->grp, "gpSceneDepthTexture", iter->pd->dummy_tx);
567  }
568 
569  iter->do_sbuffer_call = DRAW_NOW;
572 
573  gpencil_vfx_cache_populate(vedata, iter->ob, iter->tgp_ob);
574 
575  /* Restore state. */
576  iter->do_sbuffer_call = 0;
577  iter->pd->scene_depth_tx = depth_texture;
578 }
579 
580 void GPENCIL_cache_populate(void *ved, Object *ob)
581 {
582  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
583  GPENCIL_PrivateData *pd = vedata->stl->pd;
584  GPENCIL_TextureList *txl = vedata->txl;
585  const bool is_final_render = DRW_state_is_image_render();
586 
587  /* object must be visible */
589  return;
590  }
591 
592  if (ob->data && (ob->type == OB_GPENCIL) && (ob->dt >= OB_SOLID)) {
593  gpIterPopulateData iter = {0};
594  iter.ob = ob;
595  iter.pd = pd;
596  iter.tgp_ob = gpencil_object_cache_add(pd, ob);
597  iter.matpool = gpencil_material_pool_create(pd, ob, &iter.mat_ofs);
598  iter.tex_fill = txl->dummy_texture;
599  iter.tex_stroke = txl->dummy_texture;
600 
601  /* Special case for rendering onion skin. */
602  bGPdata *gpd = (bGPdata *)ob->data;
603  bool do_onion = (!pd->is_render) ? pd->do_onion : (gpd->onion_flag & GP_ONION_GHOST_ALWAYS);
604  gpd->runtime.playing = (short)pd->playing;
605 
606  /* When render in background the active frame could not be properly set due thread priority,
607  * better set again. This is not required in viewport. */
608  if (txl->render_depth_tx) {
609  const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
610  const DRWContextState *draw_ctx = DRW_context_state_get();
611 
612  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
613  /* If there is a time modifier, need remap the time before. */
614  if (time_remap) {
615  gpl->actframe = BKE_gpencil_frame_retime_get(draw_ctx->depsgraph, pd->scene, ob, gpl);
616  }
617  else {
619  }
620  }
621  }
622 
624  ob,
627  &iter,
628  do_onion,
629  pd->cfra);
630 
631  gpencil_drawcall_flush(&iter);
632 
633  if (iter.do_sbuffer_call) {
635  }
636 
637  gpencil_vfx_cache_populate(vedata, ob, iter.tgp_ob);
638 
639  if (pd->do_fast_drawing) {
641  }
642  }
643 
644  if (ob->type == OB_LAMP && pd->use_lights) {
646  }
647 }
648 
649 void GPENCIL_cache_finish(void *ved)
650 {
651  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
652  GPENCIL_PrivateData *pd = vedata->stl->pd;
653  GPENCIL_FramebufferList *fbl = vedata->fbl;
654 
655  /* Upload UBO data. */
656  BLI_memblock_iter iter;
659  while ((pool = (GPENCIL_MaterialPool *)BLI_memblock_iterstep(&iter))) {
660  GPU_uniformbuf_update(pool->ubo, pool->mat_data);
661  }
662 
664  GPENCIL_LightPool *lpool;
665  while ((lpool = (GPENCIL_LightPool *)BLI_memblock_iterstep(&iter))) {
666  GPU_uniformbuf_update(lpool->ubo, lpool->light_data);
667  }
668 
669  /* Sort object by decreasing Z to avoid most of alpha ordering issues. */
671 
672  /* Create frame-buffers only if needed. */
673  if (pd->tobjects.first) {
675 
676  const float *size = DRW_viewport_size_get();
681 
682  GPU_framebuffer_ensure_config(&fbl->gpencil_fb,
683  {
684  GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
685  GPU_ATTACHMENT_TEXTURE(pd->color_tx),
686  GPU_ATTACHMENT_TEXTURE(pd->reveal_tx),
687  });
688 
689  if (pd->use_layer_fb) {
694 
695  GPU_framebuffer_ensure_config(&fbl->layer_fb,
696  {
697  GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
698  GPU_ATTACHMENT_TEXTURE(pd->color_layer_tx),
699  GPU_ATTACHMENT_TEXTURE(pd->reveal_layer_tx),
700  });
701  }
702 
703  if (pd->use_object_fb) {
708 
709  GPU_framebuffer_ensure_config(&fbl->object_fb,
710  {
711  GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
712  GPU_ATTACHMENT_TEXTURE(pd->color_object_tx),
713  GPU_ATTACHMENT_TEXTURE(pd->reveal_object_tx),
714  });
715  }
716 
717  if (pd->use_mask_fb) {
718  /* We need an extra depth to not disturb the normal drawing.
719  * The color_tx is needed for frame-buffer completeness. */
720  GPUTexture *color_tx, *depth_tx;
721  depth_tx = DRW_texture_pool_query_2d(
724  /* Use high quality format for render. */
725  eGPUTextureFormat mask_format = pd->is_render ? GPU_R16 : GPU_R8;
727  size[0], size[1], mask_format, &draw_engine_gpencil_type);
728 
729  GPU_framebuffer_ensure_config(&fbl->mask_fb,
730  {
731  GPU_ATTACHMENT_TEXTURE(depth_tx),
732  GPU_ATTACHMENT_TEXTURE(color_tx),
733  GPU_ATTACHMENT_TEXTURE(pd->mask_tx),
734  });
735  }
736 
738  }
739 }
740 
741 static void GPENCIL_draw_scene_depth_only(void *ved)
742 {
743  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
744  GPENCIL_PrivateData *pd = vedata->stl->pd;
746 
747  if (DRW_state_is_fbo()) {
749  }
750 
752  LISTBASE_FOREACH (GPENCIL_tLayer *, layer, &ob->layers) {
753  DRW_draw_pass(layer->geom_ps);
754  }
755  }
756 
757  if (DRW_state_is_fbo()) {
759  }
760 
762 
763  /* Free temp stroke buffers. */
764  if (pd->sbuffer_gpd) {
766  }
767 }
768 
770 {
771  GPENCIL_PassList *psl = vedata->psl;
772  GPENCIL_FramebufferList *fbl = vedata->fbl;
773  const float clear_col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
774  float clear_depth = ob->is_drawmode3d ? 1.0f : 0.0f;
775  bool inverted = false;
776  /* OPTI(@fclem): we could optimize by only clearing if the new mask_bits does not contain all
777  * the masks already rendered in the buffer, and drawing only the layers not already drawn. */
778  bool cleared = false;
779 
780  DRW_stats_group_start("GPencil Mask");
781 
783 
784  for (int i = 0; i < GP_MAX_MASKBITS; i++) {
785  if (!BLI_BITMAP_TEST(layer->mask_bits, i)) {
786  continue;
787  }
788 
789  if (BLI_BITMAP_TEST_BOOL(layer->mask_invert_bits, i) != inverted) {
790  if (cleared) {
792  }
793  inverted = !inverted;
794  }
795 
796  if (!cleared) {
797  cleared = true;
798  GPU_framebuffer_clear_color_depth(fbl->mask_fb, clear_col, clear_depth);
799  }
800 
801  GPENCIL_tLayer *mask_layer = gpencil_layer_cache_get(ob, i);
802  /* When filtering by viewlayer, the mask could be null and must be ignored. */
803  if (mask_layer == NULL) {
804  continue;
805  }
806 
807  DRW_draw_pass(mask_layer->geom_ps);
808  }
809 
810  if (!inverted) {
811  /* Blend shader expect an opacity mask not a reavealage buffer. */
813  }
814 
816 }
817 
819 {
820  GPENCIL_PassList *psl = vedata->psl;
821  GPENCIL_PrivateData *pd = vedata->stl->pd;
822  GPENCIL_FramebufferList *fbl = vedata->fbl;
823  const float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
824 
825  DRW_stats_group_start("GPencil Object");
826 
827  GPUFrameBuffer *fb_object = (ob->vfx.first) ? fbl->object_fb : fbl->gpencil_fb;
828 
829  GPU_framebuffer_bind(fb_object);
830  GPU_framebuffer_clear_depth_stencil(fb_object, ob->is_drawmode3d ? 1.0f : 0.0f, 0x00);
831 
832  if (ob->vfx.first) {
833  GPU_framebuffer_multi_clear(fb_object, clear_cols);
834  }
835 
836  LISTBASE_FOREACH (GPENCIL_tLayer *, layer, &ob->layers) {
837  if (layer->mask_bits) {
838  gpencil_draw_mask(vedata, ob, layer);
839  }
840 
841  if (layer->blend_ps) {
843  GPU_framebuffer_multi_clear(fbl->layer_fb, clear_cols);
844  }
845  else {
846  GPU_framebuffer_bind(fb_object);
847  }
848 
849  DRW_draw_pass(layer->geom_ps);
850 
851  if (layer->blend_ps) {
852  GPU_framebuffer_bind(fb_object);
853  DRW_draw_pass(layer->blend_ps);
854  }
855  }
856 
857  LISTBASE_FOREACH (GPENCIL_tVfx *, vfx, &ob->vfx) {
858  GPU_framebuffer_bind(*(vfx->target_fb));
859  DRW_draw_pass(vfx->vfx_ps);
860  }
861 
864 
865  if (pd->scene_fb) {
868  }
869 
871 }
872 
874 {
875  GPENCIL_PrivateData *pd = vedata->stl->pd;
876  GPENCIL_FramebufferList *fbl = vedata->fbl;
878 
879  if (!pd->snapshot_buffer_dirty) {
880  /* Copy back cached render. */
884  /* Bypass drawing. */
885  pd->tobjects.first = pd->tobjects.last = NULL;
886  }
887 }
888 
890 {
891  GPENCIL_PrivateData *pd = vedata->stl->pd;
892  GPENCIL_FramebufferList *fbl = vedata->fbl;
894 
895  if (pd->snapshot_buffer_dirty) {
896  /* Save to snapshot buffer. */
900  pd->snapshot_buffer_dirty = false;
901  }
902  /* Draw the sbuffer stroke(s). */
904  GPENCIL_draw_object(vedata, ob);
905  }
906 }
907 
908 void GPENCIL_draw_scene(void *ved)
909 {
910  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
911  GPENCIL_PrivateData *pd = vedata->stl->pd;
912  GPENCIL_FramebufferList *fbl = vedata->fbl;
913  float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
914 
915  /* Fade 3D objects. */
916  if ((!pd->is_render) && (pd->fade_3d_object_opacity > -1.0f) && (pd->obact != NULL) &&
917  (pd->obact->type == OB_GPENCIL)) {
918  float background_color[3];
919  ED_view3d_background_color_get(pd->scene, pd->v3d, background_color);
920  /* Blend color. */
921  interp_v3_v3v3(clear_cols[0], background_color, clear_cols[0], pd->fade_3d_object_opacity);
922 
923  mul_v4_fl(clear_cols[1], pd->fade_3d_object_opacity);
924  }
925 
926  if (pd->draw_depth_only) {
928  return;
929  }
930 
931  if (pd->tobjects.first == NULL) {
932  return;
933  }
934 
935  if (pd->do_fast_drawing) {
936  GPENCIL_fast_draw_start(vedata);
937  }
938 
939  if (pd->tobjects.first) {
941  GPU_framebuffer_multi_clear(fbl->gpencil_fb, clear_cols);
942  }
943 
945  GPENCIL_draw_object(vedata, ob);
946  }
947 
948  if (pd->do_fast_drawing) {
949  GPENCIL_fast_draw_end(vedata);
950  }
951 
952  if (pd->scene_fb) {
954  }
955 
957 
958  /* Free temp stroke buffers. */
959  if (pd->sbuffer_gpd) {
961  }
962 }
963 
964 static void GPENCIL_engine_free(void)
965 {
967 }
968 
970 
972  NULL,
973  NULL,
974  N_("GpencilMode"),
978  NULL, /* instance_free */
983  NULL,
984  NULL,
986  NULL,
987 };
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)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
struct bGPDlayer * BKE_gpencil_layer_active_get(struct bGPdata *gpd)
Definition: gpencil.c:1558
#define GPENCIL_SIMPLIFY_AA(scene)
Definition: BKE_gpencil.h:52
void BKE_gpencil_visible_stroke_advanced_iter(struct ViewLayer *view_layer, struct Object *ob, gpIterCb layer_cb, gpIterCb stroke_cb, void *thunk, bool do_onion, int cfra)
Definition: gpencil.c:2430
#define GPENCIL_SIMPLIFY_FILL(scene, playing)
Definition: BKE_gpencil.h:42
#define GPENCIL_SIMPLIFY_FX(scene, playing)
Definition: BKE_gpencil.h:47
struct bGPDframe * BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
Definition: gpencil.c:1232
@ GP_GETFRAME_USE_PREV
Definition: BKE_gpencil.h:338
bool BKE_gpencil_has_time_modifiers(struct Object *ob)
struct bGPDframe * BKE_gpencil_frame_retime_get(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bGPDlayer *gpl)
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
Definition: material.c:805
General operations, lookup, etc. for blender objects.
@ OB_VISIBLE_SELF
Definition: BKE_object.h:150
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition: BLI_bitmap.h:64
#define BLI_BITMAP_TEST_BOOL(_bitmap, _index)
Definition: BLI_bitmap.h:74
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
MINLINE void mul_v4_fl(float r[4], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
Definition: math_vector.c:29
MINLINE void copy_v3_fl(float r[3], float f)
void BLI_memblock_iternew(BLI_memblock *mblk, BLI_memblock_iter *iter) ATTR_NONNULL()
Definition: BLI_memblock.c:145
void * BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_memblock.c:157
void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1)
Definition: BLI_memblock.c:86
#define UNUSED(x)
float DEG_get_ctime(const Depsgraph *graph)
@ CAM_DOF_ENABLED
@ GP_STROKE_NOFILL
#define GPENCIL_PAINT_MODE(gpd)
@ GP_LAYER_USE_LIGHTS
@ GP_ONION_GHOST_ALWAYS
@ GP_MATERIAL_HIDE_ONIONSKIN
@ GP_MATERIAL_HIDE
@ GP_MATERIAL_STROKE_SHOW
@ GP_MATERIAL_FILL_SHOW
@ OB_WIRE
@ OB_SOLID
@ OB_RENDER
@ OB_MODE_VERTEX_GPENCIL
@ OB_CAMERA
@ OB_LAMP
@ OB_GPENCIL
@ OB_USE_GPENCIL_LIGHTS
@ GP_PROJECT_DEPTH_VIEW
@ GP_PROJECT_DEPTH_STROKE
@ V3D_SHADING_VERTEX_COLOR
#define V3D_GP_FADE_OBJECTS
#define V3D_USES_SCENE_WORLD(v3d)
#define RV3D_CAMOB
#define V3D_GP_FADE_NOACTIVE_LAYERS
#define V3D_GP_SHOW_ONION_SKIN
#define V3D_HIDE_OVERLAYS
#define V3D_USES_SCENE_LIGHTS(v3d)
#define V3D_GP_FADE_NOACTIVE_GPENCIL
#define V3D_GP_SHOW_MULTIEDIT_LINES
@ DRW_TEX_WRAP
Definition: DRW_render.h:141
DRWState
Definition: DRW_render.h:298
@ DRW_STATE_DEPTH_LESS
Definition: DRW_render.h:310
@ DRW_STATE_WRITE_DEPTH
Definition: DRW_render.h:302
@ DRW_STATE_LOGIC_INVERT
Definition: DRW_render.h:337
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:303
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:690
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
Definition: DRW_render.h:651
#define DRW_VIEWPORT_DATA_SIZE(ty)
Definition: DRW_render.h:96
#define DRW_TEXTURE_FREE_SAFE(tex)
Definition: DRW_render.h:183
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
#define XRAY_ENABLED(v3d)
Definition: ED_view3d.h:1299
void ED_view3d_background_color_get(const struct Scene *scene, const struct View3D *v3d, float r_color[3])
#define XRAY_ALPHA(v3d)
Definition: ED_view3d.h:1294
GPUBatch
Definition: GPU_batch.h:78
struct GPUFrameBuffer GPUFrameBuffer
@ GPU_DEPTH_BIT
@ GPU_COLOR_BIT
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
struct GPUShader GPUShader
Definition: GPU_shader.h:20
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
eGPUTextureFormat
Definition: GPU_texture.h:83
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
@ GPU_R16
Definition: GPU_texture.h:114
@ GPU_R8
Definition: GPU_texture.h:107
@ GPU_R11F_G11F_B10F
Definition: GPU_texture.h:118
@ GPU_RGBA8
Definition: GPU_texture.h:87
struct GPUUniformBuf GPUUniformBuf
void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
Scene scene
World world
struct GPUBatch * DRW_cache_gpencil_strokes_get(struct Object *ob, int cfra)
struct bGPDstroke * DRW_cache_gpencil_sbuffer_stroke_data_get(struct Object *ob)
struct GPUBatch * DRW_cache_gpencil_sbuffer_fill_get(struct Object *ob)
struct GPUBatch * DRW_cache_gpencil_fills_get(struct Object *ob, int cfra)
void DRW_cache_gpencil_sbuffer_clear(struct Object *ob)
struct GPUBatch * DRW_cache_gpencil_sbuffer_stroke_get(struct Object *ob)
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
Definition: draw_manager.c:633
int DRW_object_visibility_in_active_context(const Object *ob)
Definition: draw_manager.c:209
bool DRW_state_is_fbo(void)
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)
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_vec4(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_call_instance_range(DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint i_sta, uint i_num)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, Object *ob, uint tri_count)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
void DRW_shgroup_call_range(DRWShadingGroup *shgroup, struct Object *ob, GPUBatch *geom, uint v_sta, uint v_num)
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
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_create_2d(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
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
void GPENCIL_antialiasing_draw(struct GPENCIL_Data *vedata)
void GPENCIL_antialiasing_init(struct GPENCIL_Data *vedata)
GPENCIL_tLayer * gpencil_layer_cache_get(GPENCIL_tObject *tgp_ob, int number)
GPENCIL_tLayer * gpencil_layer_cache_add(GPENCIL_PrivateData *pd, const Object *ob, const bGPDlayer *gpl, const bGPDframe *gpf, GPENCIL_tObject *tgp_ob)
void gpencil_object_cache_sort(GPENCIL_PrivateData *pd)
GPENCIL_tObject * gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob)
void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
GPENCIL_ViewLayerData * GPENCIL_view_layer_data_ensure(void)
GPENCIL_LightPool * gpencil_light_pool_add(GPENCIL_PrivateData *pd)
void gpencil_light_pool_free(void *storage)
void gpencil_material_pool_free(void *storage)
GPENCIL_MaterialPool * gpencil_material_pool_create(GPENCIL_PrivateData *pd, Object *ob, int *ofs)
void gpencil_light_ambient_add(GPENCIL_LightPool *lightpool, const float color[3])
void gpencil_material_resources_get(GPENCIL_MaterialPool *first_pool, int mat_id, GPUTexture **r_tex_stroke, GPUTexture **r_tex_fill, GPUUniformBuf **r_ubo_mat)
static void gpencil_stroke_cache_populate(bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, void *thunk)
static const DrawEngineDataSize GPENCIL_data_size
static void gpencil_sbuffer_cache_populate(gpIterPopulateData *iter)
void GPENCIL_cache_populate(void *ved, Object *ob)
static void gpencil_drawcall_add(gpIterPopulateData *iter, struct GPUBatch *geom, bool instancing, int v_first, int v_count)
void GPENCIL_draw_scene(void *ved)
static void GPENCIL_engine_free(void)
static void gpencil_draw_mask(GPENCIL_Data *vedata, GPENCIL_tObject *ob, GPENCIL_tLayer *layer)
static void GPENCIL_draw_scene_depth_only(void *ved)
#define DRAW_NOW
void GPENCIL_cache_init(void *ved)
static void gpencil_drawcall_flush(gpIterPopulateData *iter)
struct gpIterPopulateData gpIterPopulateData
void GPENCIL_cache_finish(void *ved)
static void GPENCIL_draw_object(GPENCIL_Data *vedata, GPENCIL_tObject *ob)
static void GPENCIL_fast_draw_end(GPENCIL_Data *vedata)
DrawEngineType draw_engine_gpencil_type
static void gpencil_sbuffer_cache_populate_fast(GPENCIL_Data *vedata, gpIterPopulateData *iter)
void GPENCIL_engine_init(void *ved)
static void GPENCIL_fast_draw_start(GPENCIL_Data *vedata)
static void gpencil_layer_cache_populate(bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *UNUSED(gps), void *thunk)
void gpencil_vfx_cache_populate(GPENCIL_Data *vedata, Object *ob, GPENCIL_tObject *tgp_ob)
#define GP_MAX_MASKBITS
struct GPUShader * GPENCIL_shader_mask_invert_get(void)
void GPENCIL_shader_free(void)
void GPENCIL_render_to_image(void *vedata, struct RenderEngine *engine, struct RenderLayer *render_layer, const rcti *rect)
struct GPUShader * GPENCIL_shader_depth_merge_get(void)
void GPU_framebuffer_multi_clear(GPUFrameBuffer *gpu_fb, const float(*clear_cols)[4])
void GPU_framebuffer_blit(GPUFrameBuffer *gpufb_read, int read_slot, GPUFrameBuffer *gpufb_write, int write_slot, eGPUFrameBufferBits blit_buffers)
const int state
ccl_gpu_kernel_postfix ccl_global float int int int int sh
format
Definition: logImageCore.h:38
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define fabsf(x)
Definition: metal/compat.h:219
char sensor_fit
float sensor_y
float lens
float sensor_x
struct CameraDOFSettings dof
struct Object * obact
Definition: DRW_render.h:983
struct Scene * scene
Definition: DRW_render.h:979
const struct bContext * evil_C
Definition: DRW_render.h:997
struct Depsgraph * depsgraph
Definition: DRW_render.h:987
struct ViewLayer * view_layer
Definition: DRW_render.h:980
struct View3D * v3d
Definition: DRW_render.h:976
struct RegionView3D * rv3d
Definition: DRW_render.h:975
struct GPUFrameBuffer * depth_only_fb
struct GPUFrameBuffer * default_fb
struct GPUTexture * depth
struct GPENCIL_TextureList * txl
struct GPENCIL_PassList * psl
struct GPENCIL_StorageList * stl
struct GPENCIL_FramebufferList * fbl
struct GPUFrameBuffer * render_fb
struct GPUFrameBuffer * snapshot_fb
struct GPUFrameBuffer * mask_fb
struct GPUFrameBuffer * gpencil_fb
struct GPUFrameBuffer * object_fb
struct GPUFrameBuffer * layer_fb
gpLight light_data[GPENCIL_LIGHT_BUFFER_LEN]
struct GPUUniformBuf * ubo
struct DRWPass * mask_invert_ps
struct DRWPass * merge_depth_ps
float object_bound_mat[4][4]
GPENCIL_LightPool * last_light_pool
struct BLI_memblock * gp_vfx_pool
GPUTexture * scene_depth_tx
struct bGPDstroke * sbuffer_stroke
struct BLI_memblock * gp_layer_pool
GPUTexture * color_object_tx
GPENCIL_LightPool * shadeless_light_pool
struct bGPDlayer * sbuffer_layer
struct ViewLayer * view_layer
GPUTexture * reveal_tx
struct BLI_memblock * gp_maskbit_pool
struct BLI_memblock * gp_object_pool
struct GPENCIL_PrivateData::@219 tobjects_infront
GPUTexture * dummy_tx
GPENCIL_tObject * first
GPUTexture * color_tx
GPUTexture * mask_tx
struct GPENCIL_PrivateData::@220 sbuffer_tobjects
GPENCIL_LightPool * global_light_pool
GPUTexture * depth_tx
struct BLI_memblock * gp_material_pool
struct View3D * v3d
GPUFrameBuffer * scene_fb
struct Scene * scene
GPENCIL_tObject * last
struct GPENCIL_PrivateData::@219 tobjects
GPUTexture * reveal_layer_tx
struct bGPdata * sbuffer_gpd
GPUTexture * color_layer_tx
struct BLI_memblock * gp_light_pool
GPENCIL_MaterialPool * last_material_pool
GPUTexture * reveal_object_tx
struct GPENCIL_PrivateData * pd
struct GPUTexture * snapshot_reveal_tx
struct GPUTexture * snapshot_depth_tx
struct GPUTexture * snapshot_color_tx
struct GPUTexture * render_depth_tx
struct GPUTexture * dummy_texture
struct BLI_memblock * gp_vfx_pool
struct BLI_memblock * gp_material_pool
struct BLI_memblock * gp_maskbit_pool
struct BLI_memblock * gp_light_pool
struct BLI_memblock * gp_layer_pool
struct BLI_memblock * gp_object_pool
DRWShadingGroup * base_shgrp
BLI_bitmap * mask_invert_bits
DRWPass * geom_ps
BLI_bitmap * mask_bits
float plane_mat[4][4]
struct GPENCIL_tObject::@218 vfx
struct GPENCIL_tObject::@217 layers
struct GPENCIL_tObject * next
GPENCIL_tLayer * first
void * data
float viewcamtexcofac[4]
struct ToolSettings * toolsettings
struct World * world
float gpencil_paper_opacity
float gpencil_vertex_paint_opacity
float studiolight_intensity
float single_color[3]
View3DOverlay overlay
struct Object * camera
View3DShading shading
short gp_flag
float horr
bGPDframe_Runtime runtime
bGPDframe * actframe
bGPDstroke_Runtime runtime
ListBase layers
bGPdata_Runtime runtime
DRWShadingGroup * grp
GPENCIL_PrivateData * pd
GPENCIL_MaterialPool * matpool
GPENCIL_tObject * tgp_ob
GPUUniformBuf * ubo_lights
GPUTexture * tex_fill
GPUTexture * tex_stroke
struct GPUBatch * geom
GPUUniformBuf * ubo_mat
#define N_(msgid)