33 PassSimple paint_region_ps_ = {
"paint_region_ps_"};
44 PassSimple paint_mask_ps_ = {
"paint_mask_ps_"};
46 bool show_weight_ =
false;
47 bool show_wires_ =
false;
48 bool show_paint_mask_ =
false;
49 bool masked_transparency_support_ =
false;
55 state.is_space_v3d() && !res.is_selection() &&
59 paint_region_ps_.init();
61 paint_mask_ps_.init();
71 auto &pass = paint_region_ps_;
75 auto &sub = pass.sub(
"Face");
78 state.clipping_plane_count);
79 sub.shader_set(res.shaders->paint_region_face.get());
80 sub.push_constant(
"ucolor",
float4(1.0, 1.0, 1.0, 0.2));
81 paint_region_face_ps_ = ⊂
84 auto &sub = pass.sub(
"Edge");
87 state.clipping_plane_count);
88 sub.shader_set(res.shaders->paint_region_edge.get());
89 paint_region_edge_ps_ = ⊂
92 auto &sub = pass.sub(
"Vert");
94 state.clipping_plane_count);
95 sub.shader_set(res.shaders->paint_region_vert.get());
96 paint_region_vert_ps_ = ⊂
104 masked_transparency_support_ = ((shading_type ==
OB_SOLID) ||
108 const bool shadeless = shading_type ==
OB_WIRE;
111 auto &pass = weight_ps_;
114 auto weight_subpass = [&](
const char *name,
DRWState drw_state) {
115 auto &sub = pass.sub(name);
116 sub.state_set(drw_state,
state.clipping_plane_count);
117 sub.shader_set(shadeless ? res.shaders->paint_weight.get() :
118 res.shaders->paint_weight_fake_shading.get());
119 sub.bind_texture(
"colorramp", &res.weight_ramp_tx);
120 sub.push_constant(
"draw_contours", draw_contours);
121 sub.push_constant(
"opacity",
state.overlay.weight_paint_mode_opacity);
128 weight_opaque_ps_ = weight_subpass(
130 weight_masked_transparency_ps_ = weight_subpass(
131 "Masked Transparency",
137 show_paint_mask_ = paint_settings.
stencil &&
140 if (show_paint_mask_) {
147 auto &pass = paint_mask_ps_;
149 state.clipping_plane_count);
150 pass.shader_set(res.shaders->paint_texture.get());
153 pass.bind_texture(
"mask_image", mask_texture);
154 pass.push_constant(
"maskPremult", mask_premult);
155 pass.push_constant(
"mask_invert_stencil", mask_inverted);
157 pass.push_constant(
"opacity",
state.overlay.texture_paint_mode_opacity);
171 if (ob_ref.object->type !=
OB_MESH) {
176 switch (
state.ctx_mode) {
200 switch (
state.ctx_mode) {
203 if (masked_transparency_support_ && ob_ref.object->dt >=
OB_SOLID) {
204 weight_masked_transparency_ps_->draw(geom, manager.unique_handle(ob_ref));
207 weight_opaque_ps_->draw(geom, manager.unique_handle(ob_ref));
216 if (show_paint_mask_) {
218 paint_mask_ps_.draw(geom, manager.unique_handle(ob_ref));
238 if ((use_face_selection || show_wires_) && !in_texture_paint_mode) {
240 paint_region_edge_ps_->push_constant(
"use_select", use_face_selection);
241 paint_region_edge_ps_->draw(geom, manager.unique_handle(ob_ref));
243 if (use_face_selection) {
245 paint_region_face_ps_->draw(geom, manager.unique_handle(ob_ref));
247 if (use_vert_selection && !in_texture_paint_mode) {
249 paint_region_vert_ps_->draw(geom, manager.unique_handle(ob_ref));
260 manager.submit(weight_ps_, view);
261 manager.submit(paint_mask_ps_, view);
264 manager.submit(paint_region_ps_, view);
#define BLI_assert_unreachable()
void hold_texture(gpu::Texture *texture)
detail::PassBase< command::DrawCommandBuf > Sub
void draw(Framebuffer &framebuffer, Manager &manager, View &view) final
void begin_sync(Resources &res, const State &state) final
void object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &, const State &state) final
#define DRW_CLIPPING_UBO_SLOT
#define OVERLAY_GLOBALS_SLOT
detail::Pass< command::DrawCommandBuf > PassSimple
gpu::Batch * DRW_cache_mesh_paint_overlay_edges_get(Object *ob)
gpu::Batch * DRW_cache_mesh_paint_overlay_verts_get(Object *ob)
gpu::Batch * DRW_cache_mesh_surface_weights_get(Object *ob)
gpu::Batch * DRW_cache_mesh_paint_overlay_surface_get(Object *ob)
gpu::Batch * DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
@ IMAGEPAINT_PROJECT_LAYER_STENCIL_INV
@ IMAGEPAINT_PROJECT_LAYER_STENCIL
T & DRW_object_get_data_for_drawing(const Object &object)
@ V3D_OVERLAY_WPAINT_CONTOURS
@ DRW_STATE_DEPTH_LESS_EQUAL
T * DEG_get_original(T *id)
bool BKE_scene_uses_blender_workbench(const Scene *scene)
draw::Manager * DRW_manager_get()
gpu::Texture * BKE_image_acquire_gpu_texture(Image *image, ImageUser *iuser)