Blender  V2.93
gpencil_engine.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 2017, Blender Foundation.
17  */
18 
22 #include "DRW_engine.h"
23 #include "DRW_render.h"
24 
25 #include "BKE_gpencil.h"
26 #include "BKE_gpencil_modifier.h"
27 #include "BKE_lib_id.h"
28 #include "BKE_main.h"
29 #include "BKE_object.h"
30 #include "BKE_paint.h"
31 #include "BKE_shader_fx.h"
32 
33 #include "BKE_camera.h"
34 #include "BKE_global.h" /* for G.debug */
35 
36 #include "BLI_link_utils.h"
37 #include "BLI_listbase.h"
38 #include "BLI_memblock.h"
39 
40 #include "DNA_camera_types.h"
41 #include "DNA_gpencil_types.h"
42 #include "DNA_screen_types.h"
43 #include "DNA_view3d_types.h"
44 
45 #include "GPU_texture.h"
46 #include "GPU_uniform_buffer.h"
47 
48 #include "gpencil_engine.h"
49 
50 #include "DEG_depsgraph_query.h"
51 
52 #include "ED_screen.h"
53 #include "ED_view3d.h"
54 
55 #include "UI_resources.h"
56 
57 /* *********** FUNCTIONS *********** */
58 
59 void GPENCIL_engine_init(void *ved)
60 {
61  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
62  GPENCIL_StorageList *stl = vedata->stl;
63  GPENCIL_TextureList *txl = vedata->txl;
64  GPENCIL_FramebufferList *fbl = vedata->fbl;
68  const View3D *v3d = ctx->v3d;
69 
70  if (!stl->pd) {
71  stl->pd = MEM_callocN(sizeof(GPENCIL_PrivateData), "GPENCIL_PrivateData");
72  }
73 
74  if (txl->dummy_texture == NULL) {
75  const float pixels[1][4] = {{1.0f, 0.0f, 1.0f, 1.0f}};
76  txl->dummy_texture = DRW_texture_create_2d(1, 1, GPU_RGBA8, DRW_TEX_WRAP, (float *)pixels);
77  }
78 
80 
81  /* Resize and reset memblocks. */
88 
89  stl->pd->gp_light_pool = vldata->gp_light_pool;
90  stl->pd->gp_material_pool = vldata->gp_material_pool;
91  stl->pd->gp_maskbit_pool = vldata->gp_maskbit_pool;
92  stl->pd->gp_object_pool = vldata->gp_object_pool;
93  stl->pd->gp_layer_pool = vldata->gp_layer_pool;
94  stl->pd->gp_vfx_pool = vldata->gp_vfx_pool;
95  stl->pd->view_layer = ctx->view_layer;
96  stl->pd->scene = ctx->scene;
97  stl->pd->v3d = ctx->v3d;
98  stl->pd->last_light_pool = NULL;
99  stl->pd->last_material_pool = NULL;
100  stl->pd->tobjects.first = NULL;
101  stl->pd->tobjects.last = NULL;
102  stl->pd->tobjects_infront.first = NULL;
103  stl->pd->tobjects_infront.last = NULL;
104  stl->pd->sbuffer_tobjects.first = NULL;
105  stl->pd->sbuffer_tobjects.last = NULL;
106  stl->pd->dummy_tx = txl->dummy_texture;
108  stl->pd->draw_wireframe = (v3d && v3d->shading.type == OB_WIRE) && !stl->pd->draw_depth_only;
109  stl->pd->scene_depth_tx = stl->pd->draw_depth_only ? txl->dummy_texture : dtxl->depth;
110  stl->pd->scene_fb = dfbl->default_fb;
111  stl->pd->is_render = txl->render_depth_tx || (v3d && v3d->shading.type == OB_RENDER);
112  stl->pd->is_viewport = (v3d != NULL);
115  /* Small HACK: we don't want the global pool to be reused,
116  * so we set the last light pool to NULL. */
117  stl->pd->last_light_pool = NULL;
118 
119  bool use_scene_lights = false;
120  bool use_scene_world = false;
121 
122  if (v3d) {
123  use_scene_lights = ((v3d->shading.type == OB_MATERIAL) &&
125  ((v3d->shading.type == OB_RENDER) &&
127 
128  use_scene_world = ((v3d->shading.type == OB_MATERIAL) &&
130  ((v3d->shading.type == OB_RENDER) &&
132 
133  stl->pd->v3d_color_type = (v3d->shading.type == OB_SOLID) ? v3d->shading.color_type : -1;
134  /* Special case: If Vertex Paint mode, use always Vertex mode. */
135  if (v3d->shading.type == OB_SOLID && ctx->obact && ctx->obact->type == OB_GPENCIL &&
136  ctx->obact->mode == OB_MODE_VERTEX_GPENCIL) {
138  }
139 
141 
142  /* For non active frame, use only lines in multiedit mode. */
143  const bool overlays_on = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0;
144  stl->pd->use_multiedit_lines_only = overlays_on &&
145  (v3d->gp_flag & V3D_GP_SHOW_MULTIEDIT_LINES) != 0;
146 
147  const bool shmode_xray_support = v3d->shading.type <= OB_SOLID;
148  stl->pd->xray_alpha = (shmode_xray_support && XRAY_ENABLED(v3d)) ? XRAY_ALPHA(v3d) : 1.0f;
149  }
150  else if (stl->pd->is_render) {
151  use_scene_lights = true;
152  use_scene_world = true;
153  stl->pd->use_multiedit_lines_only = false;
154  stl->pd->xray_alpha = 1.0f;
155  stl->pd->v3d_color_type = -1;
156  }
157 
158  stl->pd->use_lighting = (v3d && v3d->shading.type > OB_SOLID) || stl->pd->is_render;
159  stl->pd->use_lights = use_scene_lights;
160 
161  if (txl->render_depth_tx != NULL) {
162  stl->pd->scene_depth_tx = txl->render_depth_tx;
163  stl->pd->scene_fb = fbl->render_fb;
164  }
165 
166  gpencil_light_ambient_add(stl->pd->shadeless_light_pool, (float[3]){1.0f, 1.0f, 1.0f});
167 
168  World *world = ctx->scene->world;
169  if (world != NULL && use_scene_world) {
171  }
172  else if (v3d) {
173  float world_light[3];
174  copy_v3_fl(world_light, v3d->shading.studiolight_intensity);
175  gpencil_light_ambient_add(stl->pd->global_light_pool, world_light);
176  }
177 
178  float viewmatinv[4][4];
179  DRW_view_viewmat_get(NULL, viewmatinv, true);
180  copy_v3_v3(stl->pd->camera_z_axis, viewmatinv[2]);
181  copy_v3_v3(stl->pd->camera_pos, viewmatinv[3]);
182  stl->pd->camera_z_offset = dot_v3v3(viewmatinv[3], viewmatinv[2]);
183 
184  if (ctx && ctx->rv3d && v3d) {
185  stl->pd->camera = (ctx->rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL;
186  }
187  else {
188  stl->pd->camera = NULL;
189  }
190 }
191 
192 void GPENCIL_cache_init(void *ved)
193 {
194  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
195  GPENCIL_PassList *psl = vedata->psl;
196  GPENCIL_TextureList *txl = vedata->txl;
197  GPENCIL_FramebufferList *fbl = vedata->fbl;
198  GPENCIL_PrivateData *pd = vedata->stl->pd;
199  DRWShadingGroup *grp;
200 
201  const DRWContextState *draw_ctx = DRW_context_state_get();
202  pd->cfra = (int)DEG_get_ctime(draw_ctx->depsgraph);
204  pd->use_layer_fb = false;
205  pd->use_object_fb = false;
206  pd->use_mask_fb = false;
207  /* Always use high precision for render. */
208  pd->use_signed_fb = !pd->is_viewport;
209 
210  if (draw_ctx->v3d) {
211  const bool hide_overlay = ((draw_ctx->v3d->flag2 & V3D_HIDE_OVERLAYS) != 0);
212  const bool show_onion = ((draw_ctx->v3d->gp_flag & V3D_GP_SHOW_ONION_SKIN) != 0);
213  const bool playing = (draw_ctx->evil_C != NULL) ?
215  NULL :
216  false;
217  pd->do_onion = show_onion && !hide_overlay && !playing;
218  pd->playing = playing;
219  /* Save simplify flags (can change while drawing, so it's better to save). */
220  Scene *scene = draw_ctx->scene;
221  pd->simplify_fill = GPENCIL_SIMPLIFY_FILL(scene, playing);
222  pd->simplify_fx = GPENCIL_SIMPLIFY_FX(scene, playing) ||
223  (draw_ctx->v3d->shading.type < OB_RENDER);
224 
225  /* Fade Layer. */
226  const bool is_fade_layer = ((!hide_overlay) && (!pd->is_render) &&
227  (draw_ctx->v3d->gp_flag & V3D_GP_FADE_NOACTIVE_LAYERS));
228  pd->fade_layer_opacity = (is_fade_layer) ? draw_ctx->v3d->overlay.gpencil_fade_layer : -1.0f;
230  /* Fade GPencil Objects. */
231  const bool is_fade_object = ((!hide_overlay) && (!pd->is_render) &&
232  (draw_ctx->v3d->gp_flag & V3D_GP_FADE_OBJECTS) &&
233  (draw_ctx->v3d->gp_flag & V3D_GP_FADE_NOACTIVE_GPENCIL));
234  pd->fade_gp_object_opacity = (is_fade_object) ? draw_ctx->v3d->overlay.gpencil_paper_opacity :
235  -1.0f;
236  pd->fade_3d_object_opacity = ((!hide_overlay) && (!pd->is_render) &&
237  (draw_ctx->v3d->gp_flag & V3D_GP_FADE_OBJECTS)) ?
238  draw_ctx->v3d->overlay.gpencil_paper_opacity :
239  -1.0f;
240  }
241  else {
242  pd->do_onion = true;
243  Scene *scene = draw_ctx->scene;
245  pd->simplify_fx = GPENCIL_SIMPLIFY_FX(scene, false);
246  pd->fade_layer_opacity = -1.0f;
247  pd->playing = false;
248  }
249 
250  {
251  pd->sbuffer_stroke = NULL;
252  pd->sbuffer_gpd = NULL;
253  pd->sbuffer_layer = NULL;
254  pd->stroke_batch = NULL;
255  pd->fill_batch = NULL;
256  pd->do_fast_drawing = false;
257 
258  pd->obact = draw_ctx->obact;
259  if (pd->obact && pd->obact->type == OB_GPENCIL && !(pd->draw_depth_only)) {
260  /* Check if active object has a temp stroke data. */
261  bGPdata *gpd = (bGPdata *)pd->obact->data;
262  if (gpd->runtime.sbuffer_used > 0) {
263  pd->sbuffer_gpd = gpd;
266  pd->do_fast_drawing = false; /* TODO option */
267  }
268  }
269  }
270 
271  if (pd->do_fast_drawing) {
273  const float *size = DRW_viewport_size_get();
277 
278  GPU_framebuffer_ensure_config(&fbl->snapshot_fb,
279  {
280  GPU_ATTACHMENT_TEXTURE(txl->snapshot_depth_tx),
281  GPU_ATTACHMENT_TEXTURE(txl->snapshot_color_tx),
282  GPU_ATTACHMENT_TEXTURE(txl->snapshot_reveal_tx),
283  });
284  }
285  else {
286  /* Free unneeded buffers. */
291  }
292 
293  {
296 
298  grp = DRW_shgroup_create(sh, psl->merge_depth_ps);
299  DRW_shgroup_uniform_texture_ref(grp, "depthBuf", &pd->depth_tx);
300  DRW_shgroup_uniform_bool(grp, "strokeOrder3d", &pd->is_stroke_order_3d, 1);
301  DRW_shgroup_uniform_vec4(grp, "gpModelMatrix", pd->object_bound_mat[0], 4);
303  }
304  {
307 
309  grp = DRW_shgroup_create(sh, psl->mask_invert_ps);
311  }
312 
313  Camera *cam = (pd->camera != NULL) ? pd->camera->data : NULL;
314 
315  /* Pseudo DOF setup. */
316  if (cam && (cam->dof.flag & CAM_DOF_ENABLED)) {
317  const float *vp_size = DRW_viewport_size_get();
318  float fstop = cam->dof.aperture_fstop;
319  float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
320  float focus_dist = BKE_camera_object_dof_distance(pd->camera);
321  float focal_len = cam->lens;
322 
323  const float scale_camera = 0.001f;
324  /* we want radius here for the aperture number */
325  float aperture = 0.5f * scale_camera * focal_len / fstop;
326  float focal_len_scaled = scale_camera * focal_len;
327  float sensor_scaled = scale_camera * sensor;
328 
329  if (draw_ctx->rv3d != NULL) {
330  sensor_scaled *= draw_ctx->rv3d->viewcamtexcofac[0];
331  }
332 
333  pd->dof_params[1] = aperture * fabsf(focal_len_scaled / (focus_dist - focal_len_scaled));
334  pd->dof_params[1] *= vp_size[0] / sensor_scaled;
335  pd->dof_params[0] = -focus_dist * pd->dof_params[1];
336  }
337  else {
338  /* Disable DoF blur scaling. */
339  pd->camera = NULL;
340  }
341 }
342 
343 #define DRAW_NOW 2
344 
345 typedef struct gpIterPopulateData {
351  /* Last material UBO bound. Used to avoid unneeded buffer binding. */
354  /* Last texture bound. */
357  /* Offset in the material pool to the first material of this object. */
358  int mat_ofs;
359  /* Is the sbuffer call need to be issued. */
361  /* Indices to do correct insertion of the sbuffer stroke. */
364  /* Infos for call batching. */
365  struct GPUBatch *geom;
369 
370 #define DISABLE_BATCHING 0
371 
373 {
374 #if !DISABLE_BATCHING
375  if (iter->geom != NULL) {
376  if (iter->instancing) {
377  DRW_shgroup_call_instance_range(iter->grp, iter->ob, iter->geom, iter->vfirst, iter->vcount);
378  }
379  else {
380  DRW_shgroup_call_range(iter->grp, iter->ob, iter->geom, iter->vfirst, iter->vcount);
381  }
382  }
383 #endif
384 
385  iter->geom = NULL;
386  iter->vfirst = -1;
387  iter->vcount = 0;
388 }
389 
390 /* Group draw-calls that are consecutive and with the same type. Reduces GPU driver overhead. */
392  gpIterPopulateData *iter, struct GPUBatch *geom, bool instancing, int v_first, int v_count)
393 {
394 #if DISABLE_BATCHING
395  if (instancing) {
396  DRW_shgroup_call_instance_range(iter->grp, iter->ob, geom, v_first, v_count);
397  }
398  else {
399  DRW_shgroup_call_range(iter->grp, iter->ob, geom, v_first, v_count);
400  }
401 #endif
402 
403  int last = iter->vfirst + iter->vcount;
404  /* Interrupt draw-call grouping if the sequence is not consecutive. */
405  if ((geom != iter->geom) || (v_first - last > 3)) {
407  }
408  iter->geom = geom;
409  iter->instancing = instancing;
410  if (iter->vfirst == -1) {
411  iter->vfirst = v_first;
412  }
413  iter->vcount = v_first + v_count - iter->vfirst;
414 }
415 
417  bGPDframe *gpf,
418  bGPDstroke *gps,
419  void *thunk);
420 
422 {
423  iter->do_sbuffer_call = DRAW_NOW;
424  /* In order to draw the sbuffer stroke correctly mixed with other strokes,
425  * we need to offset the stroke index of the sbuffer stroke and the subsequent strokes.
426  * Remember, sbuffer stroke indices start from 0. So we add last index to avoid
427  * masking issues. */
428  iter->grp = DRW_shgroup_create_sub(iter->grp);
429  DRW_shgroup_uniform_block(iter->grp, "gpMaterialBlock", iter->ubo_mat);
430  DRW_shgroup_uniform_float_copy(iter->grp, "strokeIndexOffset", iter->stroke_index_last);
431 
432  const DRWContextState *ctx = DRW_context_state_get();
433  ToolSettings *ts = ctx->scene->toolsettings;
435  /* In this case we can't do correct projection during stroke. We just disable depth test. */
436  DRW_shgroup_uniform_texture(iter->grp, "gpSceneDepthTexture", iter->pd->dummy_tx);
437  }
438 
441 
442  iter->stroke_index_offset = iter->pd->sbuffer_stroke->totpoints + 1;
443  iter->do_sbuffer_call = 0;
444 }
445 
447  bGPDframe *gpf,
448  bGPDstroke *UNUSED(gps),
449  void *thunk)
450 {
451  gpIterPopulateData *iter = (gpIterPopulateData *)thunk;
452  GPENCIL_PrivateData *pd = iter->pd;
453  bGPdata *gpd = (bGPdata *)iter->ob->data;
454 
456 
457  if (iter->do_sbuffer_call) {
459  }
460  else {
461  iter->do_sbuffer_call = !pd->do_fast_drawing && (gpd == pd->sbuffer_gpd) &&
462  (gpl == pd->sbuffer_layer) &&
463  (gpf == NULL || gpf->runtime.onion_id == 0.0f);
464  }
465 
466  GPENCIL_tLayer *tgp_layer = gpencil_layer_cache_add(pd, iter->ob, gpl, gpf, iter->tgp_ob);
467 
468  const bool use_lights = pd->use_lighting && ((gpl->flag & GP_LAYER_USE_LIGHTS) != 0) &&
469  (iter->ob->dtx & OB_USE_GPENCIL_LIGHTS);
470 
471  iter->ubo_lights = (use_lights) ? pd->global_light_pool->ubo : pd->shadeless_light_pool->ubo;
472 
474 
475  /* Iterator dependent uniforms. */
476  DRWShadingGroup *grp = iter->grp = tgp_layer->base_shgrp;
477  DRW_shgroup_uniform_block(grp, "gpLightBlock", iter->ubo_lights);
478  DRW_shgroup_uniform_block(grp, "gpMaterialBlock", iter->ubo_mat);
479  DRW_shgroup_uniform_texture(grp, "gpFillTexture", iter->tex_fill);
480  DRW_shgroup_uniform_texture(grp, "gpStrokeTexture", iter->tex_stroke);
481  DRW_shgroup_uniform_int_copy(grp, "gpMaterialOffset", iter->mat_ofs);
482  DRW_shgroup_uniform_float_copy(grp, "strokeIndexOffset", iter->stroke_index_offset);
483 }
484 
486  bGPDframe *gpf,
487  bGPDstroke *gps,
488  void *thunk)
489 {
490  gpIterPopulateData *iter = (gpIterPopulateData *)thunk;
491 
492  bGPdata *gpd = iter->ob->data;
493  MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(iter->ob, gps->mat_nr + 1);
494 
495  const bool is_render = iter->pd->is_render;
496  bool hide_material = (gp_style->flag & GP_MATERIAL_HIDE) != 0;
497  bool show_stroke = ((gp_style->flag & GP_MATERIAL_STROKE_SHOW) != 0) ||
498  (!is_render && ((gps->flag & GP_STROKE_NOFILL) != 0));
499  bool show_fill = (gps->tot_triangles > 0) && ((gp_style->flag & GP_MATERIAL_FILL_SHOW) != 0) &&
500  (!iter->pd->simplify_fill) && ((gps->flag & GP_STROKE_NOFILL) == 0);
501  bool only_lines = !GPENCIL_PAINT_MODE(gpd) && gpl && gpf && gpl->actframe != gpf &&
503  bool is_onion = gpl && gpf && gpf->runtime.onion_id != 0;
504  bool hide_onion = is_onion && ((gp_style->flag & GP_MATERIAL_HIDE_ONIONSKIN) != 0);
505  if ((hide_material) || (!show_stroke && !show_fill) || (only_lines && !is_onion) ||
506  (hide_onion)) {
507  return;
508  }
509 
510  GPUUniformBuf *ubo_mat;
511  GPUTexture *tex_stroke, *tex_fill;
513  iter->matpool, iter->mat_ofs + gps->mat_nr, &tex_stroke, &tex_fill, &ubo_mat);
514 
515  bool resource_changed = (iter->ubo_mat != ubo_mat) ||
516  (tex_fill && (iter->tex_fill != tex_fill)) ||
517  (tex_stroke && (iter->tex_stroke != tex_stroke));
518 
519  if (resource_changed) {
521 
522  iter->grp = DRW_shgroup_create_sub(iter->grp);
523  if (iter->ubo_mat != ubo_mat) {
524  DRW_shgroup_uniform_block(iter->grp, "gpMaterialBlock", ubo_mat);
525  iter->ubo_mat = ubo_mat;
526  }
527  if (tex_fill) {
528  DRW_shgroup_uniform_texture(iter->grp, "gpFillTexture", tex_fill);
529  iter->tex_fill = tex_fill;
530  }
531  if (tex_stroke) {
532  DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", tex_stroke);
533  iter->tex_stroke = tex_stroke;
534  }
535  }
536 
537  bool do_sbuffer = (iter->do_sbuffer_call == DRAW_NOW);
538 
539  if (show_fill) {
540  GPUBatch *geom = do_sbuffer ? DRW_cache_gpencil_sbuffer_fill_get(iter->ob) :
541  DRW_cache_gpencil_fills_get(iter->ob, iter->pd->cfra);
542  int vfirst = gps->runtime.fill_start * 3;
543  int vcount = gps->tot_triangles * 3;
544  gpencil_drawcall_add(iter, geom, false, vfirst, vcount);
545  }
546 
547  if (show_stroke) {
548  GPUBatch *geom = do_sbuffer ? DRW_cache_gpencil_sbuffer_stroke_get(iter->ob) :
549  DRW_cache_gpencil_strokes_get(iter->ob, iter->pd->cfra);
550  /* Start one vert before to have gl_InstanceID > 0 (see shader). */
551  int vfirst = gps->runtime.stroke_start - 1;
552  /* Include "potential" cyclic vertex and start adj vertex (see shader). */
553  int vcount = gps->totpoints + 1 + 1;
554  gpencil_drawcall_add(iter, geom, true, vfirst, vcount);
555  }
556 
557  iter->stroke_index_last = gps->runtime.stroke_start + gps->totpoints + 1;
558 }
559 
561 {
562  bGPdata *gpd = (bGPdata *)iter->ob->data;
563  if (gpd != iter->pd->sbuffer_gpd) {
564  return;
565  }
566 
567  GPENCIL_TextureList *txl = vedata->txl;
568  GPUTexture *depth_texture = iter->pd->scene_depth_tx;
569  GPENCIL_tObject *last_tgp_ob = iter->pd->tobjects.last;
570  /* Create another temp object that only contain the stroke. */
571  iter->tgp_ob = gpencil_object_cache_add(iter->pd, iter->ob);
572  /* Remove from the main list. */
573  iter->pd->tobjects.last = last_tgp_ob;
574  last_tgp_ob->next = NULL;
575  /* Add to sbuffer tgpobject list. */
576  BLI_LINKS_APPEND(&iter->pd->sbuffer_tobjects, iter->tgp_ob);
577  /* Remove depth test with scene (avoid self occlusion). */
578  iter->pd->scene_depth_tx = txl->dummy_texture;
579 
581  iter->pd->sbuffer_layer, iter->pd->sbuffer_layer->actframe, NULL, iter);
582 
583  const DRWContextState *ctx = DRW_context_state_get();
584  ToolSettings *ts = ctx->scene->toolsettings;
586  /* In this case we can't do correct projection during stroke. We just disable depth test. */
587  DRW_shgroup_uniform_texture(iter->grp, "gpSceneDepthTexture", iter->pd->dummy_tx);
588  }
589 
590  iter->do_sbuffer_call = DRAW_NOW;
593 
594  gpencil_vfx_cache_populate(vedata, iter->ob, iter->tgp_ob);
595 
596  /* Restore state. */
597  iter->do_sbuffer_call = 0;
598  iter->pd->scene_depth_tx = depth_texture;
599 }
600 
601 void GPENCIL_cache_populate(void *ved, Object *ob)
602 {
603  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
604  GPENCIL_PrivateData *pd = vedata->stl->pd;
605  GPENCIL_TextureList *txl = vedata->txl;
606  const bool is_final_render = DRW_state_is_image_render();
607 
608  /* object must be visible */
610  return;
611  }
612 
613  if (ob->data && (ob->type == OB_GPENCIL) && (ob->dt >= OB_SOLID)) {
614  gpIterPopulateData iter = {0};
615  iter.ob = ob;
616  iter.pd = pd;
617  iter.tgp_ob = gpencil_object_cache_add(pd, ob);
618  iter.matpool = gpencil_material_pool_create(pd, ob, &iter.mat_ofs);
619  iter.tex_fill = txl->dummy_texture;
620  iter.tex_stroke = txl->dummy_texture;
621 
622  /* Special case for rendering onion skin. */
623  bGPdata *gpd = (bGPdata *)ob->data;
624  bool do_onion = (!pd->is_render) ? pd->do_onion : (gpd->onion_flag & GP_ONION_GHOST_ALWAYS);
625  gpd->runtime.playing = (short)pd->playing;
626 
627  /* When render in background the active frame could not be properly set due thread priority,
628  * better set again. This is not required in viewport. */
629  if (txl->render_depth_tx) {
630  const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
631  const DRWContextState *draw_ctx = DRW_context_state_get();
632 
633  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
634  /* If there is a time modifier, need remap the time before. */
635  if (time_remap) {
636  gpl->actframe = BKE_gpencil_frame_retime_get(draw_ctx->depsgraph, pd->scene, ob, gpl);
637  }
638  else {
640  }
641  }
642  }
643 
644  BKE_gpencil_visible_stroke_iter(is_final_render ? pd->view_layer : NULL,
645  ob,
648  &iter,
649  do_onion,
650  pd->cfra);
651 
652  gpencil_drawcall_flush(&iter);
653 
654  if (iter.do_sbuffer_call) {
656  }
657 
658  gpencil_vfx_cache_populate(vedata, ob, iter.tgp_ob);
659 
660  if (pd->do_fast_drawing) {
662  }
663  }
664 
665  if (ob->type == OB_LAMP && pd->use_lights) {
667  }
668 }
669 
670 void GPENCIL_cache_finish(void *ved)
671 {
672  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
673  GPENCIL_PrivateData *pd = vedata->stl->pd;
674  GPENCIL_FramebufferList *fbl = vedata->fbl;
675 
676  /* Upload UBO data. */
677  BLI_memblock_iter iter;
680  while ((pool = (GPENCIL_MaterialPool *)BLI_memblock_iterstep(&iter))) {
681  GPU_uniformbuf_update(pool->ubo, pool->mat_data);
682  }
683 
685  GPENCIL_LightPool *lpool;
686  while ((lpool = (GPENCIL_LightPool *)BLI_memblock_iterstep(&iter))) {
687  GPU_uniformbuf_update(lpool->ubo, lpool->light_data);
688  }
689 
690  /* Sort object by decreasing Z to avoid most of alpha ordering issues. */
692 
693  /* Create frame-buffers only if needed. */
694  if (pd->tobjects.first) {
696 
697  const float *size = DRW_viewport_size_get();
702 
703  GPU_framebuffer_ensure_config(&fbl->gpencil_fb,
704  {
705  GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
706  GPU_ATTACHMENT_TEXTURE(pd->color_tx),
707  GPU_ATTACHMENT_TEXTURE(pd->reveal_tx),
708  });
709 
710  if (pd->use_layer_fb) {
715 
716  GPU_framebuffer_ensure_config(&fbl->layer_fb,
717  {
718  GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
719  GPU_ATTACHMENT_TEXTURE(pd->color_layer_tx),
720  GPU_ATTACHMENT_TEXTURE(pd->reveal_layer_tx),
721  });
722  }
723 
724  if (pd->use_object_fb) {
729 
730  GPU_framebuffer_ensure_config(&fbl->object_fb,
731  {
732  GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
733  GPU_ATTACHMENT_TEXTURE(pd->color_object_tx),
734  GPU_ATTACHMENT_TEXTURE(pd->reveal_object_tx),
735  });
736  }
737 
738  if (pd->use_mask_fb) {
739  /* We need an extra depth to not disturb the normal drawing.
740  * The color_tx is needed for frame-buffer completeness. */
741  GPUTexture *color_tx, *depth_tx;
742  depth_tx = DRW_texture_pool_query_2d(
745  /* Use high quality format for render. */
746  eGPUTextureFormat mask_format = pd->is_render ? GPU_R16 : GPU_R8;
748  size[0], size[1], mask_format, &draw_engine_gpencil_type);
749 
750  GPU_framebuffer_ensure_config(&fbl->mask_fb,
751  {
752  GPU_ATTACHMENT_TEXTURE(depth_tx),
753  GPU_ATTACHMENT_TEXTURE(color_tx),
754  GPU_ATTACHMENT_TEXTURE(pd->mask_tx),
755  });
756  }
757 
759  }
760 }
761 
762 static void GPENCIL_draw_scene_depth_only(void *ved)
763 {
764  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
765  GPENCIL_PrivateData *pd = vedata->stl->pd;
767 
768  if (DRW_state_is_fbo()) {
770  }
771 
773  LISTBASE_FOREACH (GPENCIL_tLayer *, layer, &ob->layers) {
774  DRW_draw_pass(layer->geom_ps);
775  }
776  }
777 
778  if (DRW_state_is_fbo()) {
780  }
781 
783 
784  /* Free temp stroke buffers. */
785  if (pd->sbuffer_gpd) {
787  }
788 }
789 
791 {
792  GPENCIL_PassList *psl = vedata->psl;
793  GPENCIL_FramebufferList *fbl = vedata->fbl;
794  const float clear_col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
795  float clear_depth = ob->is_drawmode3d ? 1.0f : 0.0f;
796  bool inverted = false;
797  /* OPTI(fclem) we could optimize by only clearing if the new mask_bits does not contain all
798  * the masks already rendered in the buffer, and drawing only the layers not already drawn. */
799  bool cleared = false;
800 
801  DRW_stats_group_start("GPencil Mask");
802 
804 
805  for (int i = 0; i < GP_MAX_MASKBITS; i++) {
806  if (!BLI_BITMAP_TEST(layer->mask_bits, i)) {
807  continue;
808  }
809 
810  if (BLI_BITMAP_TEST_BOOL(layer->mask_invert_bits, i) != inverted) {
811  if (cleared) {
813  }
814  inverted = !inverted;
815  }
816 
817  if (!cleared) {
818  cleared = true;
819  GPU_framebuffer_clear_color_depth(fbl->mask_fb, clear_col, clear_depth);
820  }
821 
822  GPENCIL_tLayer *mask_layer = gpencil_layer_cache_get(ob, i);
823  /* When filtering by viewlayer, the mask could be null and must be ignored. */
824  if (mask_layer == NULL) {
825  continue;
826  }
827 
828  DRW_draw_pass(mask_layer->geom_ps);
829  }
830 
831  if (!inverted) {
832  /* Blend shader expect an opacity mask not a reavealage buffer. */
834  }
835 
837 }
838 
840 {
841  GPENCIL_PassList *psl = vedata->psl;
842  GPENCIL_PrivateData *pd = vedata->stl->pd;
843  GPENCIL_FramebufferList *fbl = vedata->fbl;
844  const float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
845 
846  DRW_stats_group_start("GPencil Object");
847 
848  GPUFrameBuffer *fb_object = (ob->vfx.first) ? fbl->object_fb : fbl->gpencil_fb;
849 
850  GPU_framebuffer_bind(fb_object);
851  GPU_framebuffer_clear_depth_stencil(fb_object, ob->is_drawmode3d ? 1.0f : 0.0f, 0x00);
852 
853  if (ob->vfx.first) {
854  GPU_framebuffer_multi_clear(fb_object, clear_cols);
855  }
856 
857  LISTBASE_FOREACH (GPENCIL_tLayer *, layer, &ob->layers) {
858  if (layer->mask_bits) {
859  gpencil_draw_mask(vedata, ob, layer);
860  }
861 
862  if (layer->blend_ps) {
864  GPU_framebuffer_multi_clear(fbl->layer_fb, clear_cols);
865  }
866  else {
867  GPU_framebuffer_bind(fb_object);
868  }
869 
870  DRW_draw_pass(layer->geom_ps);
871 
872  if (layer->blend_ps) {
873  GPU_framebuffer_bind(fb_object);
874  DRW_draw_pass(layer->blend_ps);
875  }
876  }
877 
878  LISTBASE_FOREACH (GPENCIL_tVfx *, vfx, &ob->vfx) {
879  GPU_framebuffer_bind(*(vfx->target_fb));
880  DRW_draw_pass(vfx->vfx_ps);
881  }
882 
885 
886  if (pd->scene_fb) {
889  }
890 
892 }
893 
895 {
896  GPENCIL_PrivateData *pd = vedata->stl->pd;
897  GPENCIL_FramebufferList *fbl = vedata->fbl;
899 
900  if (!pd->snapshot_buffer_dirty) {
901  /* Copy back cached render. */
905  /* Bypass drawing. */
906  pd->tobjects.first = pd->tobjects.last = NULL;
907  }
908 }
909 
911 {
912  GPENCIL_PrivateData *pd = vedata->stl->pd;
913  GPENCIL_FramebufferList *fbl = vedata->fbl;
915 
916  if (pd->snapshot_buffer_dirty) {
917  /* Save to snapshot buffer. */
921  pd->snapshot_buffer_dirty = false;
922  }
923  /* Draw the sbuffer stroke(s). */
925  GPENCIL_draw_object(vedata, ob);
926  }
927 }
928 
929 void GPENCIL_draw_scene(void *ved)
930 {
931  GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
932  GPENCIL_PrivateData *pd = vedata->stl->pd;
933  GPENCIL_FramebufferList *fbl = vedata->fbl;
934  float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
935 
936  /* Fade 3D objects. */
937  if ((!pd->is_render) && (pd->fade_3d_object_opacity > -1.0f) && (pd->obact != NULL) &&
938  (pd->obact->type == OB_GPENCIL)) {
939  float background_color[3];
940  ED_view3d_background_color_get(pd->scene, pd->v3d, background_color);
941  /* Blend color. */
942  interp_v3_v3v3(clear_cols[0], background_color, clear_cols[0], pd->fade_3d_object_opacity);
943 
944  mul_v4_fl(clear_cols[1], pd->fade_3d_object_opacity);
945  }
946 
947  if (pd->draw_depth_only) {
949  return;
950  }
951 
952  if (pd->tobjects.first == NULL) {
953  return;
954  }
955 
956  if (pd->do_fast_drawing) {
957  GPENCIL_fast_draw_start(vedata);
958  }
959 
960  if (pd->tobjects.first) {
962  GPU_framebuffer_multi_clear(fbl->gpencil_fb, clear_cols);
963  }
964 
966  GPENCIL_draw_object(vedata, ob);
967  }
968 
969  if (pd->do_fast_drawing) {
970  GPENCIL_fast_draw_end(vedata);
971  }
972 
973  if (pd->scene_fb) {
975  }
976 
978 
979  /* Free temp stroke buffers. */
980  if (pd->sbuffer_gpd) {
982  }
983 }
984 
985 static void GPENCIL_engine_free(void)
986 {
988 }
989 
991 
993  NULL,
994  NULL,
995  N_("GpencilMode"),
1003  NULL,
1004  NULL,
1006  NULL,
1007 };
Camera data-block and utility functions.
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
Definition: camera.c:242
float BKE_camera_object_dof_distance(struct Object *ob)
Definition: camera.c:227
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct bGPDlayer * BKE_gpencil_layer_active_get(struct bGPdata *gpd)
Definition: gpencil.c:1650
#define GPENCIL_SIMPLIFY_AA(scene)
Definition: BKE_gpencil.h:66
void BKE_gpencil_visible_stroke_iter(struct ViewLayer *view_layer, struct Object *ob, gpIterCb layer_cb, gpIterCb stroke_cb, void *thunk, bool do_onion, int cfra)
Definition: gpencil.c:2637
#define GPENCIL_SIMPLIFY_FILL(scene, playing)
Definition: BKE_gpencil.h:56
#define GPENCIL_SIMPLIFY_FX(scene, playing)
Definition: BKE_gpencil.h:61
struct bGPDframe * BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
Definition: gpencil.c:1307
@ GP_GETFRAME_USE_PREV
Definition: BKE_gpencil.h:187
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:713
General operations, lookup, etc. for blender objects.
@ OB_VISIBLE_SELF
Definition: BKE_object.h:125
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition: BLI_bitmap.h:63
#define BLI_BITMAP_TEST_BOOL(_bitmap, _index)
Definition: BLI_bitmap.h:73
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
MINLINE void mul_v4_fl(float r[4], float f)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:49
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
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:163
void * BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_memblock.c:175
void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1)
Definition: BLI_memblock.c:104
#define UNUSED(x)
#define N_(msgid)
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_MATERIAL
@ OB_MODE_VERTEX_GPENCIL
@ OB_USE_GPENCIL_LIGHTS
@ OB_LAMP
@ OB_GPENCIL
@ GP_PROJECT_DEPTH_VIEW
@ GP_PROJECT_DEPTH_STROKE
@ V3D_SHADING_VERTEX_COLOR
#define V3D_GP_FADE_OBJECTS
#define RV3D_CAMOB
#define V3D_GP_FADE_NOACTIVE_LAYERS
#define V3D_GP_SHOW_ONION_SKIN
#define V3D_HIDE_OVERLAYS
#define V3D_GP_FADE_NOACTIVE_GPENCIL
@ V3D_SHADING_SCENE_WORLD_RENDER
@ V3D_SHADING_SCENE_WORLD
@ V3D_SHADING_SCENE_LIGHTS
@ V3D_SHADING_SCENE_LIGHTS_RENDER
#define V3D_GP_SHOW_MULTIEDIT_LINES
@ DRW_TEX_WRAP
Definition: DRW_render.h:140
DRWState
Definition: DRW_render.h:312
@ DRW_STATE_DEPTH_LESS
Definition: DRW_render.h:322
@ DRW_STATE_WRITE_DEPTH
Definition: DRW_render.h:314
@ DRW_STATE_LOGIC_INVERT
Definition: DRW_render.h:349
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:593
#define DRW_VIEWPORT_DATA_SIZE(ty)
Definition: DRW_render.h:97
#define DRW_TEXTURE_FREE_SAFE(tex)
Definition: DRW_render.h:180
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
#define XRAY_ENABLED(v3d)
Definition: ED_view3d.h:710
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:705
GPUBatch
Definition: GPU_batch.h:93
struct GPUFrameBuffer GPUFrameBuffer
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
@ GPU_DEPTH_BIT
@ GPU_COLOR_BIT
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
struct GPUShader GPUShader
Definition: GPU_shader.h:33
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
eGPUTextureFormat
Definition: GPU_texture.h:84
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:121
@ GPU_RGBA16F
Definition: GPU_texture.h:94
@ GPU_R16
Definition: GPU_texture.h:115
@ GPU_R8
Definition: GPU_texture.h:108
@ GPU_R11F_G11F_B10F
Definition: GPU_texture.h:119
@ GPU_RGBA8
Definition: GPU_texture.h:88
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:697
int DRW_object_visibility_in_active_context(const Object *ob)
Definition: draw_manager.c:235
bool DRW_state_is_fbo(void)
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)
DefaultTextureList * DRW_viewport_texture_list_get(void)
Definition: draw_manager.c:702
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuf *ubo)
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_ct)
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_ct)
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)
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)
#define fabsf(x)
format
Definition: logImageCore.h:47
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static ulong state[N]
char sensor_fit
float sensor_y
float sensor_x
struct CameraDOFSettings dof
struct Object * obact
Definition: DRW_render.h:749
struct Scene * scene
Definition: DRW_render.h:745
const struct bContext * evil_C
Definition: DRW_render.h:763
struct Depsgraph * depsgraph
Definition: DRW_render.h:753
struct ViewLayer * view_layer
Definition: DRW_render.h:746
struct View3D * v3d
Definition: DRW_render.h:742
struct RegionView3D * rv3d
Definition: DRW_render.h:741
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 GPENCIL_PrivateData::@212 sbuffer_tobjects
struct BLI_memblock * gp_maskbit_pool
struct BLI_memblock * gp_object_pool
GPUTexture * dummy_tx
GPENCIL_tObject * first
GPUTexture * color_tx
GPUTexture * mask_tx
GPENCIL_LightPool * global_light_pool
GPUTexture * depth_tx
struct BLI_memblock * gp_material_pool
struct View3D * v3d
struct GPENCIL_PrivateData::@211 tobjects_infront
struct GPENCIL_PrivateData::@211 tobjects
GPUFrameBuffer * scene_fb
struct Scene * scene
GPENCIL_tObject * last
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::@210 vfx
struct GPENCIL_tObject::@209 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