Blender  V3.3
gpencil_draw_data.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. */
3 
8 #include "DRW_render.h"
9 
10 #include "DNA_light_types.h"
11 
12 #include "BKE_image.h"
13 
14 #include "BLI_hash.h"
15 #include "BLI_math_color.h"
16 #include "BLI_memblock.h"
17 
18 #include "GPU_uniform_buffer.h"
19 
20 #include "IMB_imbuf_types.h"
21 
22 #include "gpencil_engine.h"
23 
24 /* -------------------------------------------------------------------- */
29 {
31  matpool->next = NULL;
32  matpool->used_count = 0;
33  if (matpool->ubo == NULL) {
34  matpool->ubo = GPU_uniformbuf_create(sizeof(matpool->mat_data));
35  }
36  pd->last_material_pool = matpool;
37  return matpool;
38 }
39 
40 static struct GPUTexture *gpencil_image_texture_get(Image *image, bool *r_alpha_premult)
41 {
42  ImBuf *ibuf;
43  ImageUser iuser = {NULL};
44  struct GPUTexture *gpu_tex = NULL;
45  void *lock;
46 
47  ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
48 
49  if (ibuf != NULL && ibuf->rect != NULL) {
50  gpu_tex = BKE_image_get_gpu_texture(image, &iuser, ibuf);
51  *r_alpha_premult = (image->alpha_mode == IMA_ALPHA_PREMUL);
52  }
54 
55  return gpu_tex;
56 }
57 
58 static void gpencil_uv_transform_get(const float ofs[2],
59  const float scale[2],
60  const float rotation,
61  float r_rot_scale[2][2],
62  float r_offset[2])
63 {
64  /* OPTI this could use 3x2 matrices and reduce the number of operations drastically. */
65  float mat[4][4];
66  unit_m4(mat);
67  /* Offset to center. */
68  translate_m4(mat, 0.5f, 0.5f, 0.0f);
69  /* Reversed order. */
70  rescale_m4(mat, (float[3]){1.0f / scale[0], 1.0f / scale[1], 0.0});
71  rotate_m4(mat, 'Z', -rotation);
72  translate_m4(mat, ofs[0], ofs[1], 0.0f);
73  /* Convert to 3x2 */
74  copy_v2_v2(r_rot_scale[0], mat[0]);
75  copy_v2_v2(r_rot_scale[1], mat[1]);
76  copy_v2_v2(r_offset, mat[3]);
77 }
78 
79 static void gpencil_shade_color(float color[3])
80 {
81  /* This is scene refereed color, not gamma corrected and not per perceptual.
82  * So we lower the threshold a bit. (1.0 / 3.0) */
83  if (color[0] + color[1] + color[2] > 1.1) {
84  add_v3_fl(color, -0.25f);
85  }
86  else {
87  add_v3_fl(color, 0.15f);
88  }
89  CLAMP3(color, 0.0f, 1.0f);
90 }
91 
92 /* Apply all overrides from the solid viewport mode to the GPencil material. */
95  Object *ob,
96  int color_type,
97  MaterialGPencilStyle *gp_style,
98  const eV3DShadingLightingMode lighting_mode)
99 {
100  static MaterialGPencilStyle gp_style_tmp;
101 
102  switch (color_type) {
105  /* Random uses a random color by layer and this is done using the tint
106  * layer. A simple color by object, like meshes, is not practical in
107  * grease pencil. */
108  copy_v4_v4(gp_style_tmp.stroke_rgba, gp_style->stroke_rgba);
109  copy_v4_v4(gp_style_tmp.fill_rgba, gp_style->fill_rgba);
110  gp_style = &gp_style_tmp;
113  break;
115  memcpy(&gp_style_tmp, gp_style, sizeof(*gp_style));
116  gp_style = &gp_style_tmp;
117  if ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && (gp_style->sima)) {
118  copy_v4_fl(gp_style->stroke_rgba, 1.0f);
119  gp_style->mix_stroke_factor = 0.0f;
120  }
121 
122  if ((gp_style->fill_style == GP_MATERIAL_FILL_STYLE_TEXTURE) && (gp_style->ima)) {
123  copy_v4_fl(gp_style->fill_rgba, 1.0f);
124  gp_style->mix_factor = 0.0f;
125  }
126  else if (gp_style->fill_style == GP_MATERIAL_FILL_STYLE_GRADIENT) {
127  /* gp_style->fill_rgba is needed for correct gradient. */
128  gp_style->mix_factor = 0.0f;
129  }
130  break;
132  gp_style = &gp_style_tmp;
135  copy_v3_v3(gp_style->fill_rgba, pd->v3d_single_color);
136  gp_style->fill_rgba[3] = 1.0f;
137  copy_v4_v4(gp_style->stroke_rgba, gp_style->fill_rgba);
138  if (lighting_mode != V3D_LIGHTING_FLAT) {
139  gpencil_shade_color(gp_style->fill_rgba);
140  }
141  break;
143  gp_style = &gp_style_tmp;
146  copy_v4_v4(gp_style->fill_rgba, ob->color);
147  copy_v4_v4(gp_style->stroke_rgba, ob->color);
148  if (lighting_mode != V3D_LIGHTING_FLAT) {
149  gpencil_shade_color(gp_style->fill_rgba);
150  }
151  break;
153  gp_style = &gp_style_tmp;
156  copy_v4_fl(gp_style->fill_rgba, 1.0f);
157  copy_v4_fl(gp_style->stroke_rgba, 1.0f);
158  break;
159  default:
160  break;
161  }
162  return gp_style;
163 }
164 
166 {
168 
169  int mat_len = max_ii(1, BKE_object_material_count_eval(ob));
170 
171  bool reuse_matpool = matpool && ((matpool->used_count + mat_len) <= GPENCIL_MATERIAL_BUFFER_LEN);
172 
173  if (reuse_matpool) {
174  /* Share the matpool with other objects. Return offset to first material. */
175  *ofs = matpool->used_count;
176  }
177  else {
178  matpool = gpencil_material_pool_add(pd);
179  *ofs = 0;
180  }
181 
182  /* Force vertex color in solid mode with vertex paint mode. Same behavior as meshes. */
183  bGPdata *gpd = (bGPdata *)ob->data;
184  int color_type = (pd->v3d_color_type != -1 && GPENCIL_VERTEX_MODE(gpd)) ?
186  pd->v3d_color_type;
187  const eV3DShadingLightingMode lighting_mode = (pd->v3d != NULL) ? pd->v3d->shading.light :
189 
190  GPENCIL_MaterialPool *pool = matpool;
191  for (int i = 0; i < mat_len; i++) {
192  if ((i > 0) && (pool->used_count == GPENCIL_MATERIAL_BUFFER_LEN)) {
193  pool->next = gpencil_material_pool_add(pd);
194  pool = pool->next;
195  }
196  int mat_id = pool->used_count++;
197 
198  gpMaterial *mat_data = &pool->mat_data[mat_id];
200 
201  if (gp_style->mode == GP_MATERIAL_MODE_LINE) {
202  mat_data->flag = 0;
203  }
204  else {
205  switch (gp_style->alignment_mode) {
207  mat_data->flag = GP_STROKE_ALIGNMENT_STROKE;
208  break;
210  mat_data->flag = GP_STROKE_ALIGNMENT_OBJECT;
211  break;
213  default:
214  mat_data->flag = GP_STROKE_ALIGNMENT_FIXED;
215  break;
216  }
217 
218  if (gp_style->mode == GP_MATERIAL_MODE_DOT) {
219  mat_data->flag |= GP_STROKE_DOTS;
220  }
221  }
222 
223  if ((gp_style->mode != GP_MATERIAL_MODE_LINE) ||
224  (gp_style->flag & GP_MATERIAL_DISABLE_STENCIL)) {
225  mat_data->flag |= GP_STROKE_OVERLAP;
226  }
227 
228  /* Material with holdout. */
229  if (gp_style->flag & GP_MATERIAL_IS_STROKE_HOLDOUT) {
230  mat_data->flag |= GP_STROKE_HOLDOUT;
231  }
232  if (gp_style->flag & GP_MATERIAL_IS_FILL_HOLDOUT) {
233  mat_data->flag |= GP_FILL_HOLDOUT;
234  }
235 
236  gp_style = gpencil_viewport_material_overrides(pd, ob, color_type, gp_style, lighting_mode);
237 
238  /* Dots or Squares rotation. */
239  mat_data->alignment_rot[0] = cosf(gp_style->alignment_rotation);
240  mat_data->alignment_rot[1] = sinf(gp_style->alignment_rotation);
241 
242  /* Stroke Style */
243  if ((gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_TEXTURE) && (gp_style->sima)) {
244  bool premul;
245  pool->tex_stroke[mat_id] = gpencil_image_texture_get(gp_style->sima, &premul);
246  mat_data->flag |= pool->tex_stroke[mat_id] ? GP_STROKE_TEXTURE_USE : 0;
247  mat_data->flag |= premul ? GP_STROKE_TEXTURE_PREMUL : 0;
248  copy_v4_v4(mat_data->stroke_color, gp_style->stroke_rgba);
249  mat_data->stroke_texture_mix = 1.0f - gp_style->mix_stroke_factor;
250  mat_data->stroke_u_scale = 500.0f / gp_style->texture_pixsize;
251  }
252  else /* if (gp_style->stroke_style == GP_MATERIAL_STROKE_STYLE_SOLID) */ {
253  pool->tex_stroke[mat_id] = NULL;
254  mat_data->flag &= ~GP_STROKE_TEXTURE_USE;
255  copy_v4_v4(mat_data->stroke_color, gp_style->stroke_rgba);
256  mat_data->stroke_texture_mix = 0.0f;
257  }
258 
259  /* Fill Style */
260  if ((gp_style->fill_style == GP_MATERIAL_FILL_STYLE_TEXTURE) && (gp_style->ima)) {
261  bool use_clip = (gp_style->flag & GP_MATERIAL_TEX_CLAMP) != 0;
262  bool premul;
263  pool->tex_fill[mat_id] = gpencil_image_texture_get(gp_style->ima, &premul);
264  mat_data->flag |= pool->tex_fill[mat_id] ? GP_FILL_TEXTURE_USE : 0;
265  mat_data->flag |= premul ? GP_FILL_TEXTURE_PREMUL : 0;
266  mat_data->flag |= use_clip ? GP_FILL_TEXTURE_CLIP : 0;
268  gp_style->texture_scale,
269  gp_style->texture_angle,
270  (float(*)[2])mat_data->fill_uv_rot_scale,
271  mat_data->fill_uv_offset);
272  copy_v4_v4(mat_data->fill_color, gp_style->fill_rgba);
273  mat_data->fill_texture_mix = 1.0f - gp_style->mix_factor;
274  }
275  else if (gp_style->fill_style == GP_MATERIAL_FILL_STYLE_GRADIENT) {
276  bool use_radial = (gp_style->gradient_type == GP_MATERIAL_GRADIENT_RADIAL);
277  pool->tex_fill[mat_id] = NULL;
278  mat_data->flag |= GP_FILL_GRADIENT_USE;
279  mat_data->flag |= use_radial ? GP_FILL_GRADIENT_RADIAL : 0;
281  gp_style->texture_scale,
282  gp_style->texture_angle,
283  (float(*)[2])mat_data->fill_uv_rot_scale,
284  mat_data->fill_uv_offset);
285  copy_v4_v4(mat_data->fill_color, gp_style->fill_rgba);
286  copy_v4_v4(mat_data->fill_mix_color, gp_style->mix_rgba);
287  mat_data->fill_texture_mix = 1.0f - gp_style->mix_factor;
288  if (gp_style->flag & GP_MATERIAL_FLIP_FILL) {
289  swap_v4_v4(mat_data->fill_color, mat_data->fill_mix_color);
290  }
291  }
292  else /* if (gp_style->fill_style == GP_MATERIAL_FILL_STYLE_SOLID) */ {
293  pool->tex_fill[mat_id] = NULL;
294  copy_v4_v4(mat_data->fill_color, gp_style->fill_rgba);
295  mat_data->fill_texture_mix = 0.0f;
296  }
297  }
298 
299  return matpool;
300 }
301 
303  int mat_id,
304  GPUTexture **r_tex_stroke,
305  GPUTexture **r_tex_fill,
306  GPUUniformBuf **r_ubo_mat)
307 {
308  GPENCIL_MaterialPool *matpool = first_pool;
309  int pool_id = mat_id / GPENCIL_MATERIAL_BUFFER_LEN;
310  for (int i = 0; i < pool_id; i++) {
311  matpool = matpool->next;
312  }
313  mat_id = mat_id % GPENCIL_MATERIAL_BUFFER_LEN;
314  *r_ubo_mat = matpool->ubo;
315  if (r_tex_fill) {
316  *r_tex_fill = matpool->tex_fill[mat_id];
317  }
318  if (r_tex_stroke) {
319  *r_tex_stroke = matpool->tex_stroke[mat_id];
320  }
321 }
322 
325 /* -------------------------------------------------------------------- */
330 {
332  lightpool->light_used = 0;
333  /* Tag light list end. */
334  lightpool->light_data[0].color[0] = -1.0;
335  if (lightpool->ubo == NULL) {
336  lightpool->ubo = GPU_uniformbuf_create(sizeof(lightpool->light_data));
337  }
338  pd->last_light_pool = lightpool;
339  return lightpool;
340 }
341 
342 void gpencil_light_ambient_add(GPENCIL_LightPool *lightpool, const float color[3])
343 {
344  if (lightpool->light_used >= GPENCIL_LIGHT_BUFFER_LEN) {
345  return;
346  }
347 
348  gpLight *gp_light = &lightpool->light_data[lightpool->light_used];
349  gp_light->type = GP_LIGHT_TYPE_AMBIENT;
350  copy_v3_v3(gp_light->color, color);
351  lightpool->light_used++;
352 
353  if (lightpool->light_used < GPENCIL_LIGHT_BUFFER_LEN) {
354  /* Tag light list end. */
355  gp_light[1].color[0] = -1.0f;
356  }
357 }
358 
359 static float light_power_get(const Light *la)
360 {
361  if (la->type == LA_AREA) {
362  return 1.0f / (4.0f * M_PI);
363  }
364  if (ELEM(la->type, LA_SPOT, LA_LOCAL)) {
365  return 1.0f / (4.0f * M_PI * M_PI);
366  }
367 
368  return 1.0f / M_PI;
369 }
370 
372 {
373  Light *la = (Light *)ob->data;
374 
375  if (lightpool->light_used >= GPENCIL_LIGHT_BUFFER_LEN) {
376  return;
377  }
378 
379  gpLight *gp_light = &lightpool->light_data[lightpool->light_used];
380  float(*mat)[4] = (float(*)[4])gp_light->right;
381 
382  if (la->type == LA_SPOT) {
383  copy_m4_m4(mat, ob->imat);
384  gp_light->type = GP_LIGHT_TYPE_SPOT;
385  gp_light->spot_size = cosf(la->spotsize * 0.5f);
386  gp_light->spot_blend = (1.0f - gp_light->spot_size) * la->spotblend;
387  }
388  else if (la->type == LA_AREA) {
389  /* Simulate area lights using a spot light. */
390  normalize_m4_m4(mat, ob->obmat);
391  invert_m4(mat);
392  gp_light->type = GP_LIGHT_TYPE_SPOT;
393  gp_light->spot_size = cosf(M_PI_2);
394  gp_light->spot_blend = (1.0f - gp_light->spot_size) * 1.0f;
395  }
396  else if (la->type == LA_SUN) {
397  normalize_v3_v3(gp_light->forward, ob->obmat[2]);
398  gp_light->type = GP_LIGHT_TYPE_SUN;
399  }
400  else {
401  gp_light->type = GP_LIGHT_TYPE_POINT;
402  }
403  copy_v4_v4(gp_light->position, ob->obmat[3]);
404  copy_v3_v3(gp_light->color, &la->r);
405  mul_v3_fl(gp_light->color, la->energy * light_power_get(la));
406 
407  lightpool->light_used++;
408 
409  if (lightpool->light_used < GPENCIL_LIGHT_BUFFER_LEN) {
410  /* Tag light list end. */
411  gp_light[1].color[0] = -1.0f;
412  }
413 }
414 
416 {
417  GPENCIL_LightPool *lightpool = pd->last_light_pool;
418 
419  if (lightpool == NULL) {
420  lightpool = gpencil_light_pool_add(pd);
421  }
422  /* TODO(fclem): Light linking. */
423  // gpencil_light_pool_populate(lightpool, ob);
424 
425  return lightpool;
426 }
427 
428 void gpencil_material_pool_free(void *storage)
429 {
430  GPENCIL_MaterialPool *matpool = (GPENCIL_MaterialPool *)storage;
431  DRW_UBO_FREE_SAFE(matpool->ubo);
432 }
433 
434 void gpencil_light_pool_free(void *storage)
435 {
436  GPENCIL_LightPool *lightpool = (GPENCIL_LightPool *)storage;
437  DRW_UBO_FREE_SAFE(lightpool->ubo);
438 }
439 
442 /* -------------------------------------------------------------------- */
446 static void gpencil_view_layer_data_free(void *storage)
447 {
448  GPENCIL_ViewLayerData *vldata = (GPENCIL_ViewLayerData *)storage;
449 
456 }
457 
459 {
462 
463  /* NOTE(&fclem): Putting this stuff in viewlayer means it is shared by all viewports.
464  * For now it is ok, but in the future, it could become a problem if we implement
465  * the caching system. */
466  if (*vldata == NULL) {
467  *vldata = MEM_callocN(sizeof(**vldata), "GPENCIL_ViewLayerData");
468 
469  (*vldata)->gp_light_pool = BLI_memblock_create(sizeof(GPENCIL_LightPool));
470  (*vldata)->gp_material_pool = BLI_memblock_create(sizeof(GPENCIL_MaterialPool));
471  (*vldata)->gp_maskbit_pool = BLI_memblock_create(BLI_BITMAP_SIZE(GP_MAX_MASKBITS));
472  (*vldata)->gp_object_pool = BLI_memblock_create(sizeof(GPENCIL_tObject));
473  (*vldata)->gp_layer_pool = BLI_memblock_create(sizeof(GPENCIL_tLayer));
474  (*vldata)->gp_vfx_pool = BLI_memblock_create(sizeof(GPENCIL_tVfx));
475  }
476 
477  return *vldata;
478 }
479 
typedef float(TangentPoint)[2]
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
struct GPUTexture * BKE_image_get_gpu_texture(struct Image *image, struct ImageUser *iuser, struct ImBuf *ibuf)
Definition: image_gpu.cc:438
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
Definition: material.c:805
int BKE_object_material_count_eval(struct Object *ob)
Definition: material.c:746
#define BLI_BITMAP_SIZE(_num)
Definition: BLI_bitmap.h:35
MINLINE int max_ii(int a, int b)
#define M_PI_2
Definition: BLI_math_base.h:23
#define M_PI
Definition: BLI_math_base.h:20
bool invert_m4(float R[4][4])
Definition: math_matrix.c:1206
void unit_m4(float m[4][4])
Definition: rct.c:1090
void translate_m4(float mat[4][4], float tx, float ty, float tz)
Definition: math_matrix.c:2318
void rescale_m4(float mat[4][4], const float scale[3])
Definition: math_matrix.c:2362
void normalize_m4_m4(float R[4][4], const float M[4][4]) ATTR_NONNULL()
Definition: math_matrix.c:1965
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
void rotate_m4(float mat[4][4], char axis, float angle)
Definition: math_matrix.c:2325
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void swap_v4_v4(float a[4], float b[4])
MINLINE void add_v3_fl(float r[3], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void copy_v4_fl(float r[4], float f)
void BLI_memblock_destroy(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1)
Definition: BLI_memblock.c:66
#define BLI_memblock_create(elem_size)
Definition: BLI_memblock.h:32
void * BLI_memblock_alloc(BLI_memblock *mblk) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: BLI_memblock.c:115
#define UNUSED(x)
#define ELEM(...)
#define CLAMP3(vec, b, c)
#define GPENCIL_VERTEX_MODE(gpd)
@ IMA_ALPHA_PREMUL
#define LA_AREA
#define LA_SPOT
#define LA_SUN
#define LA_LOCAL
@ GP_MATERIAL_GRADIENT_RADIAL
@ GP_MATERIAL_FILL_STYLE_GRADIENT
@ GP_MATERIAL_FILL_STYLE_TEXTURE
@ GP_MATERIAL_FILL_STYLE_SOLID
@ GP_MATERIAL_STROKE_STYLE_SOLID
@ GP_MATERIAL_STROKE_STYLE_TEXTURE
@ GP_MATERIAL_FLIP_FILL
@ GP_MATERIAL_DISABLE_STENCIL
@ GP_MATERIAL_IS_STROKE_HOLDOUT
@ GP_MATERIAL_IS_FILL_HOLDOUT
@ GP_MATERIAL_TEX_CLAMP
@ GP_MATERIAL_MODE_DOT
@ GP_MATERIAL_MODE_LINE
@ GP_MATERIAL_FOLLOW_OBJ
@ GP_MATERIAL_FOLLOW_PATH
@ GP_MATERIAL_FOLLOW_FIXED
@ V3D_SHADING_TEXTURE_COLOR
@ V3D_SHADING_VERTEX_COLOR
@ V3D_SHADING_MATERIAL_COLOR
@ V3D_SHADING_OBJECT_COLOR
@ V3D_SHADING_RANDOM_COLOR
@ V3D_SHADING_SINGLE_COLOR
eV3DShadingLightingMode
@ V3D_LIGHTING_FLAT
@ V3D_LIGHTING_STUDIO
#define DRW_UBO_FREE_SAFE(ubo)
Definition: DRW_render.h:191
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
struct GPUUniformBuf GPUUniformBuf
#define GPU_uniformbuf_create(size)
Contains defines and structs used throughout the imbuf module.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
volatile int lock
#define sinf(x)
Definition: cuda/compat.h:102
#define cosf(x)
Definition: cuda/compat.h:101
void ** DRW_view_layer_engine_data_ensure(DrawEngineType *engine_type, void(*callback)(void *storage))
Definition: draw_manager.c:787
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
#define GPENCIL_MATERIAL_BUFFER_LEN
#define GPENCIL_LIGHT_BUFFER_LEN
static MaterialGPencilStyle * gpencil_viewport_material_overrides(GPENCIL_PrivateData *pd, Object *ob, int color_type, MaterialGPencilStyle *gp_style, const eV3DShadingLightingMode lighting_mode)
GPENCIL_LightPool * gpencil_light_pool_create(GPENCIL_PrivateData *pd, Object *UNUSED(ob))
void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
static GPENCIL_MaterialPool * gpencil_material_pool_add(GPENCIL_PrivateData *pd)
GPENCIL_ViewLayerData * GPENCIL_view_layer_data_ensure(void)
static void gpencil_shade_color(float color[3])
GPENCIL_LightPool * gpencil_light_pool_add(GPENCIL_PrivateData *pd)
static void gpencil_uv_transform_get(const float ofs[2], const float scale[2], const float rotation, float r_rot_scale[2][2], float r_offset[2])
void gpencil_light_pool_free(void *storage)
static struct GPUTexture * gpencil_image_texture_get(Image *image, bool *r_alpha_premult)
void gpencil_material_pool_free(void *storage)
static float light_power_get(const Light *la)
static void gpencil_view_layer_data_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)
DrawEngineType draw_engine_gpencil_type
#define GP_MAX_MASKBITS
@ GP_LIGHT_TYPE_AMBIENT
@ GP_LIGHT_TYPE_SUN
@ GP_LIGHT_TYPE_POINT
@ GP_LIGHT_TYPE_SPOT
@ GP_FILL_TEXTURE_USE
@ GP_STROKE_DOTS
@ GP_STROKE_HOLDOUT
@ GP_STROKE_TEXTURE_PREMUL
@ GP_STROKE_ALIGNMENT_STROKE
@ GP_FILL_TEXTURE_PREMUL
@ GP_STROKE_TEXTURE_USE
@ GP_STROKE_ALIGNMENT_OBJECT
@ GP_FILL_GRADIENT_USE
@ GP_FILL_TEXTURE_CLIP
@ GP_FILL_GRADIENT_RADIAL
@ GP_STROKE_OVERLAP
@ GP_FILL_HOLDOUT
@ GP_STROKE_ALIGNMENT_FIXED
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
gpLight light_data[GPENCIL_LIGHT_BUFFER_LEN]
struct GPUUniformBuf * ubo
gpMaterial mat_data[GPENCIL_MATERIAL_BUFFER_LEN]
struct GPUTexture * tex_fill[GPENCIL_MATERIAL_BUFFER_LEN]
struct GPUUniformBuf * ubo
struct GPENCIL_MaterialPool * next
struct GPUTexture * tex_stroke[GPENCIL_MATERIAL_BUFFER_LEN]
GPENCIL_LightPool * last_light_pool
struct BLI_memblock * gp_material_pool
struct View3D * v3d
struct BLI_memblock * gp_light_pool
GPENCIL_MaterialPool * last_material_pool
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
unsigned int * rect
float r
float energy
float spotblend
float spotsize
short type
float imat[4][4]
float obmat[4][4]
float color[4]
void * data
View3DShading shading
gpLightType type
gpMaterialFlag flag