Blender V4.5
grease_pencil_image_render.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_color.hh"
6#include "BLI_math_geom.h"
7#include "BLI_math_matrix.hh"
8#include "BLI_math_vector.hh"
9
10#include "BKE_attribute.hh"
11#include "BKE_camera.h"
12#include "BKE_curves.hh"
13#include "BKE_grease_pencil.hh"
14#include "BKE_image.hh"
15#include "BKE_material.hh"
16
18#include "DNA_material_types.h"
19#include "DNA_object_types.h"
20#include "DNA_scene_types.h"
21#include "DNA_userdef_types.h"
22#include "DNA_view3d_types.h"
23
24#include "ED_grease_pencil.hh"
25#include "ED_view3d.hh"
26
27#include "IMB_imbuf.hh"
28#include "IMB_imbuf_types.hh"
29
30#include "GPU_debug.hh"
31#include "GPU_framebuffer.hh"
32#include "GPU_immediate.hh"
33#include "GPU_matrix.hh"
34#include "GPU_primitive.hh"
35#include "GPU_shader_builtin.hh"
36#include "GPU_shader_shared.hh"
37#include "GPU_state.hh"
38#include "GPU_texture.hh"
39#include "GPU_uniform_buffer.hh"
40#include "GPU_vertex_format.hh"
41
43
44/* Enable GPU debug capture (needs WITH_RENDERDOC option). */
45constexpr const bool enable_debug_gpu_capture = true;
46
47RegionViewData region_init(ARegion &region, const int2 &win_size)
48{
49 RegionView3D &rv3d = *static_cast<RegionView3D *>(region.regiondata);
50
51 const RegionViewData data = {
52 int2{region.winx, region.winy}, region.winrct, ED_view3d_mats_rv3d_backup(&rv3d)};
53
54 /* Resize region. */
55 region.winrct.xmin = 0;
56 region.winrct.ymin = 0;
57 region.winrct.xmax = win_size.x;
58 region.winrct.ymax = win_size.y;
59 region.winx = short(win_size.x);
60 region.winy = short(win_size.y);
61
62 return data;
63}
64
66{
67 RegionView3D &rv3d = *static_cast<RegionView3D *>(region.regiondata);
68
69 region.winx = data.winsize.x;
70 region.winy = data.winsize.y;
71 region.winrct = data.winrct;
72
73 ED_view3d_mats_rv3d_restore(&rv3d, data.rv3d_store);
75}
76
78{
80 GPU_debug_capture_begin("Grease Pencil Image Render");
81 }
82
83 char err_out[256] = "unknown";
85 win_size.x, win_size.y, true, GPU_RGBA8, GPU_TEXTURE_USAGE_HOST_READ, false, err_out);
86 if (offscreen == nullptr) {
87 return nullptr;
88 }
89
90 GPU_offscreen_bind(offscreen, true);
91
96
97 GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
98 GPU_clear_depth(1.0f);
99
100 return offscreen;
101}
102
104{
107
108 const int2 win_size = {GPU_offscreen_width(buffer), GPU_offscreen_height(buffer)};
109 const uint imb_flag = IB_byte_data;
110 ImBuf *ibuf = IMB_allocImBuf(win_size.x, win_size.y, 32, imb_flag);
111 if (ibuf->float_buffer.data) {
113 }
114 else if (ibuf->byte_buffer.data) {
116 }
117 if (ibuf->float_buffer.data && ibuf->byte_buffer.data) {
119 }
120
121 Image *ima = BKE_image_add_from_imbuf(&bmain, ibuf, "Grease Pencil Fill");
122 ima->id.tag |= ID_TAG_DOIT;
123
124 BKE_image_release_ibuf(ima, ibuf, nullptr);
125
126 /* Switch back to regular frame-buffer. */
127 GPU_offscreen_unbind(buffer, true);
128 GPU_offscreen_free(buffer);
129
132 }
133
134 return ima;
135}
136
137void compute_view_matrices(const ViewContext &view_context,
138 const Scene &scene,
139 const int2 &win_size,
140 const float2 &zoom,
141 const float2 &offset)
142{
143 rctf viewplane;
144 float clip_start, clip_end;
145 const bool is_ortho = ED_view3d_viewplane_get(view_context.depsgraph,
146 view_context.v3d,
147 view_context.rv3d,
148 win_size.x,
149 win_size.y,
150 &viewplane,
151 &clip_start,
152 &clip_end,
153 nullptr);
154
155 /* Rescale `viewplane` to fit all strokes. */
156 const float2 view_min = float2(viewplane.xmin, viewplane.ymin);
157 const float2 view_max = float2(viewplane.xmax, viewplane.ymax);
158 const float2 view_extent = view_max - view_min;
159 const float2 view_center = 0.5f * (view_max + view_min);
160 const float2 offset_abs = offset * view_extent;
161 const float2 view_min_new = (view_min - view_center) * zoom + view_center + offset_abs;
162 const float2 view_max_new = (view_max - view_center) * zoom + view_center + offset_abs;
163 viewplane.xmin = view_min_new.x;
164 viewplane.ymin = view_min_new.y;
165 viewplane.xmax = view_max_new.x;
166 viewplane.ymax = view_max_new.y;
167
168 float4x4 winmat;
169 if (is_ortho) {
170 orthographic_m4(winmat.ptr(),
171 viewplane.xmin,
172 viewplane.xmax,
173 viewplane.ymin,
174 viewplane.ymax,
175 -clip_end,
176 clip_end);
177 }
178 else {
179 perspective_m4(winmat.ptr(),
180 viewplane.xmin,
181 viewplane.xmax,
182 viewplane.ymin,
183 viewplane.ymax,
184 clip_start,
185 clip_end);
186 }
187
189 &scene,
190 view_context.v3d,
191 view_context.region,
192 nullptr,
193 winmat.ptr(),
194 nullptr,
195 true);
196}
197
199{
201}
202
207
212
217
238
240 const IndexRange indices,
241 Span<float3> positions,
242 const VArray<ColorGeometry4f> &colors,
243 const bool cyclic,
244 const float line_width)
245{
247 const uint attr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
248 const uint attr_color = GPU_vertformat_attr_add(
249 format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
251
252 GPU_line_width(line_width);
253 /* If cyclic the curve needs one more vertex. */
254 const int cyclic_add = (cyclic && indices.size() > 2) ? 1 : 0;
255 immBeginAtMost(GPU_PRIM_LINE_STRIP, indices.size() + cyclic_add);
256
257 for (const int point_i : indices) {
258 immAttr4fv(attr_color, colors[point_i]);
259 immVertex3fv(attr_pos, math::transform_point(transform, positions[point_i]));
260 }
261
262 if (cyclic && indices.size() > 2) {
263 const int point_i = indices[0];
264 immAttr4fv(attr_color, colors[point_i]);
265 immVertex3fv(attr_pos, math::transform_point(transform, positions[point_i]));
266 }
267
268 immEnd();
270}
271
272static GPUUniformBuf *create_shader_ubo(const RegionView3D &rv3d,
273 const int2 &win_size,
274 const Object &object,
275 const eGPDstroke_Caps cap_start,
276 const eGPDstroke_Caps cap_end,
277 const bool is_fill_stroke)
278{
280 copy_v2_v2(data.viewport, float2(win_size));
281 data.pixsize = rv3d.pixsize;
282 data.objscale = math::average(float3(object.scale));
283 /* TODO Was based on the GP_DATA_STROKE_KEEPTHICKNESS flag which is currently not converted. */
284 data.keep_size = false;
285 data.pixfactor = 1.0f;
286 /* X-ray mode always to 3D space to avoid wrong Z-depth calculation (#60051). */
287 data.xraymode = GP_XRAY_3DSPACE;
288 data.caps_start = cap_start;
289 data.caps_end = cap_end;
290 data.fill_stroke = is_fill_stroke;
291
292 return GPU_uniformbuf_create_ex(sizeof(GPencilStrokeData), &data, __func__);
293}
294
295constexpr const float min_stroke_thickness = 0.05f;
296
298 const RegionView3D &rv3d,
299 const int2 &win_size,
300 const Object &object,
301 const IndexRange indices,
302 Span<float3> positions,
303 const VArray<float> &radii,
304 const VArray<ColorGeometry4f> &colors,
305 const bool cyclic,
306 const eGPDstroke_Caps cap_start,
307 const eGPDstroke_Caps cap_end,
308 const bool fill_stroke,
309 const float radius_scale)
310{
311 if (indices.is_empty()) {
312 return;
313 }
314
316 /* Format is matching shader manual load. Keep in sync with #GreasePencilStrokeData.
317 * Only the name of the first attribute is important. */
318 const uint attr_pos = GPU_vertformat_attr_add(
319 format, "gp_vert_data", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
320 const uint attr_thickness = GPU_vertformat_attr_add(
321 format, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
322 const uint attr_color = GPU_vertformat_attr_add(
323 format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
324
326 GPUUniformBuf *ubo = create_shader_ubo(rv3d, win_size, object, cap_start, cap_end, fill_stroke);
327 immBindUniformBuf("gpencil_stroke_data", ubo);
328
329 /* If cyclic the curve needs one more vertex. */
330 const int cyclic_add = (cyclic && indices.size() > 2) ? 1 : 0;
331
333 indices.size() + cyclic_add + 2);
334
335 auto draw_point = [&](const int point_i) {
336 constexpr const float radius_to_pixel_factor =
338 const float thickness = radii[point_i] * radius_scale * radius_to_pixel_factor;
339
340 immAttr4fv(attr_color, colors[point_i]);
341 immAttr1f(attr_thickness, std::max(thickness, min_stroke_thickness));
342 immVertex3fv(attr_pos, math::transform_point(transform, positions[point_i]));
343 };
344
345 /* First point for adjacency (not drawn). */
346 if (cyclic && indices.size() > 2) {
347 draw_point(indices.last() - 1);
348 }
349 else {
350 draw_point(indices.first() + 1);
351 }
352
353 for (const int point_i : indices) {
354 draw_point(point_i);
355 }
356
357 if (cyclic && indices.size() > 2) {
358 draw_point(indices.first());
359 draw_point(indices.first() + 1);
360 }
361 /* Last adjacency point (not drawn). */
362 else {
363 draw_point(indices.last() - 1);
364 }
365
366 immEnd();
367
368 /* Expanded `drawcall`. */
369 GPUPrimType expand_prim_type = GPUPrimType::GPU_PRIM_TRIS;
370 /* Hard-coded in shader. */
371 const uint expand_prim_len = 12;
372 /* Do not count adjacency info for start and end primitives. */
373 const uint final_vert_len = ((batch->vertex_count_get() - 2) * expand_prim_len) * 3;
374
375 if (final_vert_len > 0) {
377
378 /* TODO(fclem): get rid of this dummy VBO. */
379 GPUVertFormat format = {0};
382 GPU_vertbuf_data_alloc(*vbo, 1);
383
384 gpu::Batch *gpu_batch = GPU_batch_create_ex(
385 expand_prim_type, vbo, nullptr, GPU_BATCH_OWNS_VBO);
386
387 GPU_batch_set_shader(gpu_batch, batch->shader);
388 GPU_batch_draw_advanced(gpu_batch, 0, final_vert_len, 0, 1);
389
390 GPU_batch_discard(gpu_batch);
391 }
393
395
397}
398
399static void draw_dots(const float4x4 &transform,
400 const IndexRange indices,
401 Span<float3> positions,
402 const VArray<float> &radii,
403 const VArray<ColorGeometry4f> &colors,
404 const float radius_scale)
405{
406 if (indices.is_empty()) {
407 return;
408 }
409
411 const uint attr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
413 const uint attr_color = GPU_vertformat_attr_add(
414 format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
415
418
420
421 for (const int point_i : indices) {
422 constexpr const float radius_to_pixel_factor =
424 const float thickness = radii[point_i] * radius_scale * radius_to_pixel_factor;
425
426 immAttr4fv(attr_color, colors[point_i]);
427 /* NOTE: extra factor 0.5 for point size to match rendering. */
428 immAttr1f(attr_size, std::max(thickness, min_stroke_thickness) * 0.5f);
429 immVertex3fv(attr_pos, math::transform_point(transform, positions[point_i]));
430 }
431
432 immEnd();
435}
436
438 const IndexRange indices,
439 Span<float3> centers,
440 const VArray<float> &radii,
441 const VArray<ColorGeometry4f> &colors,
442 const float2 &viewport_size,
443 const float line_width,
444 const bool fill)
445{
446 if (indices.is_empty()) {
447 return;
448 }
449
450 constexpr const int segments_num = 32;
451 static const float2 coords[] = {
452 {1.0000f, 0.0000f}, {0.9808f, 0.1951f}, {0.9239f, 0.3827f}, {0.8315f, 0.5556f},
453 {0.7071f, 0.7071f}, {0.5556f, 0.8315f}, {0.3827f, 0.9239f}, {0.1951f, 0.9808f},
454 {0.0000f, 1.0000f}, {-0.1951f, 0.9808f}, {-0.3827f, 0.9239f}, {-0.5556f, 0.8315f},
455 {-0.7071f, 0.7071f}, {-0.8315f, 0.5556f}, {-0.9239f, 0.3827f}, {-0.9808f, 0.1951f},
456 {-1.0000f, 0.0000f}, {-0.9808f, -0.1951f}, {-0.9239f, -0.3827f}, {-0.8315f, -0.5556f},
457 {-0.7071f, -0.7071f}, {-0.5556f, -0.8315f}, {-0.3827f, -0.9239f}, {-0.1951f, -0.9808f},
458 {-0.0000f, -1.0000f}, {0.1951f, -0.9808f}, {0.3827f, -0.9239f}, {0.5556f, -0.8315f},
459 {0.7071f, -0.7071f}, {0.8315f, -0.5556f}, {0.9239f, -0.3827f}, {0.9808f, -0.1951f},
460 };
461
463 const uint attr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
464 const uint attr_color = GPU_vertformat_attr_add(
465 format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
466
467 const float scale = math::average(math::to_scale(transform));
468
469 if (fill) {
471
472 for (const int point_i : indices) {
473 const float radius = radii[point_i];
474 const ColorGeometry4f color = colors[point_i];
475 const float3 center = math::transform_point(transform, centers[point_i]);
476
477 immBegin(GPU_PRIM_TRI_STRIP, segments_num);
478
479 for (const int i : IndexRange(segments_num / 2)) {
480 immAttr4fv(attr_color, color);
481 immVertex3fv(attr_pos, center + float3(radius * scale * coords[i], 0.0f));
482 if (segments_num - 1 - i > i) {
483 immAttr4fv(attr_color, color);
484 immVertex3fv(attr_pos,
485 center + float3(radius * scale * coords[segments_num - 1 - i], 0.0f));
486 }
487 }
488
489 immEnd();
490 }
491
493 }
494 else {
496
497 immUniform2fv("viewportSize", viewport_size);
498 immUniform1f("lineWidth", line_width * U.pixelsize);
499
500 for (const int point_i : indices) {
501 const float radius = radii[point_i];
502 const ColorGeometry4f color = colors[point_i];
503 const float3 center = math::transform_point(transform, centers[point_i]);
504
505 immBegin(GPU_PRIM_LINE_STRIP, segments_num + 1);
506
507 for (const int i : IndexRange(segments_num)) {
508 immAttr4fv(attr_color, color);
509 immVertex3fv(attr_pos, center + float3(radius * scale * coords[i], 0.0f));
510 }
511 immAttr4fv(attr_color, color);
512 immVertex3fv(attr_pos, center + float3(radius * scale * coords[0], 0.0f));
513
514 immEnd();
515 }
516
518 }
519}
520
523 Span<float3> start_positions,
524 Span<float3> end_positions,
525 const VArray<ColorGeometry4f> &colors,
526 float line_width)
527{
529 const uint attr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
530 const uint attr_color = GPU_vertformat_attr_add(
531 format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
533
534 GPU_line_width(line_width);
536
537 for (const int point_i : indices) {
538 immAttr4fv(attr_color, colors[point_i]);
539 immVertex3fv(attr_pos, math::transform_point(transform, start_positions[point_i]));
540
541 immAttr4fv(attr_color, colors[point_i]);
542 immVertex3fv(attr_pos, math::transform_point(transform, end_positions[point_i]));
543 }
544
545 immEnd();
547}
548
550 const int2 &win_size,
551 const Object &object,
552 const bke::greasepencil::Drawing &drawing,
553 const float4x4 &transform,
554 const IndexMask &strokes_mask,
555 const VArray<ColorGeometry4f> &colors,
556 const bool use_xray,
557 const float radius_scale)
558{
559 set_view_matrix(rv3d);
560
562 /* Do not write to depth (avoid self-occlusion). */
563 const bool prev_depth_mask = GPU_depth_mask_get();
564 GPU_depth_mask(false);
565 if (!use_xray) {
567 /* First arg is normally rv3d->dist, but this isn't
568 * available here and seems to work quite well without. */
569 GPU_polygon_offset(1.0f, 1.0f);
570 }
571
572 const bke::CurvesGeometry &curves = drawing.strokes();
573 const OffsetIndices points_by_curve = curves.points_by_curve();
574 const Span<float3> positions = curves.positions();
575 const bke::AttributeAccessor attributes = curves.attributes();
576 const VArray<bool> cyclic = curves.cyclic();
577 const VArray<float> &radii = drawing.radii();
578 const VArray<int8_t> stroke_start_caps = *attributes.lookup_or_default<int8_t>(
580 const VArray<int8_t> stroke_end_caps = *attributes.lookup_or_default<int8_t>(
582 const VArray<int> materials = *attributes.lookup_or_default<int>(
583 "material_index", bke::AttrDomain::Curve, 0);
584
585 /* Note: Serial loop without GrainSize, since immediate mode drawing can't happen in worker
586 * threads, has to be from the main thread. */
587 strokes_mask.foreach_index([&](const int stroke_i) {
588 /* Check if the color is visible. */
589 const int material_index = materials[stroke_i];
590 const Material *mat = BKE_object_material_get(const_cast<Object *>(&object),
591 material_index + 1);
592 const eMaterialGPencilStyle_Mode stroke_mode = mat && mat->gp_style ?
594 mat->gp_style->mode) :
596
597 if (mat == nullptr || (mat->gp_style->flag & GP_MATERIAL_HIDE)) {
598 return;
599 }
600
601 switch (eMaterialGPencilStyle_Mode(stroke_mode)) {
604 rv3d,
605 win_size,
606 object,
607 points_by_curve[stroke_i],
608 positions,
609 radii,
610 colors,
611 cyclic[stroke_i],
612 eGPDstroke_Caps(stroke_start_caps[stroke_i]),
613 eGPDstroke_Caps(stroke_end_caps[stroke_i]),
614 false,
615 radius_scale);
616 break;
619 /* NOTE: Squares don't have their own shader, render as dots too. */
620 draw_dots(transform, points_by_curve[stroke_i], positions, radii, colors, radius_scale);
621 break;
622 }
623 });
624
625 if (!use_xray) {
627
628 GPU_polygon_offset(0.0f, 0.0f);
629 }
630 GPU_depth_mask(prev_depth_mask);
633}
634
635} // namespace blender::ed::greasepencil::image_render
Camera data-block and utility functions.
Low-level operations for curves.
Low-level operations for grease pencil.
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
Image * BKE_image_add_from_imbuf(Main *bmain, ImBuf *ibuf, const char *name)
General operations, lookup, etc. for materials.
Material * BKE_object_material_get(Object *ob, short act)
#define M_SQRT2
void orthographic_m4(float mat[4][4], float left, float right, float bottom, float top, float nearClip, float farClip)
void perspective_m4(float mat[4][4], float left, float right, float bottom, float top, float nearClip, float farClip)
MINLINE void copy_v2_v2(float r[2], const float a[2])
unsigned int uint
@ ID_TAG_DOIT
Definition DNA_ID.h:944
@ GP_MATERIAL_HIDE
eMaterialGPencilStyle_Mode
@ GP_MATERIAL_MODE_SQUARE
@ GP_MATERIAL_MODE_DOT
@ GP_MATERIAL_MODE_LINE
Object is a sort of wrapper for general info.
RV3DMatrixStore * ED_view3d_mats_rv3d_backup(RegionView3D *rv3d)
void ED_view3d_mats_rv3d_restore(RegionView3D *rv3d, RV3DMatrixStore *rv3dmat)
void ED_view3D_mats_rv3d_free(RV3DMatrixStore *rv3d_mat)
bool ED_view3d_viewplane_get(const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d, int winx, int winy, rctf *r_viewplane, float *r_clip_start, float *r_clip_end, float *r_pixsize)
void ED_view3d_update_viewmat(const Depsgraph *depsgraph, const Scene *scene, View3D *v3d, ARegion *region, const float viewmat[4][4], const float winmat[4][4], const rcti *rect, bool offscreen)
blender::gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
Definition gpu_batch.cc:51
void GPU_batch_discard(blender::gpu::Batch *batch)
void GPU_batch_draw_advanced(blender::gpu::Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
void GPU_batch_bind_as_resources(blender::gpu::Batch *batch, GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants=nullptr)
void GPU_batch_set_shader(blender::gpu::Batch *batch, GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
@ GPU_BATCH_OWNS_VBO
Definition GPU_batch.hh:41
void GPU_debug_capture_end()
Definition gpu_debug.cc:93
void GPU_debug_capture_begin(const char *title)
Definition gpu_debug.cc:78
int GPU_offscreen_width(const GPUOffScreen *offscreen)
void GPU_offscreen_bind(GPUOffScreen *offscreen, bool save)
int GPU_offscreen_height(const GPUOffScreen *offscreen)
GPUOffScreen * GPU_offscreen_create(int width, int height, bool with_depth_buffer, eGPUTextureFormat format, eGPUTextureUsage usage, bool clear, char err_out[256])
void GPU_clear_color(float red, float green, float blue, float alpha)
void GPU_offscreen_free(GPUOffScreen *offscreen)
void GPU_clear_depth(float depth)
void GPU_offscreen_read_color(GPUOffScreen *offscreen, eGPUDataFormat data_format, void *r_data)
void GPU_offscreen_unbind(GPUOffScreen *offscreen, bool restore)
void immEnd()
void immUniform2fv(const char *name, const float data[2])
void immUnbindProgram()
void immAttr4fv(uint attr_id, const float data[4])
void immAttr1f(uint attr_id, float x)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
blender::gpu::Batch * immBeginBatchAtMost(GPUPrimType, uint vertex_len)
void immBeginAtMost(GPUPrimType, uint max_vertex_len)
void immBindUniformBuf(const char *name, GPUUniformBuf *ubo)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat()
void immVertex3fv(uint attr_id, const float data[3])
void immBegin(GPUPrimType, uint vertex_len)
void GPU_matrix_identity_projection_set()
void GPU_matrix_identity_set()
#define GPU_matrix_set(x)
void GPU_matrix_push()
void GPU_matrix_push_projection()
void GPU_matrix_pop_projection()
#define GPU_matrix_projection_set(x)
void GPU_polygon_offset(float viewdist, float dist)
void GPU_matrix_pop()
GPUPrimType
@ GPU_PRIM_LINE_STRIP_ADJ
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_TRI_STRIP
@ GPU_PRIM_TRIS
@ GPU_SHADER_GPENCIL_STROKE
@ GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR
@ GPU_SHADER_3D_FLAT_COLOR
@ GPU_SHADER_3D_POLYLINE_FLAT_COLOR
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:180
void GPU_line_width(float width)
Definition gpu_state.cc:166
void GPU_depth_mask(bool depth)
Definition gpu_state.cc:110
@ GPU_DEPTH_LESS_EQUAL
Definition GPU_state.hh:114
@ GPU_DEPTH_NONE
Definition GPU_state.hh:111
void GPU_depth_test(eGPUDepthTest test)
Definition gpu_state.cc:68
bool GPU_depth_mask_get()
Definition gpu_state.cc:287
@ GPU_DATA_UBYTE
@ GPU_DATA_FLOAT
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_RGBA8
GPUUniformBuf * GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name)
void GPU_uniformbuf_free(GPUUniformBuf *ubo)
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, blender::StringRef name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
void IMB_byte_from_float(ImBuf *ibuf)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
@ IB_byte_data
#define U
BMesh const char void * data
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) const
const bke::CurvesGeometry & strokes() const
void foreach_index(Fn &&fn) const
static ushort indices[]
struct @064345207361167251075330302113175271221317160336::@113254110077376341056327177062323111323010325277 batch
static uint attr_size(const GPUVertAttr *a)
format
constexpr float LEGACY_RADIUS_CONVERSION_FACTOR
void compute_view_matrices(const ViewContext &view_context, const Scene &scene, const int2 &win_size, const float2 &zoom, const float2 &offset)
void region_reset(ARegion &region, const RegionViewData &data)
void draw_lines(const float4x4 &transform, IndexRange indices, Span< float3 > start_positions, Span< float3 > end_positions, const VArray< ColorGeometry4f > &colors, float line_width)
Image * image_render_end(Main &bmain, GPUOffScreen *buffer)
void draw_grease_pencil_strokes(const RegionView3D &rv3d, const int2 &win_size, const Object &object, const bke::greasepencil::Drawing &drawing, const float4x4 &transform, const IndexMask &strokes_mask, const VArray< ColorGeometry4f > &colors, const bool use_xray, const float radius_scale)
RegionViewData region_init(ARegion &region, const int2 &win_size)
static GPUUniformBuf * create_shader_ubo(const RegionView3D &rv3d, const int2 &win_size, const Object &object, const eGPDstroke_Caps cap_start, const eGPDstroke_Caps cap_end, const bool is_fill_stroke)
static void draw_grease_pencil_stroke(const float4x4 &transform, const RegionView3D &rv3d, const int2 &win_size, const Object &object, const IndexRange indices, Span< float3 > positions, const VArray< float > &radii, const VArray< ColorGeometry4f > &colors, const bool cyclic, const eGPDstroke_Caps cap_start, const eGPDstroke_Caps cap_end, const bool fill_stroke, const float radius_scale)
static void draw_dots(const float4x4 &transform, const IndexRange indices, Span< float3 > positions, const VArray< float > &radii, const VArray< ColorGeometry4f > &colors, const float radius_scale)
void draw_circles(const float4x4 &transform, const IndexRange indices, Span< float3 > centers, const VArray< float > &radii, const VArray< ColorGeometry4f > &colors, const float2 &viewport_size, const float line_width, const bool fill)
void draw_dot(const float4x4 &transform, const float3 &position, const float point_size, const ColorGeometry4f &color)
void draw_polyline(const float4x4 &transform, const IndexRange indices, Span< float3 > positions, const VArray< ColorGeometry4f > &colors, const bool cyclic, const float line_width)
GPUOffScreen * image_render_begin(const int2 &win_size)
T average(const VecBase< T, Size > &a)
VecBase< T, 3 > to_scale(const MatBase< T, NumCol, NumRow > &mat)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
Definition BLI_color.hh:342
VecBase< float, 3 > float3
void * regiondata
int tag
Definition DNA_ID.h:424
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
struct MaterialGPencilStyle * gp_style
float viewmat[4][4]
float winmat[4][4]
RegionView3D * rv3d
Definition ED_view3d.hh:80
ARegion * region
Definition ED_view3d.hh:77
View3D * v3d
Definition ED_view3d.hh:78
Depsgraph * depsgraph
Definition ED_view3d.hh:72
const c_style_mat & ptr() const
float xmax
float xmin
float ymax
float ymin
int ymin
int ymax
int xmin
int xmax
i
Definition text_draw.cc:230