Blender V5.0
blender::draw::gpencil Namespace Reference

Classes

struct  SortInfo
struct  Engine
struct  MaterialPool
struct  LightPool
struct  tVfx
struct  tLayer
struct  tObject
struct  Instance
struct  GPENCIL_Data
class  ShaderCache

Typedefs

typedef int(* CompareFn) (const void *, const void *)
using StaticShader = gpu::StaticShader

Functions

static float erfinv_approx (const float x)
void init_sort_info (struct SortInfo *si, CompareFn func)
list_nodemerge_lists (list_node *first, list_node *second, CompareFn func)
BLI_INLINE list_nodesweep_up (struct SortInfo *si, list_node *list, unsigned int upto)
BLI_INLINE void insert_list (struct SortInfo *si, list_node *list, unsigned int rank)
BLI_INLINE list_nodelist_sort_do (list_node *list, CompareFn func)
static int gpencil_tobject_dist_sort (const void *a, const void *b)
void gpencil_object_cache_sort (Instance *inst)
struct GpencilBatchCache * gpencil_batch_cache_get (struct Object *ob, int cfra)
static void remap_depth (const View &view, MutableSpan< float > pix_z)
static void render_set_view (RenderEngine *engine, const Depsgraph *depsgraph, const float2 aa_offset=float2{0.0f})
static void render_init_buffers (const DRWContext *draw_ctx, Instance &inst, RenderEngine *engine, RenderLayer *render_layer, const rcti *rect, const bool use_separated_pass)
static void render_result_z (const DRWContext *draw_ctx, RenderLayer *rl, const char *viewname, Instance &instance, const rcti *rect)
static void render_result_combined (RenderLayer *rl, const char *viewname, Instance &instance, const rcti *rect)
static void render_result_separated_pass (float *data, Instance &instance, const rcti *rect)
static void cdf_from_curvemapping (const CurveMapping &curve, Array< float > &cdf)
static void cdf_invert (Array< float > &cdf, Array< float > &inverted_cdf)
static float shutter_time_to_scene_time (const int shutter_position, const float shutter_time, const float frame_time, float time)
static void render_frame (RenderEngine *engine, Depsgraph *depsgraph, const DRWContext *draw_ctx, RenderLayer *render_layer, const rcti rect, gpencil::Instance &inst, Manager &manager, const bool separated_pass)
static bool effect_is_active (ShaderFxData *fx, bool is_edit, bool is_viewport)
Struct After Macros

Typically used to copy/clear polymorphic structs which have a generic member at the start which needs to be left as-is.

bool BLI_memory_is_zero (const void *arr, size_t arr_size)
Layer
static float grease_pencil_layer_final_opacity_get (const Instance *inst, const Object *ob, const GreasePencil &grease_pencil, const bke::greasepencil::Layer &layer)
static float4 grease_pencil_layer_final_tint_and_alpha_get (const Instance *inst, const GreasePencil &grease_pencil, const int onion_id, float *r_alpha)
static void grease_pencil_layer_random_color_get (const Object *ob, const bke::greasepencil::Layer &layer, float r_color[3])
tLayergrease_pencil_layer_cache_get (tObject *tgp_ob, int layer_id, const bool skip_onion)
tLayergrease_pencil_layer_cache_add (Instance *inst, const Object *ob, const bke::greasepencil::Layer &layer, const int onion_id, const bool is_used_as_mask, tObject *tgp_ob)
Material
static MaterialPoolgpencil_material_pool_add (Instance *inst)
static gpu::Texturegpencil_image_texture_get (::Image *image, bool *r_alpha_premult)
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])
static void gpencil_shade_color (float color[3])
static MaterialGPencilStylegpencil_viewport_material_overrides (Instance *inst, Object *ob, int color_type, MaterialGPencilStyle *gp_style, const eV3DShadingLightingMode lighting_mode)
MaterialPoolgpencil_material_pool_create (Instance *inst, Object *ob, int *ofs, const bool is_vertex_mode)
void gpencil_material_resources_get (MaterialPool *first_pool, int mat_id, gpu::Texture **r_tex_stroke, gpu::Texture **r_tex_fill, gpu::UniformBuf **r_ubo_mat)
Lights
LightPoolgpencil_light_pool_add (Instance *inst)
void gpencil_light_ambient_add (LightPool *lightpool, const float color[3])
static float light_power_get (const Light *la)
void gpencil_light_pool_populate (LightPool *lightpool, Object *ob)
LightPoolgpencil_light_pool_create (Instance *inst, Object *)

Object

typedef signed char int8_t
typedef signed short int16_t
typedef signed int int32_t
typedef unsigned char uint8_t
typedef unsigned short uint16_t
typedef unsigned int uint32_t
typedef __int64 int64_t
typedef unsigned __int64 uint64_t
typedef int8_t int_least8_t
typedef int16_t int_least16_t
typedef int32_t int_least32_t
typedef int64_t int_least64_t
typedef uint8_t uint_least8_t
typedef uint16_t uint_least16_t
typedef uint32_t uint_least32_t
typedef uint64_t uint_least64_t
typedef int8_t int_fast8_t
typedef int16_t int_fast16_t
typedef int32_t int_fast32_t
typedef int64_t int_fast64_t
typedef uint8_t uint_fast8_t
typedef uint16_t uint_fast16_t
typedef uint32_t uint_fast32_t
typedef uint64_t uint_fast64_t
typedef _W64 int intptr_t
typedef _W64 unsigned int uintptr_t
typedef int64_t intmax_t
typedef uint64_t uintmax_t
typedef unsigned int uint
typedef unsigned short ushort
typedef unsigned long ulong
typedef unsigned char uchar
tObjectgpencil_object_cache_add (Instance *inst, Object *ob, const bool is_stroke_order_3d, const Bounds< float3 > bounds)
void _BLI_assert_print_pos (const char *file, int line, const char *function, const char *id)
void _BLI_assert_print_extra (const char *str)
void _BLI_assert_print_backtrace (void)
void _BLI_assert_abort (void)
void _BLI_assert_unreachable_print (const char *file, int line, const char *function)

Typedef Documentation

◆ CompareFn

typedef int(* blender::draw::gpencil::CompareFn) (const void *, const void *)

Definition at line 75 of file gpencil_cache_utils.cc.

◆ int16_t

Definition at line 77 of file gpencil_cache_utils.cc.

◆ int32_t

Definition at line 78 of file gpencil_cache_utils.cc.

◆ int64_t

◆ int8_t

Definition at line 76 of file gpencil_cache_utils.cc.

◆ int_fast16_t

◆ int_fast32_t

◆ int_fast64_t

◆ int_fast8_t

◆ int_least16_t

◆ int_least32_t

◆ int_least64_t

◆ int_least8_t

◆ intmax_t

◆ intptr_t

◆ StaticShader

◆ uchar

◆ uint

◆ uint16_t

◆ uint32_t

◆ uint64_t

◆ uint8_t

◆ uint_fast16_t

◆ uint_fast32_t

◆ uint_fast64_t

◆ uint_fast8_t

◆ uint_least16_t

◆ uint_least32_t

◆ uint_least64_t

◆ uint_least8_t

◆ uintmax_t

◆ uintptr_t

◆ ulong

◆ ushort

Function Documentation

◆ _BLI_assert_abort()

void blender::draw::gpencil::_BLI_assert_abort ( void )

◆ _BLI_assert_print_backtrace()

void blender::draw::gpencil::_BLI_assert_print_backtrace ( void )

◆ _BLI_assert_print_extra()

void blender::draw::gpencil::_BLI_assert_print_extra ( const char * str)

◆ _BLI_assert_print_pos()

void blender::draw::gpencil::_BLI_assert_print_pos ( const char * file,
int line,
const char * function,
const char * id )

◆ _BLI_assert_unreachable_print()

void blender::draw::gpencil::_BLI_assert_unreachable_print ( const char * file,
int line,
const char * function )

◆ BLI_memory_is_zero()

bool blender::draw::gpencil::BLI_memory_is_zero ( const void * arr,
size_t arr_size )
extern

◆ cdf_from_curvemapping()

◆ cdf_invert()

◆ effect_is_active()

bool blender::draw::gpencil::effect_is_active ( ShaderFxData * fx,
bool is_edit,
bool is_viewport )
static

◆ erfinv_approx()

float blender::draw::gpencil::erfinv_approx ( const float x)
static

◆ gpencil_batch_cache_get()

struct GpencilBatchCache * blender::draw::gpencil::gpencil_batch_cache_get ( struct Object * ob,
int cfra )

◆ gpencil_image_texture_get()

gpu::Texture * blender::draw::gpencil::gpencil_image_texture_get ( ::Image * image,
bool * r_alpha_premult )
static

◆ gpencil_light_ambient_add()

void blender::draw::gpencil::gpencil_light_ambient_add ( LightPool * lightpool,
const float color[3] )

◆ gpencil_light_pool_add()

◆ gpencil_light_pool_create()

LightPool * blender::draw::gpencil::gpencil_light_pool_create ( Instance * inst,
Object * ob )

Creates a single pool containing all lights assigned (light linked) for a given object.

Definition at line 417 of file gpencil_draw_data.cc.

References gpencil_light_pool_add(), and blender::draw::gpencil::Instance::last_light_pool.

◆ gpencil_light_pool_populate()

◆ gpencil_material_pool_add()

◆ gpencil_material_pool_create()

MaterialPool * blender::draw::gpencil::gpencil_material_pool_create ( Instance * inst,
Object * ob,
int * ofs,
bool is_vertex_mode )

Creates a linked list of material pool containing all materials assigned for a given object. We merge the material pools together if object does not contain a huge amount of materials. Also return an offset to the first material of the object in the UBO.

Definition at line 163 of file gpencil_draw_data.cc.

References MaterialGPencilStyle::alignment_mode, gpMaterial::alignment_rot, MaterialGPencilStyle::alignment_rotation, BKE_gpencil_material_settings(), BKE_object_material_used_with_fallback_eval(), copy_v4_v4(), cosf, gpMaterial::fill_color, gpMaterial::fill_mix_color, MaterialGPencilStyle::fill_rgba, MaterialGPencilStyle::fill_style, gpMaterial::fill_texture_mix, gpMaterial::fill_uv_offset, gpMaterial::fill_uv_rot_scale, gpMaterial::flag, MaterialGPencilStyle::flag, GP_FILL_GRADIENT_RADIAL, GP_FILL_GRADIENT_USE, GP_FILL_HOLDOUT, GP_FILL_TEXTURE_CLIP, GP_FILL_TEXTURE_PREMUL, GP_FILL_TEXTURE_USE, GP_FLAG_NONE, GP_MATERIAL_DISABLE_STENCIL, GP_MATERIAL_FILL_STYLE_GRADIENT, GP_MATERIAL_FILL_STYLE_TEXTURE, GP_MATERIAL_FLIP_FILL, GP_MATERIAL_FOLLOW_FIXED, GP_MATERIAL_FOLLOW_OBJ, GP_MATERIAL_FOLLOW_PATH, GP_MATERIAL_GRADIENT_RADIAL, GP_MATERIAL_IS_FILL_HOLDOUT, GP_MATERIAL_IS_STROKE_HOLDOUT, GP_MATERIAL_MODE_DOT, GP_MATERIAL_MODE_LINE, GP_MATERIAL_STROKE_STYLE_TEXTURE, GP_MATERIAL_TEX_CLAMP, GP_STROKE_ALIGNMENT_FIXED, GP_STROKE_ALIGNMENT_OBJECT, GP_STROKE_ALIGNMENT_STROKE, GP_STROKE_DOTS, GP_STROKE_HOLDOUT, GP_STROKE_OVERLAP, GP_STROKE_TEXTURE_PREMUL, GP_STROKE_TEXTURE_USE, gpencil_image_texture_get(), GPENCIL_MATERIAL_BUFFER_LEN, gpencil_material_pool_add(), gpencil_uv_transform_get(), gpencil_viewport_material_overrides(), MaterialGPencilStyle::gradient_type, i, MaterialGPencilStyle::ima, blender::draw::gpencil::Instance::last_material_pool, View3DShading::light, blender::draw::gpencil::MaterialPool::mat_data, MaterialGPencilStyle::mix_factor, MaterialGPencilStyle::mix_rgba, MaterialGPencilStyle::mix_stroke_factor, MaterialGPencilStyle::mode, blender::draw::gpencil::MaterialPool::next, View3D::shading, MaterialGPencilStyle::sima, sinf, gpMaterial::stroke_color, MaterialGPencilStyle::stroke_rgba, MaterialGPencilStyle::stroke_style, gpMaterial::stroke_texture_mix, gpMaterial::stroke_u_scale, swap_v4_v4(), blender::draw::gpencil::MaterialPool::tex_fill, blender::draw::gpencil::MaterialPool::tex_stroke, MaterialGPencilStyle::texture_angle, MaterialGPencilStyle::texture_offset, MaterialGPencilStyle::texture_pixsize, MaterialGPencilStyle::texture_scale, blender::draw::gpencil::MaterialPool::used_count, blender::draw::gpencil::Instance::v3d, blender::draw::gpencil::Instance::v3d_color_type, V3D_LIGHTING_STUDIO, and V3D_SHADING_VERTEX_COLOR.

◆ gpencil_material_resources_get()

void blender::draw::gpencil::gpencil_material_resources_get ( MaterialPool * first_pool,
int mat_id,
gpu::Texture ** r_tex_stroke,
gpu::Texture ** r_tex_fill,
gpu::UniformBuf ** r_ubo_mat )

◆ gpencil_object_cache_add()

◆ gpencil_object_cache_sort()

void blender::draw::gpencil::gpencil_object_cache_sort ( Instance * inst)

Definition at line 149 of file gpencil_cache_utils.cc.

Referenced by blender::draw::gpencil::Instance::draw().

◆ gpencil_shade_color()

void blender::draw::gpencil::gpencil_shade_color ( float color[3])
static

Definition at line 77 of file gpencil_draw_data.cc.

References add_v3_fl(), and clamp_v3().

Referenced by gpencil_viewport_material_overrides().

◆ gpencil_tobject_dist_sort()

int blender::draw::gpencil::gpencil_tobject_dist_sort ( const void * a,
const void * b )
static

Definition at line 134 of file gpencil_cache_utils.cc.

References b.

◆ gpencil_uv_transform_get()

void blender::draw::gpencil::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] )
static

◆ gpencil_viewport_material_overrides()

◆ grease_pencil_layer_cache_add()

tLayer * blender::draw::gpencil::grease_pencil_layer_cache_add ( Instance * inst,
const Object * ob,
const bke::greasepencil::Layer & layer,
const int onion_id,
const bool is_used_as_mask,
tObject * tgp_ob )

Definition at line 296 of file gpencil_cache_utils.cc.

References blender::draw::detail::SubPassVector< T, block_size >::append_and_get_index(), TreeNode::as_layer(), GreasePencilLayer::base, GreasePencilLayer::blend_mode, blender::draw::gpencil::tLayer::blend_ps, BLI_BITMAP_SET, BLI_bitmap_set_all(), BLI_LINKS_APPEND, BLI_listbase_is_empty(), BLI_memblock_alloc(), blender::StringRefNull::c_str(), DRW_object_get_data_for_drawing(), DRW_STATE_BLEND_ALPHA_PREMUL, DRW_STATE_STENCIL_EQUAL, DRW_STATE_WRITE_COLOR, Object::dtx, GreasePencilLayerTreeNode::flag, GP_LAYER_BLEND_NONE, GP_LAYER_MASK_HIDE, GP_LAYER_MASK_INVERT, blender::draw::gpencil::Instance::gp_layer_pool, GP_LAYER_TREE_NODE_DISABLE_MASKS_IN_VIEWLAYER, blender::draw::gpencil::Instance::gp_maskbit_pool, GP_MAX_MASKBITS, grease_pencil_layer_final_opacity_get(), grease_pencil_layer_final_tint_and_alpha_get(), blender::math::invert(), blender::StringRefBase::is_empty(), blender::draw::gpencil::tLayer::is_onion, blender::draw::gpencil::Instance::is_render, blender::draw::gpencil::tLayer::layer_id, blender::draw::gpencil::tObject::layers, LISTBASE_FOREACH, mask(), blender::draw::gpencil::tLayer::mask_bits, blender::draw::gpencil::tLayer::mask_invert_bits, GreasePencilLayer::masks, Object::mode, ViewLayer::name, OB_DRAW_IN_FRONT, OB_MODE_PAINT_GREASE_PENCIL, OB_MODE_VERTEX_PAINT, state, STREQ, blender::draw::gpencil::Instance::use_mask_fb, blender::draw::gpencil::Instance::v3d_color_type, V3D_SHADING_VERTEX_COLOR, blender::draw::gpencil::Instance::vertex_paint_opacity, blender::draw::gpencil::Instance::view_layer, blender::bke::greasepencil::Layer::view_layer_name(), and blender::draw::gpencil::Instance::xray_alpha.

◆ grease_pencil_layer_cache_get()

tLayer * blender::draw::gpencil::grease_pencil_layer_cache_get ( tObject * tgp_ob,
int layer_id,
const bool skip_onion )

◆ grease_pencil_layer_final_opacity_get()

float blender::draw::gpencil::grease_pencil_layer_final_opacity_get ( const Instance * inst,
const Object * ob,
const GreasePencil & grease_pencil,
const bke::greasepencil::Layer & layer )
static

Definition at line 195 of file gpencil_cache_utils.cc.

Referenced by grease_pencil_layer_cache_add().

◆ grease_pencil_layer_final_tint_and_alpha_get()

float4 blender::draw::gpencil::grease_pencil_layer_final_tint_and_alpha_get ( const Instance * inst,
const GreasePencil & grease_pencil,
const int onion_id,
float * r_alpha )
static

Definition at line 217 of file gpencil_cache_utils.cc.

Referenced by grease_pencil_layer_cache_add().

◆ grease_pencil_layer_random_color_get()

void blender::draw::gpencil::grease_pencil_layer_random_color_get ( const Object * ob,
const bke::greasepencil::Layer & layer,
float r_color[3] )
static

Definition at line 267 of file gpencil_cache_utils.cc.

◆ init_sort_info()

void blender::draw::gpencil::init_sort_info ( struct SortInfo * si,
CompareFn func )
inline

Definition at line 135 of file gpencil_cache_utils.cc.

◆ insert_list()

BLI_INLINE void blender::draw::gpencil::insert_list ( struct SortInfo * si,
list_node * list,
unsigned int rank )

The 'ranks' array essentially captures the recursion stack of a merge-sort. The merge tree is built in a bottom-up manner. The control loop for updating the 'ranks' array is analogous to incrementing a binary integer, and the O(n) time for counting upto n translates to O(n) merges when inserting rank-0 lists. When we plug in the sizes of the lists involved in those merges, we get the O(n log n) time for the sort.

Inserting higher-ranked lists reduce the height of the merge tree, and also eliminate a lot of redundant comparisons when merging two lists that would've been part of the same run. Adding a rank-i list is analogous to incrementing a binary integer by 2**i in one operation, thus sharing a similar speedup.

When inserting higher-ranked lists, we choose to clear out the lower ranks in the interests of keeping the sort stable, but this makes analysis harder. Note that clearing the lower-ranked lists is O(length(list))-- thus it shouldn't affect the O(n log n) behavior. In other words, inserting one rank-i list is equivalent to inserting 2**i rank-0 lists, thus even if we do i additional merges in the clearing-out (taking at most 2**i time) we are still fine. Pre-condition: 2**(rank+1) <= length(list) < 2**(rank+2) (therefore: length(list) >= 2)

Definition at line 223 of file gpencil_cache_utils.cc.

References GreasePencilOnionSkinningSettings::flag, GP_ONION_SKINNING_USE_CUSTOM_COLORS, GP_ONION_SKINNING_USE_FADE, GreasePencil::onion_skinning_settings, and GreasePencilOnionSkinningSettings::opacity.

◆ light_power_get()

float blender::draw::gpencil::light_power_get ( const Light * la)
static

Definition at line 361 of file gpencil_draw_data.cc.

References ELEM, LA_AREA, LA_LOCAL, LA_SPOT, and M_PI.

Referenced by gpencil_light_pool_populate().

◆ list_sort_do()

BLI_INLINE list_node * blender::draw::gpencil::list_sort_do ( list_node * list,
CompareFn func )

◆ merge_lists()

list_node * blender::draw::gpencil::merge_lists ( list_node * first,
list_node * second,
CompareFn func )
inline

Definition at line 153 of file gpencil_cache_utils.cc.

◆ remap_depth()

void blender::draw::gpencil::remap_depth ( const View & view,
MutableSpan< float > pix_z )
static

Definition at line 32 of file gpencil_render.cc.

References clamp_f(), fabsf, and view.

Referenced by render_init_buffers().

◆ render_frame()

void blender::draw::gpencil::render_frame ( RenderEngine * engine,
Depsgraph * depsgraph,
const DRWContext * draw_ctx,
RenderLayer * render_layer,
const rcti rect,
gpencil::Instance & inst,
Manager & manager,
const bool separated_pass )
static

Definition at line 309 of file gpencil_render.cc.

References SceneGpencil::aa_samples, blender::draw::gpencil::Instance::antialiasing_accumulate(), blender::draw::gpencil::Instance::antialiasing_sample_get(), blender::draw::gpencil::Instance::begin_sync(), blender::draw::Manager::begin_sync(), BKE_curvemapping_changed(), BLI_assert, blender::draw::gpencil::Instance::camera, cdf_from_curvemapping(), cdf_invert(), ceil_to_multiple_u(), RenderData::cfra, clamp_f(), CM_TABLE, DEG_get_evaluated(), depsgraph, blender::draw::gpencil::Instance::draw(), DRW_object_visibility_in_active_context(), DRW_render_object_iter(), DRW_render_set_time(), ELEM, blender::draw::gpencil::Instance::end_sync(), blender::draw::Manager::end_sync(), blender::Array< T, InlineBufferCapacity, Allocator >::first(), floorf, fractf, RenderData::gauss, Scene::grease_pencil_settings, i, blender::draw::gpencil::Instance::init(), ViewLayer::layflag, max_ii(), RenderData::mblur_shutter_curve, RenderData::mode, RenderData::motion_blur_position, RenderData::motion_blur_shutter, SceneGpencil::motion_blur_steps, OB_GREASE_PENCIL, OB_LAMP, OB_VISIBLE_SELF, blender::draw::ObjectRef::object, blender::draw::gpencil::Instance::object_sync(), Scene::r, R_MBLUR, RenderEngine::re, RE_engine_frame_set(), RE_GetCamera(), blender::draw::gpencil::Instance::render_color_tx, render_init_buffers(), render_set_view(), SCE_LAY_MOTION_BLUR, DRWContext::scene, shutter_time_to_scene_time(), blender::Array< T, InlineBufferCapacity, Allocator >::size(), blender::draw::Texture::size(), RenderData::subframe, Object::type, and DRWContext::view_layer.

Referenced by blender::draw::gpencil::Engine::render_to_image().

◆ render_init_buffers()

◆ render_result_combined()

◆ render_result_separated_pass()

◆ render_result_z()

◆ render_set_view()

void blender::draw::gpencil::render_set_view ( RenderEngine * engine,
const Depsgraph * depsgraph,
const float2 aa_offset = float2{0.0f} )
static

Definition at line 53 of file gpencil_render.cc.

References depsgraph.

Referenced by render_frame(), and blender::draw::gpencil::Engine::render_to_image().

◆ shutter_time_to_scene_time()

float blender::draw::gpencil::shutter_time_to_scene_time ( const int shutter_position,
const float shutter_time,
const float frame_time,
float time )
static

Definition at line 285 of file gpencil_render.cc.

References BLI_assert_msg, SCE_MB_CENTER, SCE_MB_END, and SCE_MB_START.

Referenced by render_frame().

◆ sweep_up()

BLI_INLINE list_node * blender::draw::gpencil::sweep_up ( struct SortInfo * si,
list_node * list,
unsigned int upto )

Pre-condition: upto <= si->n_ranks, list == NULL || length(list) == 1

Definition at line 184 of file gpencil_cache_utils.cc.