34 PassMain wireframe_ps_ = {
"Wireframe"};
43 } colored, non_colored;
47 bool do_depth_copy_workaround_ =
false;
50 bool show_wire_ =
false;
60 show_wire_ =
state.is_wireframe_mode ||
state.show_wireframes();
62 const bool is_selection = res.is_selection();
65 const float wire_threshold = wire_discard_threshold_get(
state.overlay.wireframe_threshold);
69 depth_tex = &res.dummy_depth_tx;
73 do_depth_copy_workaround_ = !is_selection && (depth_tex == &tmp_depth_tx_);
76 auto &pass = wireframe_ps_;
82 state.clipping_plane_count);
83 res.select_bind(pass);
86 [&](
gpu::Shader *
shader,
const char *name,
bool use_coloring,
float wire_threshold) {
87 auto &sub = pass.sub(name);
88 if (res.shaders->wireframe_mesh.get() ==
shader) {
89 sub.specialize_constant(
shader,
"use_custom_depth_bias", do_smooth_lines);
92 sub.bind_texture(
"depth_tx", depth_tex);
93 sub.push_constant(
"wire_opacity",
state.overlay.wireframe_opacity);
94 sub.push_constant(
"is_transform", is_transform);
95 sub.push_constant(
"color_type",
state.v3d->shading.wire_color_type);
96 sub.push_constant(
"use_coloring", use_coloring);
97 sub.push_constant(
"wire_step_param", wire_threshold);
98 sub.push_constant(
"ndc_offset_factor", &
state.ndc_offset_factor);
99 sub.push_constant(
"is_hair",
false);
103 auto coloring_pass = [&](ColoringPass &ps,
bool use_color) {
105 ps.mesh_ps_ = shader_pass(sh.
wireframe_mesh.
get(),
"Mesh", use_color, wire_threshold);
106 ps.mesh_all_edges_ps_ = shader_pass(sh.
wireframe_mesh.
get(),
"Wire", use_color, 1.0f);
108 ps.pointcloud_ps_ = shader_pass(
114 coloring_pass(non_colored,
false);
115 coloring_pass(colored,
true);
123 const bool in_edit_paint_mode,
124 const bool in_edit_mode)
138 ColoringPass &coloring = in_edit_paint_mode ? non_colored : colored;
142 coloring.curves_ps_->
draw(
148 coloring.curves_ps_->
draw(
154 coloring.curves_ps_->
draw(
162 if (show_surface_wire) {
165 coloring.curves_ps_->
draw(
172 const bool wireframe_no_overlay =
state.hide_overlays &&
state.is_wireframe_mode;
179 const bool edit_wires_overlap_all = mesh_edit_wires_overlap(ob_ref, in_edit_mode);
181 const bool bypass_mode_check = wireframe_no_overlay || !edit_wires_overlap_all;
183 if (show_surface_wire) {
188 coloring.mesh_all_edges_ps_->
draw(batch.batch, handle);
191 else if (!in_edit_mode || bypass_mode_check) {
196 (all_edges ? coloring.mesh_all_edges_ps_ : coloring.mesh_ps_)
202 if (!in_edit_paint_mode || bypass_mode_check) {
205 if ((
mesh.edges_num == 0) && (
mesh.verts_num > 0)) {
207 coloring.points_ps_->
draw(
211 coloring.mesh_all_edges_ps_->
draw(
218 if (show_surface_wire) {
222 if (geom_pointcloud) {
223 coloring.pointcloud_ps_->
draw(
228 coloring.gsplat_ps_->
draw(
235 if (show_surface_wire) {
237 if (geom ==
nullptr) {
243 coloring.points_ps_->
draw(
247 coloring.mesh_all_edges_ps_->
draw(
266 manager.generate_commands(wireframe_ps_, view);
271 if (!
enabled_ || !do_depth_copy_workaround_) {
277 tmp_depth_tx_.acquire_2d(render_size, gpu::TextureFormat::SFLOAT_32_DEPTH_UINT_8, usage);
291 manager.submit_only(wireframe_ps_, view);
293 tmp_depth_tx_.release();
297 float wire_discard_threshold_get(
float threshold)
301 threshold =
sqrt(
abs(threshold));
306 static bool mesh_edit_wires_overlap(
const ObjectRef &ob_ref,
const bool in_edit_mode)
314 if (!edit_mapping_valid) {
ResourceHandleRange unique_handle(const ObjectRef &ref)
int3 size(int miplvl=0) const
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIDRange res_id={}, uint custom_id=0)
detail::PassBase< command::DrawMultiBuf > Sub
static bool mesh_has_edit_cage(const Object *ob)
StaticShader wireframe_points
StaticShader wireframe_gsplat
StaticShader wireframe_points_with_radius
StaticShader wireframe_curve
StaticShader wireframe_mesh
void begin_sync(Resources &res, const State &state) final
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
void pre_draw(Manager &manager, View &view) final
void object_sync_ex(Manager &manager, const ObjectRef &ob_ref, Resources &res, const State &state, const bool in_edit_paint_mode, const bool in_edit_mode)
void copy_depth(TextureRef &depth_tx)
#define DRW_CLIPPING_UBO_SLOT
#define OVERLAY_GLOBALS_SLOT
gpu::Batch * DRW_gsplat_batch_cache_get_dots(Object *ob)
gpu::Batch * DRW_cache_text_edge_wire_get(Object *ob)
gpu::Batch * DRW_cache_mesh_all_verts_get(Object *ob)
gpu::Batch * DRW_cache_grease_pencil_face_wireframe_get(const Scene *scene, Object *ob)
detail::Pass< command::DrawMultiBuf > PassMain
gpu::Batch * DRW_cache_mesh_loose_edges_get(Object *ob)
gpu::Batch * DRW_cache_mesh_face_wireframe_get(Object *ob)
Vector< SculptBatch > sculpt_batches_get(const Object *ob, SculptBatchFeature features)
gpu::Batch * DRW_pointcloud_batch_cache_get_dots(Object *ob)
gpu::Batch * DRW_cache_curve_edge_wire_get(Object *ob)
gpu::Batch * DRW_cache_surf_edge_wire_get(Object *ob)
gpu::Batch * DRW_cache_volume_face_wireframe_get(Object *ob)
gpu::Batch * gsplat_sub_pass_setup(PassMain::Sub &sub_ps, const ObjectRef &ob_ref, const ResourceHandleRange &res_handle, GPUMaterial *gpu_material=nullptr)
T interpolate(const T &a, const T &b, const FactorT &t)
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
const Mesh * BKE_object_get_pre_modified_mesh(const Object *object)
void GPU_texture_copy(gpu::Texture *dst, gpu::Texture *src)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
T & DRW_object_get_data_for_drawing(const Object &object)
@ USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE
@ DRW_STATE_FIRST_VERTEX_CONVENTION
@ DRW_STATE_DEPTH_LESS_EQUAL
bool BKE_editmesh_eval_orig_map_available(const Mesh &mesh_eval, const Mesh *mesh_orig)
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
@ VOLUME_WIREFRAME_POINTS
eObject_DrawExtraFlag dtx
const ID select_id(const ObjectRef &ob_ref, uint sub_object_id=0)