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)
365 r_is_used_as_mask =
true;
399 blender::gpu::Batch *iter_geom =
nullptr;
404 const auto drawcall_flush = [&]() {
406 if (iter_geom !=
nullptr) {
415 const auto drawcall_add =
416 [&](blender::gpu::Batch *draw_geom,
const int v_first,
const int v_count) {
421 int last = vfirst + vcount;
423 if ((draw_geom != iter_geom) || (v_first - last > 0)) {
426 iter_geom = draw_geom;
430 vcount = v_first + v_count - vfirst;
439 const Layer &layer = *layers[info.layer_index];
449 *ob, info.drawing, memory);
456 int total_num_triangles = 0;
457 int total_num_vertices = 0;
459 const IndexRange points = points_by_curve[stroke_i];
460 const int num_stroke_triangles = (points.
size() >= 3) ? (points.
size() - 2) : 0;
461 const int num_stroke_vertices = (points.
size() +
462 int(cyclic[stroke_i] && (points.
size() >= 3)));
463 num_triangles_per_stroke[
pos] = num_stroke_triangles;
464 num_vertices_per_stroke[
pos] = num_stroke_vertices;
465 total_num_triangles += num_stroke_triangles;
466 total_num_vertices += num_stroke_vertices;
469 bool is_layer_used_as_mask =
false;
471 grease_pencil, layer, *pd->
view_layer, is_layer_used_as_mask);
472 if (!show_drawing_in_render) {
474 t_offset += total_num_triangles;
475 t_offset += total_num_vertices * 2;
482 pd, ob, layer, info.onion_id, is_layer_used_as_mask, tgp_ob);
491 GPUUniformBuf *ubo_mat;
507 const bool only_lines = !
ELEM(ob->
mode,
513 const bool is_onion = info.onion_id != 0;
516 const IndexRange points = points_by_curve[stroke_i];
520 const int material_index = std::max(stroke_materials[stroke_i], 0);
525 const bool show_fill = (points.
size() >= 3) &&
529 (!do_onion && !do_multi_frame));
530 const bool skip_stroke = hide_material || (!show_stroke && !show_fill) ||
531 (only_lines && !do_onion && is_onion) || hide_onion;
534 t_offset += num_triangles_per_stroke[
pos];
535 t_offset += num_vertices_per_stroke[
pos] * 2;
539 GPUUniformBuf *new_ubo_mat;
540 GPUTexture *new_tex_fill =
nullptr;
541 GPUTexture *new_tex_stroke =
nullptr;
543 matpool, mat_ofs + material_index, &new_tex_stroke, &new_tex_fill, &new_ubo_mat);
545 const bool resource_changed = (ubo_mat != new_ubo_mat) ||
546 (new_tex_fill && (new_tex_fill != tex_fill)) ||
547 (new_tex_stroke && (new_tex_stroke != tex_stroke));
549 if (resource_changed) {
553 if (new_ubo_mat != ubo_mat) {
555 ubo_mat = new_ubo_mat;
559 tex_fill = new_tex_fill;
561 if (new_tex_stroke) {
563 tex_stroke = new_tex_stroke;
568 if (iter_geom != geom) {
580 const int v_first = t_offset * 3;
581 const int v_count = num_triangles_per_stroke[
pos] * 3;
582 drawcall_add(geom, v_first, v_count);
585 t_offset += num_triangles_per_stroke[
pos];
588 const int v_first = t_offset * 3;
589 const int v_count = num_vertices_per_stroke[
pos] * 2 * 3;
590 drawcall_add(geom, v_first, v_count);
593 t_offset += num_vertices_per_stroke[
pos] * 2;
662 GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
663 GPU_ATTACHMENT_TEXTURE(pd->color_tx),
664 GPU_ATTACHMENT_TEXTURE(pd->reveal_tx),
675 GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
676 GPU_ATTACHMENT_TEXTURE(pd->color_layer_tx),
677 GPU_ATTACHMENT_TEXTURE(pd->reveal_layer_tx),
689 GPU_ATTACHMENT_TEXTURE(pd->depth_tx),
690 GPU_ATTACHMENT_TEXTURE(pd->color_object_tx),
691 GPU_ATTACHMENT_TEXTURE(pd->reveal_object_tx),
709 GPU_ATTACHMENT_TEXTURE(depth_tx),
710 GPU_ATTACHMENT_TEXTURE(color_tx),
711 GPU_ATTACHMENT_TEXTURE(pd->mask_tx),
752 const float clear_col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
754 bool inverted =
false;
757 bool cleared =
false;
772 inverted = !inverted;
782 if (mask_layer ==
nullptr) {
802 const float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
816 if (layer->mask_bits) {
820 if (layer->blend_ps) {
830 if (layer->blend_ps) {
893 float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}};
899 float background_color[3];
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)
#define V3D_USES_SCENE_LIGHTS(v3d)
@ V3D_GP_SHOW_MULTIEDIT_LINES
@ V3D_GP_FADE_NOACTIVE_GPENCIL
@ V3D_GP_FADE_NOACTIVE_LAYERS
#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)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between world
struct GPUShader GPUShader
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
void foreach_index(Fn &&fn) const
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr const char * c_str() const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) const
StringRefNull view_layer_name() 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)
void GPENCIL_engine_init(void *vedata)
void GPENCIL_cache_init(void *vedata)
struct GPUShader * GPENCIL_shader_depth_merge_get(void)
void GPENCIL_cache_finish(void *vedata)
void GPENCIL_cache_populate(void *vedata, struct Object *ob)
void GPENCIL_shader_free(void)
DrawEngineType draw_engine_gpencil_type
void GPENCIL_draw_scene(void *vedata)
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)
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)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
blender::gpu::Batch * DRW_cache_grease_pencil_get(const Scene *scene, Object *ob)
gpu::VertBuf * DRW_cache_grease_pencil_position_buffer_get(const Scene *scene, Object *ob)
void DRW_cache_gpencil_sbuffer_clear(Object *ob)
gpu::VertBuf * DRW_cache_grease_pencil_color_buffer_get(const Scene *scene, Object *ob)
Vector< DrawingInfo > retrieve_visible_drawings(const Scene &scene, const GreasePencil &grease_pencil, const bool do_onion_skinning)
IndexMask retrieve_visible_strokes(Object &object, const bke::greasepencil::Drawing &drawing, IndexMaskMemory &memory)
VecBase< float, 3 > float3
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
struct GPENCIL_PrivateData::@075263135205165144040021316300227366261161172302 tobjects_infront
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
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::@075263135205165144040021316300227366261161172302 tobjects
struct BLI_memblock * gp_material_pool
struct GPENCIL_PrivateData::@306021236127224062014147153055313313031254062000 sbuffer_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
BLI_bitmap * mask_invert_bits
struct GPENCIL_tObject::@117060204327112013346067233377200155103124235313 vfx
struct GPENCIL_tObject::@244154305164030075072341172347154006300235046364 layers
GreasePencilLayerTreeNode base
struct ToolSettings * toolsettings
float gpencil_paper_opacity
float gpencil_vertex_paint_opacity
float studiolight_intensity