46 const bool is_stroke_order_3d,
59 for (
int i = 0;
i < tot_materials;
i++) {
126#define SORT_IMPL_LINKTYPE tObject
128#define SORT_IMPL_FUNC gpencil_tobject_sort_fn_r
132#undef SORT_IMPL_LINKTYPE
136 const tObject *ob_a = (
const tObject *)a;
137 const tObject *ob_b = (
const tObject *)
b;
139 if (ob_a->camera_z > ob_b->camera_z) {
142 if (ob_a->camera_z < ob_b->camera_z) {
198 const bke::greasepencil::Layer &layer)
200 const bool is_obact = ((inst->
obact) && (inst->
obact == ob));
202 !grease_pencil.is_layer_active(&layer);
207 if (is_obact && is_fade) {
214 return layer.opacity;
222 const bool use_onion = (onion_id != 0);
228 const bool use_next_col = onion_id > 0;
233 if (use_onion_custom_col) {
242 const float4 onion_col_custom = use_next_col ?
float4(color_next, 1.0f) :
245 *r_alpha = use_onion_fade ? (1.0f /
abs(onion_id)) : 0.5f;
246 *r_alpha *= onion_factor;
247 *r_alpha = (onion_factor > 0.0f) ?
clamp_f(*r_alpha, 0.1f, 1.0f) :
248 clamp_f(*r_alpha, 0.01f, 1.0f);
251 return onion_col_custom;
258 layer_tint[3] = 0.0f;
271 const float hsv_saturation = 0.7f;
272 const float hsv_value = 0.6f;
277 const float hsv[3] = {hue, hsv_saturation, hsv_value};
286 if (skip_onion && layer->is_onion) {
289 if (layer->layer_id == layer_id) {
300 const bool is_used_as_mask,
317 const bool disable_masks_render = is_viewlayer_render &&
320 bool is_masked = !disable_masks_render && layer.use_masks() &&
323 const float vert_col_opacity = (override_vertcol) ?
329 inst, ob, grease_pencil, layer) :
334 inst, grease_pencil, onion_id, &layer_alpha);
340 tgp_layer->
layer_id = *grease_pencil.get_layer_index(layer);
341 tgp_layer->
is_onion = onion_id != 0;
348 bool valid_mask =
false;
360 const TreeNode *node = grease_pencil.find_node_by_name(
mask->layer_name);
361 if (node ==
nullptr) {
365 if ((&mask_layer == &layer) || !mask_layer.is_visible()) {
368 const int index = *grease_pencil.get_layer_index(mask_layer);
383 is_masked = valid_mask;
411 if (tgp_layer->
blend_ps ==
nullptr) {
412 tgp_layer->
blend_ps = std::make_unique<PassSimple>(
"GPencil Blend Layer");
416 pass.state_set(
state);
418 pass.push_constant(
"blend_mode",
int(layer.
blend_mode));
419 pass.push_constant(
"blend_opacity", layer_opacity);
422 pass.bind_texture(
"mask_buf", (is_masked) ? &inst->
mask_tx : &inst->
dummy_tx);
423 pass.state_stencil(0xFF, 0xFF, 0xFF);
430 pass.push_constant(
"blend_mode", 999);
439 if (tgp_layer->
geom_ps ==
nullptr) {
440 tgp_layer->
geom_ps = std::make_unique<PassSimple>(
"GPencil Layer");
445 gpu::Texture **depth_tex = (is_in_front) ? &inst->
dummy_depth : &inst->scene_depth_tx;
446 gpu::Texture **mask_tex = (is_masked) ? &inst->
mask_tx : &inst->dummy_tx;
454 pass.state_set(
state);
456 pass.bind_texture(
"gp_scene_depth_tx", depth_tex);
457 pass.bind_texture(
"gp_mask_tx", mask_tex);
459 pass.push_constant(
"gp_stroke_order3d", tgp_ob->
is_drawmode3d);
460 pass.push_constant(
"gp_vertex_color_opacity", vert_col_opacity);
462 pass.bind_texture(
"gp_fill_tx", inst->
dummy_tx);
463 pass.bind_texture(
"gp_stroke_tx", inst->
dummy_tx);
472 pass.push_constant(
"gp_layer_tint", gpl_color);
474 pass.push_constant(
"gp_layer_opacity", layer_alpha);
475 pass.state_stencil(0xFF, 0xFF, 0xFF);
#define GPENCIL_SIMPLIFY_TINT(scene)
Low-level operations for grease pencil.
General operations, lookup, etc. for materials.
MaterialGPencilStyle * BKE_gpencil_material_settings(Object *ob, short act)
int BKE_object_material_used_with_fallback_eval(const Object &ob)
General operations, lookup, etc. for blender objects.
void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits)
#define BLI_BITMAP_SET(_bitmap, _index, _set)
unsigned int BLI_ghashutil_strhash_p_murmur(const void *ptr)
BLI_INLINE float BLI_hash_int_01(unsigned int k)
Single link-list utility macros. (header only API).
#define BLI_LINKS_APPEND(list, link)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
MINLINE float clamp_f(float value, float min, float max)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
void orthogonalize_m4(float R[4][4], int axis)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void rescale_m4(float mat[4][4], const float scale[3])
void mul_m4_v3(const float M[4][4], float r[3])
bool invert_m4(float mat[4][4])
void transpose_m4(float R[4][4])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void unit_m4(float m[4][4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void add_v3_fl(float r[3], float f)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
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
MINLINE float normalize_v3(float n[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void * BLI_memblock_alloc(BLI_memblock *mblk) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
@ GP_LAYER_BLEND_HARDLIGHT
@ GP_LAYER_BLEND_MULTIPLY
@ GP_LAYER_BLEND_SUBTRACT
@ GP_LAYER_TREE_NODE_DISABLE_MASKS_IN_VIEWLAYER
@ GP_ONION_SKINNING_USE_FADE
@ GP_ONION_SKINNING_USE_CUSTOM_COLORS
@ GP_MATERIAL_IS_STROKE_HOLDOUT
@ GP_MATERIAL_IS_FILL_HOLDOUT
@ OB_MODE_PAINT_GREASE_PENCIL
@ V3D_SHADING_VERTEX_COLOR
@ V3D_SHADING_RANDOM_COLOR
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 UI_GetThemeColor3fv(int colorid, float col[3])
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
const Layer & as_layer() const
constexpr bool is_empty() const
constexpr const char * c_str() const
StringRefNull view_layer_name() const
static View & default_get()
int64_t append_and_get_index(T &&elem)
static ShaderCache & get()
@ DRW_STATE_STENCIL_EQUAL
@ DRW_STATE_STENCIL_ALWAYS
@ DRW_STATE_BLEND_ADD_FULL
@ DRW_STATE_DEPTH_LESS_EQUAL
@ DRW_STATE_BLEND_ALPHA_PREMUL
@ DRW_STATE_DEPTH_GREATER
@ DRW_STATE_WRITE_STENCIL
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
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
CartesianBasis invert(const CartesianBasis &basis)
T midpoint(const T &a, const T &b)
VecBase< float, 4 > float4
VecBase< float, 3 > float3
GreasePencilLayerTreeNode base
GreasePencilOnionSkinningSettings onion_skinning_settings
struct BLI_memblock * gp_object_pool
tLayer_Pool * gp_layer_pool
float vertex_paint_opacity
struct ViewLayer * view_layer
struct blender::draw::gpencil::Instance::@236154265015220156065132174366266070164251065066 tobjects
float fade_gp_object_opacity
TextureFromPool color_layer_tx
struct blender::draw::gpencil::Instance::@236154265015220156065132174366266070164251065066 tobjects_infront
TextureFromPool reveal_layer_tx
struct BLI_memblock * gp_maskbit_pool
std::unique_ptr< PassSimple > geom_ps
BLI_bitmap * mask_invert_bits
std::unique_ptr< PassSimple > blend_ps
struct blender::draw::gpencil::tObject::@205301145252027033255155341114207373222070270161 layers
struct blender::draw::gpencil::tObject::@173025115035047336003051253055014360144006015207 vfx