67 const float pixels[1][4] = {{1.0f, 0.0f, 1.0f, 1.0f}};
111 bool use_scene_lights =
false;
112 bool use_scene_world =
false;
138 use_scene_lights =
true;
139 use_scene_world =
true;
156 if (world !=
nullptr && use_scene_world) {
160 float world_light[3];
165 float viewmatinv[4][4];
171 if (ctx && ctx->
rv3d && v3d) {
201 const bool playing = (draw_ctx->
evil_C !=
nullptr) ?
205 pd->
do_onion = show_onion && !hide_overlay && !playing;
214 const bool is_fade_layer = ((!hide_overlay) && (!pd->
is_render) &&
219 const bool is_fade_object = ((!hide_overlay) && (!pd->
is_render) &&
261 GPU_ATTACHMENT_TEXTURE(txl->snapshot_depth_tx),
262 GPU_ATTACHMENT_TEXTURE(txl->snapshot_color_tx),
263 GPU_ATTACHMENT_TEXTURE(txl->snapshot_reveal_tx),
303 float focal_len = cam->
lens;
305 const float scale_camera = 0.001f;
307 float aperture = 0.5f * scale_camera * focal_len / fstop;
308 float focal_len_scaled = scale_camera * focal_len;
309 float sensor_scaled = scale_camera * sensor;
311 if (draw_ctx->
rv3d !=
nullptr) {
315 pd->
dof_params[1] = aperture *
fabsf(focal_len_scaled / (focus_dist - focal_len_scaled));
316 pd->
dof_params[1] *= vp_size[0] / sensor_scaled;
325#define DISABLE_BATCHING 0
333 for (
const Layer *layer : grease_pencil.layers()) {
334 if (layer->view_layer_name().is_empty() ||
335 !
STREQ(view_layer.
name, layer->view_layer_name().c_str()))
345 if (
STREQ(mask->layer_name, mask_layer.name().c_str())) {
357 bool &r_is_used_as_mask)
359 if (!layer.view_layer_name().is_empty() &&
360 !
STREQ(view_layer.
name, layer.view_layer_name().c_str()))
365 r_is_used_as_mask =
true;
398 blender::gpu::Batch *iter_geom =
nullptr;
403 const auto drawcall_flush = [&]() {
405 if (iter_geom !=
nullptr) {
414 const auto drawcall_add =
415 [&](blender::gpu::Batch *draw_geom,
const int v_first,
const int v_count) {
420 int last = vfirst + vcount;
422 if ((draw_geom != iter_geom) || (v_first - last > 0)) {
425 iter_geom = draw_geom;
429 vcount = v_first + v_count - vfirst;
435 const Vector<DrawingInfo> drawings = retrieve_visible_drawings(*pd->
scene, grease_pencil,
true);
438 const Layer &layer = *layers[info.layer_index];
443 const VArray<bool> cyclic = *attributes.lookup_or_default<
bool>(
444 "cyclic", bke::AttrDomain::Curve,
false);
446 IndexMaskMemory memory;
447 const IndexMask visible_strokes = ed::greasepencil::retrieve_visible_strokes(
448 *ob, info.drawing, memory);
453 Array<int> num_triangles_per_stroke(visible_strokes.size());
454 Array<int> num_vertices_per_stroke(visible_strokes.size());
455 int total_num_triangles = 0;
456 int total_num_vertices = 0;
457 visible_strokes.foreach_index([&](
const int stroke_i,
const int pos) {
458 const IndexRange points = points_by_curve[stroke_i];
459 const int num_stroke_triangles = (points.size() >= 3) ? (points.size() - 2) : 0;
460 const int num_stroke_vertices = (points.size() +
461 int(cyclic[stroke_i] && (points.size() >= 3)));
462 num_triangles_per_stroke[
pos] = num_stroke_triangles;
463 num_vertices_per_stroke[
pos] = num_stroke_vertices;
464 total_num_triangles += num_stroke_triangles;
465 total_num_vertices += num_stroke_vertices;
468 bool is_layer_used_as_mask =
false;
470 grease_pencil, layer, *pd->
view_layer, is_layer_used_as_mask);
471 if (!show_drawing_in_render) {
473 t_offset += total_num_triangles;
474 t_offset += total_num_vertices * 2;
481 pd, ob, layer, info.onion_id, is_layer_used_as_mask, tgp_ob);
490 GPUUniformBuf *ubo_mat;
503 const VArray<int> stroke_materials = *attributes.lookup_or_default<
int>(
504 "material_index", bke::AttrDomain::Curve, 0);
506 const bool only_lines = !
ELEM(ob->
mode,
512 const bool is_onion = info.onion_id != 0;
514 visible_strokes.foreach_index([&](
const int stroke_i,
const int pos) {
515 const IndexRange points = points_by_curve[stroke_i];
519 const int material_index = std::max(stroke_materials[stroke_i], 0);
524 const bool show_fill = (points.size() >= 3) &&
528 (!do_onion && !do_multi_frame));
529 const bool skip_stroke = hide_material || (!show_stroke && !show_fill) ||
530 (only_lines && !do_onion && is_onion) || hide_onion;
533 t_offset += num_triangles_per_stroke[
pos];
534 t_offset += num_vertices_per_stroke[
pos] * 2;
538 GPUUniformBuf *new_ubo_mat;
539 GPUTexture *new_tex_fill =
nullptr;
540 GPUTexture *new_tex_stroke =
nullptr;
542 matpool, mat_ofs + material_index, &new_tex_stroke, &new_tex_fill, &new_ubo_mat);
544 const bool resource_changed = (ubo_mat != new_ubo_mat) ||
545 (new_tex_fill && (new_tex_fill != tex_fill)) ||
546 (new_tex_stroke && (new_tex_stroke != tex_stroke));
548 if (resource_changed) {
552 if (new_ubo_mat != ubo_mat) {
554 ubo_mat = new_ubo_mat;
558 tex_fill = new_tex_fill;
560 if (new_tex_stroke) {
562 tex_stroke = new_tex_stroke;
566 blender::gpu::Batch *geom = draw::DRW_cache_grease_pencil_get(pd->
scene, ob);
567 if (iter_geom != geom) {
579 const int v_first = t_offset * 3;
580 const int v_count = num_triangles_per_stroke[
pos] * 3;
581 drawcall_add(geom, v_first, v_count);
584 t_offset += num_triangles_per_stroke[
pos];
587 const int v_first = t_offset * 3;
588 const int v_count = num_vertices_per_stroke[
pos] * 2 * 3;
589 drawcall_add(geom, v_first, v_count);
592 t_offset += num_vertices_per_stroke[
pos] * 2;
661 GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
662 GPU_ATTACHMENT_TEXTURE(pd->color_tx),
663 GPU_ATTACHMENT_TEXTURE(pd->reveal_tx),
674 GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
675 GPU_ATTACHMENT_TEXTURE(pd->color_layer_tx),
676 GPU_ATTACHMENT_TEXTURE(pd->reveal_layer_tx),
688 GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
689 GPU_ATTACHMENT_TEXTURE(pd->color_object_tx),
690 GPU_ATTACHMENT_TEXTURE(pd->reveal_object_tx),
708 GPU_ATTACHMENT_TEXTURE(depth_tx),
709 GPU_ATTACHMENT_TEXTURE(color_tx),
710 GPU_ATTACHMENT_TEXTURE(pd->mask_tx),
743 DRW_cache_gpencil_sbuffer_clear(pd->
obact);
751 const float clear_col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
753 bool inverted =
false;
756 bool cleared =
false;
771 inverted = !inverted;
781 if (mask_layer ==
nullptr) {
801 const float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
815 if (layer->mask_bits) {
819 if (layer->blend_ps) {
829 if (layer->blend_ps) {
892 float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
898 float background_color[3];
940 DRW_cache_gpencil_sbuffer_clear(pd->
obact);
Camera data-block and utility functions.
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
float BKE_camera_object_dof_distance(const struct Object *ob)
wmWindowManager * CTX_wm_manager(const bContext *C)
Low-level operations for curves.
#define GPENCIL_SIMPLIFY_AA(scene)
#define GPENCIL_SIMPLIFY_FILL(scene, playing)
#define GPENCIL_SIMPLIFY_FX(scene, playing)
Low-level operations for grease pencil that cannot be defined in the C++ header yet.
Low-level operations for grease pencil.
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
General operations, lookup, etc. for blender objects.
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_TEST_BOOL(_bitmap, _index)
Single link-list utility macros. (header only api).
#define LISTBASE_FOREACH(type, var, list)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
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)
MINLINE void copy_v3_fl(float r[3], float f)
void BLI_memblock_iternew(BLI_memblock *mblk, BLI_memblock_iter *iter) ATTR_NONNULL()
void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1)
void * BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
float DEG_get_ctime(const Depsgraph *graph)
@ GP_LAYER_TREE_NODE_USE_LIGHTS
@ GP_LAYER_TREE_NODE_DISABLE_MASKS_IN_VIEWLAYER
@ GREASE_PENCIL_STROKE_ORDER_3D
@ GP_MATERIAL_HIDE_ONIONSKIN
@ GP_MATERIAL_STROKE_SHOW
@ OB_MODE_VERTEX_GREASE_PENCIL
@ OB_MODE_PAINT_GREASE_PENCIL
@ OB_MODE_SCULPT_GREASE_PENCIL
@ OB_MODE_WEIGHT_GREASE_PENCIL
@ GP_USE_MULTI_FRAME_EDITING
@ V3D_SHADING_VERTEX_COLOR
#define V3D_USES_SCENE_WORLD(v3d)
@ V3D_GP_SHOW_MULTIEDIT_LINES
@ V3D_GP_FADE_NOACTIVE_GPENCIL
@ V3D_GP_FADE_NOACTIVE_LAYERS
#define V3D_USES_SCENE_LIGHTS(v3d)
#define DRW_PASS_CREATE(pass, state)
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
#define DRW_VIEWPORT_DATA_SIZE(ty)
#define DRW_TEXTURE_FREE_SAFE(tex)
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
#define XRAY_ENABLED(v3d)
void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, float r_color[3])
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
void GPU_framebuffer_clear_depth_stencil(GPUFrameBuffer *fb, float clear_depth, uint clear_stencil)
void GPU_framebuffer_clear_color_depth(GPUFrameBuffer *fb, const float clear_col[4], float clear_depth)
void GPU_framebuffer_multi_clear(GPUFrameBuffer *framebuffer, const float(*clear_colors)[4])
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
#define GPU_framebuffer_ensure_config(_fb,...)
void GPU_framebuffer_blit(GPUFrameBuffer *fb_read, int read_slot, GPUFrameBuffer *fb_write, int write_slot, eGPUFrameBufferBits blit_buffers)
struct GPUShader GPUShader
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
OffsetIndices< int > evaluated_points_by_curve() const
DefaultFramebufferList * DRW_viewport_framebuffer_list_get()
const float * DRW_viewport_size_get()
int DRW_object_visibility_in_active_context(const Object *ob)
DefaultTextureList * DRW_viewport_texture_list_get()
const DRWContextState * DRW_context_state_get()
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_buffer_texture(DRWShadingGroup *shgroup, const char *name, blender::gpu::VertBuf *vertex_buffer)
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)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
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)
void DRW_shgroup_call_range(DRWShadingGroup *shgroup, const Object *ob, blender::gpu::Batch *geom, uint v_sta, uint v_num)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, const Object *ob, uint tri_count)
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
void DRW_shgroup_uniform_vec2_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
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()
GPUTexture * DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
GPUTexture * DRW_texture_create_2d(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
void DRW_texture_ensure_2d(GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags)
DOF_TILES_FLATTEN_GROUP_SIZE coc_tx GPU_R11F_G11F_B10F
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
RAYTRACE_GROUP_SIZE additional_info("eevee_shared", "eevee_gbuffer_data", "eevee_global_ubo", "eevee_sampling_data", "eevee_utility_texture", "eevee_hiz_data", "draw_view") .specialization_constant(Type RAYTRACE_GROUP_SIZE in_sh_0_tx in_sh_2_tx screen_normal_tx GPU_RGBA8
void GPENCIL_antialiasing_draw(GPENCIL_Data *vedata)
void GPENCIL_antialiasing_init(GPENCIL_Data *vedata)
GPENCIL_tLayer * grease_pencil_layer_cache_add(GPENCIL_PrivateData *pd, const Object *ob, const blender::bke::greasepencil::Layer &layer, const int onion_id, const bool is_used_as_mask, GPENCIL_tObject *tgp_ob)
GPENCIL_tLayer * grease_pencil_layer_cache_get(GPENCIL_tObject *tgp_ob, int layer_id, const bool skip_onion)
GPENCIL_tObject * gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob, const bool is_stroke_order_3d, const blender::Bounds< float3 > bounds)
void gpencil_object_cache_sort(GPENCIL_PrivateData *pd)
GPENCIL_MaterialPool * gpencil_material_pool_create(GPENCIL_PrivateData *pd, Object *ob, int *ofs, const bool is_vertex_mode)
void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
GPENCIL_LightPool * gpencil_light_pool_add(GPENCIL_PrivateData *pd)
GPENCIL_ViewLayerData * GPENCIL_view_layer_data_ensure()
void gpencil_light_pool_free(void *storage)
void gpencil_material_pool_free(void *storage)
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)
struct GPUShader * GPENCIL_shader_mask_invert_get(void)
void gpencil_vfx_cache_populate(GPENCIL_Data *vedata, Object *ob, GPENCIL_tObject *tgp_ob, const bool is_edit_mode)
struct GPUShader * GPENCIL_shader_depth_merge_get(void)
void GPENCIL_shader_free(void)
void GPENCIL_render_to_image(void *vedata, struct RenderEngine *engine, struct RenderLayer *render_layer, const rcti *rect)
static const DrawEngineDataSize GPENCIL_data_size
void GPENCIL_cache_populate(void *ved, Object *ob)
void GPENCIL_draw_scene(void *ved)
static void gpencil_draw_mask(GPENCIL_Data *vedata, GPENCIL_tObject *ob, GPENCIL_tLayer *layer)
static void GPENCIL_draw_scene_depth_only(void *ved)
static void GPENCIL_engine_free()
static bool is_used_as_layer_mask_in_viewlayer(const GreasePencil &grease_pencil, const blender::bke::greasepencil::Layer &mask_layer, const ViewLayer &view_layer)
void GPENCIL_cache_init(void *ved)
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)
static GPENCIL_tObject * grease_pencil_object_cache_populate(GPENCIL_PrivateData *pd, GPENCIL_TextureList *txl, Object *ob)
DrawEngineType draw_engine_gpencil_type
void GPENCIL_engine_init(void *ved)
static void GPENCIL_fast_draw_start(GPENCIL_Data *vedata)
static bool use_layer_in_render(const GreasePencil &grease_pencil, const blender::bke::greasepencil::Layer &layer, const ViewLayer &view_layer, bool &r_is_used_as_mask)
void *(* MEM_callocN)(size_t len, const char *str)
struct CameraDOFSettings dof
GPUFrameBuffer * depth_only_fb
GPUFrameBuffer * default_fb
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
struct GPENCIL_PrivateData::@202 tobjects_infront
bool snapshot_buffer_dirty
struct BLI_memblock * gp_maskbit_pool
blender::gpu::Batch * fill_batch
struct BLI_memblock * gp_object_pool
float vertex_paint_opacity
float fade_gp_object_opacity
float v3d_single_color[3]
blender::gpu::Batch * stroke_batch
GPENCIL_LightPool * global_light_pool
float fade_3d_object_opacity
struct GPENCIL_PrivateData::@203 sbuffer_tobjects
struct BLI_memblock * gp_material_pool
struct GPENCIL_PrivateData::@202 tobjects
GPUFrameBuffer * scene_fb
bool use_multiedit_lines_only
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
struct GPENCIL_tObject::@201 vfx
struct GPENCIL_tObject::@200 layers
struct ToolSettings * toolsettings
float gpencil_paper_opacity
float gpencil_vertex_paint_opacity
float studiolight_intensity