45 const bool is_stroke_order_3d,
51 tgp_ob->
vfx.first = tgp_ob->
vfx.last =
nullptr;
58 for (
int i = 0; i < tot_materials; i++) {
125#define SORT_IMPL_LINKTYPE tObject
127#define SORT_IMPL_FUNC gpencil_tobject_sort_fn_r
131#undef SORT_IMPL_LINKTYPE
173 if (inst->
tobjects.last !=
nullptr) {
199 const bool is_obact = ((inst->
obact) && (inst->
obact == ob));
206 if (is_obact && is_fade) {
213 return layer.opacity;
221 const bool use_onion = (onion_id != 0);
223 const bool use_onion_custom_col = (
grease_pencil.onion_skinning_settings.flag &
225 const bool use_onion_fade = (
grease_pencil.onion_skinning_settings.flag &
227 const bool use_next_col = onion_id > 0;
229 const float onion_factor =
grease_pencil.onion_skinning_settings.opacity;
231 float3 color_next, color_prev;
232 if (use_onion_custom_col) {
241 const float4 onion_col_custom = use_next_col ?
float4(color_next, 1.0f) :
244 *r_alpha = use_onion_fade ? (1.0f /
abs(onion_id)) : 1.0f;
245 *r_alpha *= onion_factor;
246 *r_alpha = (onion_factor > 0.0f) ?
clamp_f(*r_alpha, 0.1f, 1.0f) :
247 clamp_f(*r_alpha, 0.01f, 1.0f);
250 return onion_col_custom;
257 layer_tint[3] = 0.0f;
270 const float hsv_saturation = 0.7f;
271 const float hsv_value = 0.6f;
276 const float hsv[3] = {hue, hsv_saturation, hsv_value};
285 if (skip_onion &&
layer->is_onion) {
288 if (
layer->layer_id == layer_id) {
299 const bool is_used_as_mask,
314 const bool is_viewlayer_render = inst->
is_render && !
layer.view_layer_name().is_empty() &&
316 const bool disable_masks_render = is_viewlayer_render &&
319 bool is_masked = !disable_masks_render &&
layer.use_masks() && !
layer.masks.is_empty();
321 const float vert_col_opacity = (override_vertcol) ?
339 tgp_layer->
is_onion = onion_id != 0;
346 bool valid_mask =
false;
359 if (
node ==
nullptr) {
362 const Layer &mask_layer =
node->as_layer();
363 if ((&mask_layer == &
layer) || !mask_layer.is_visible()) {
381 is_masked = valid_mask;
387 switch (
layer.blend_mode) {
409 if (tgp_layer->
blend_ps ==
nullptr) {
410 tgp_layer->
blend_ps = std::make_unique<PassSimple>(
"GPencil Blend Layer");
437 if (tgp_layer->
geom_ps ==
nullptr) {
438 tgp_layer->
geom_ps = std::make_unique<PassSimple>(
"GPencil Layer");
443 gpu::Texture **depth_tex = (is_in_front) ? &inst->
dummy_depth : &inst->scene_depth_tx;
444 gpu::Texture **mask_tex = (is_masked) ? &inst->
mask_tx : &inst->dummy_tx;
452 pass.state_set(
state);
454 pass.bind_texture(
"gp_scene_depth_tx", depth_tex);
455 pass.bind_texture(
"gp_mask_tx", mask_tex);
457 pass.push_constant(
"gp_stroke_order3d", tgp_ob->
is_drawmode3d);
458 pass.push_constant(
"gp_vertex_color_opacity", vert_col_opacity);
460 pass.bind_texture(
"gp_fill_tx", inst->
dummy_tx);
461 pass.bind_texture(
"gp_stroke_tx", inst->
dummy_tx);
470 pass.push_constant(
"gp_layer_tint", gpl_color);
472 pass.push_constant(
"gp_layer_opacity", layer_alpha);
473 pass.state_stencil(0xFF, 0xFF, 0xFF);
Low-level operations for grease pencil.
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define BLI_BITMAP_SET(_bitmap, _index, _set)
Single link-list utility macros. (header only API).
#define BLI_LINKS_APPEND(list, link)
static ShaderCache & get()
static View & default_get()
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceIDRange res_id={}, uint custom_id=0)
void shader_set(gpu::Shader *shader)
void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state=sampler_auto)
void state_set(DRWState state, int clip_plane_count=0)
void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask)
void push_constant(const char *name, const float &data)
int64_t append_and_get_index(T &&elem)
static ShaderCache & get()
#define GPENCIL_SIMPLIFY_TINT(scene)
float2x2 invert(float2x2 mat)
static void grease_pencil_layer_random_color_get(const Object *ob, const bke::greasepencil::Layer &layer, float r_color[3])
void gpencil_object_cache_sort(Instance *inst)
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 int gpencil_tobject_dist_sort(const void *a, const void *b)
static float grease_pencil_layer_final_opacity_get(const Instance *inst, const Object *ob, const GreasePencil &grease_pencil, const bke::greasepencil::Layer &layer)
tLayer * 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)
tLayer * grease_pencil_layer_cache_get(tObject *tgp_ob, int layer_id, const bool skip_onion)
tObject * gpencil_object_cache_add(Instance *inst, Object *ob, const bool is_stroke_order_3d, const Bounds< float3 > bounds)
detail::Pass< command::DrawCommandBuf > PassSimple
T midpoint(const T &a, const T &b)
void get_color_3fv(int colorid, float col[3])
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ GP_LAYER_TREE_NODE_DISABLE_MASKS_IN_VIEWLAYER
void orthogonalize_m4(float R[4][4], int axis)
int BKE_object_material_used_with_fallback_eval(const Object &ob)
MINLINE void copy_v3_v3(float r[3], const float a[3])
@ GP_ONION_SKINNING_USE_CUSTOM_COLORS
@ GP_ONION_SKINNING_USE_FADE
@ GP_LAYER_BLEND_SUBTRACT
@ GP_LAYER_BLEND_MULTIPLY
@ GP_LAYER_BLEND_HARDLIGHT
MINLINE void add_v3_fl(float r[3], float f)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
bool invert_m4(float mat[4][4])
@ GP_MATERIAL_IS_FILL_HOLDOUT
@ GP_MATERIAL_IS_STROKE_HOLDOUT
BLI_INLINE float BLI_hash_int_01(unsigned int k)
unsigned int BLI_ghashutil_strhash_p_murmur(const void *ptr)
VecBase< float, 4 > float4
MaterialGPencilStyle * BKE_gpencil_material_settings(Object *ob, short act)
void mul_m4_v3(const float M[4][4], float r[3])
T & DRW_object_get_data_for_drawing(const Object &object)
BLI_INLINE void IMB_colormanagement_rec709_to_scene_linear(float scene_linear[3], const float rec709[3])
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
@ OB_MODE_PAINT_GREASE_PENCIL
void unit_m4(float m[4][4])
@ DRW_STATE_BLEND_ADD_FULL
@ DRW_STATE_STENCIL_ALWAYS
@ DRW_STATE_BLEND_ALPHA_PREMUL
@ DRW_STATE_WRITE_STENCIL
@ DRW_STATE_STENCIL_EQUAL
@ DRW_STATE_DEPTH_LESS_EQUAL
@ DRW_STATE_DEPTH_GREATER
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
@ V3D_SHADING_RANDOM_COLOR
@ V3D_SHADING_VERTEX_COLOR
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
MINLINE float normalize_v3(float n[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void transpose_m4(float R[4][4])
void * BLI_memblock_alloc(BLI_memblock *mblk) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits)
void rescale_m4(float mat[4][4], const float scale[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
VecBase< float, 3 > float3
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float clamp_f(float value, float min, float max)
eMaterialGPencilStyle_Flag flag
eObject_DrawExtraFlag dtx
struct BLI_memblock * gp_object_pool
tLayer_Pool * gp_layer_pool
float vertex_paint_opacity
struct blender::draw::gpencil::Instance::@250045130013031054234100054276160145124267353263 tobjects_infront
struct ViewLayer * view_layer
float fade_gp_object_opacity
TextureFromPool color_layer_tx
TextureFromPool reveal_layer_tx
struct blender::draw::gpencil::Instance::@250045130013031054234100054276160145124267353263 tobjects
struct BLI_memblock * gp_maskbit_pool
::std::unique_ptr< PassSimple > blend_ps
::std::unique_ptr< PassSimple > geom_ps
BLI_bitmap * mask_invert_bits
struct blender::draw::gpencil::tObject::@156157250037170237043104125276354377130037130163 layers
struct blender::draw::gpencil::tObject::@332241055010322366143177356242222270031034105156 vfx