Overlay: Avoid engine recreation for clipping region toggle
This changes the shader module reference to a pointer and set it during `init()`
This commit is contained in:
@@ -69,7 +69,7 @@ class AntiAliasing : Overlay {
|
||||
pass.init();
|
||||
pass.framebuffer_set(&framebuffer_ref_);
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL);
|
||||
pass.shader_set(res.shaders.anti_aliasing.get());
|
||||
pass.shader_set(res.shaders->anti_aliasing.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.bind_texture("depthTex", &res.depth_tx);
|
||||
|
||||
@@ -174,7 +174,7 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.envelope_distance");
|
||||
sub.state_set(transparent_state | DRW_STATE_CULL_FRONT, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_envelope_fill.get());
|
||||
sub.shader_set(res.shaders->armature_envelope_fill.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
sub.push_constant("isDistance", true);
|
||||
opaque_.envelope_distance = ⊂
|
||||
@@ -182,7 +182,7 @@ class Armatures : Overlay {
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.envelope_distance");
|
||||
sub.state_set(transparent_state | DRW_STATE_CULL_FRONT, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_envelope_fill.get());
|
||||
sub.shader_set(res.shaders->armature_envelope_fill.get());
|
||||
sub.push_constant("alpha", wire_alpha);
|
||||
sub.push_constant("isDistance", true);
|
||||
transparent_.envelope_distance = ⊂
|
||||
@@ -194,14 +194,14 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.degrees_of_freedom_fill");
|
||||
sub.state_set(transparent_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_degrees_of_freedom.get());
|
||||
sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.degrees_of_freedom_fill = ⊂
|
||||
}
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.degrees_of_freedom_fill");
|
||||
sub.state_set(transparent_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_degrees_of_freedom.get());
|
||||
sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
|
||||
sub.push_constant("alpha", wire_alpha);
|
||||
transparent_.degrees_of_freedom_fill = ⊂
|
||||
}
|
||||
@@ -218,7 +218,7 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.sphere_fill");
|
||||
sub.state_set(default_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_sphere_fill.get());
|
||||
sub.shader_set(res.shaders->armature_sphere_fill.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.sphere_fill = ⊂
|
||||
}
|
||||
@@ -226,7 +226,7 @@ class Armatures : Overlay {
|
||||
auto &sub = armature_ps_.sub("transparent.sphere_fill");
|
||||
sub.state_set((default_state & ~DRW_STATE_WRITE_DEPTH) | DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_sphere_fill.get());
|
||||
sub.shader_set(res.shaders->armature_sphere_fill.get());
|
||||
sub.push_constant("alpha", wire_alpha * 0.4f);
|
||||
transparent_.sphere_fill = ⊂
|
||||
}
|
||||
@@ -234,7 +234,7 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.shape_fill");
|
||||
sub.state_set(default_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_shape_fill.get());
|
||||
sub.shader_set(res.shaders->armature_shape_fill.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.shape_fill = ⊂
|
||||
}
|
||||
@@ -242,7 +242,7 @@ class Armatures : Overlay {
|
||||
auto &sub = armature_ps_.sub("transparent.shape_fill");
|
||||
sub.state_set((default_state & ~DRW_STATE_WRITE_DEPTH) | DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_shape_fill.get());
|
||||
sub.shader_set(res.shaders->armature_shape_fill.get());
|
||||
sub.push_constant("alpha", wire_alpha * 0.6f);
|
||||
transparent_.shape_fill = ⊂
|
||||
}
|
||||
@@ -250,14 +250,14 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.sphere_outline");
|
||||
sub.state_set(default_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_sphere_outline.get());
|
||||
sub.shader_set(res.shaders->armature_sphere_outline.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.sphere_outline = ⊂
|
||||
}
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.sphere_outline");
|
||||
sub.state_set(default_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_sphere_outline.get());
|
||||
sub.shader_set(res.shaders->armature_sphere_outline.get());
|
||||
sub.push_constant("alpha", wire_alpha);
|
||||
transparent_.sphere_outline = ⊂
|
||||
}
|
||||
@@ -268,14 +268,14 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.shape_outline");
|
||||
sub.state_set(default_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_shape_outline.get());
|
||||
sub.shader_set(res.shaders->armature_shape_outline.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.shape_outline = ⊂
|
||||
}
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.shape_outline");
|
||||
sub.state_set(default_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_shape_outline.get());
|
||||
sub.shader_set(res.shaders->armature_shape_outline.get());
|
||||
sub.bind_texture("depthTex", depth_tex);
|
||||
sub.push_constant("alpha", wire_alpha * 0.6f);
|
||||
sub.push_constant("do_smooth_wire", do_smooth_wire);
|
||||
@@ -288,7 +288,7 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.shape_wire");
|
||||
sub.state_set(default_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_shape_wire.get());
|
||||
sub.shader_set(res.shaders->armature_shape_wire.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
sub.push_constant("do_smooth_wire", do_smooth_wire);
|
||||
sub.push_constant("use_arrow_drawing", false);
|
||||
@@ -297,7 +297,7 @@ class Armatures : Overlay {
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.shape_wire");
|
||||
sub.state_set(default_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_shape_wire.get());
|
||||
sub.shader_set(res.shaders->armature_shape_wire.get());
|
||||
sub.bind_texture("depthTex", depth_tex);
|
||||
sub.push_constant("alpha", wire_alpha * 0.6f);
|
||||
sub.push_constant("do_smooth_wire", do_smooth_wire);
|
||||
@@ -311,7 +311,7 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.shape_wire_strip");
|
||||
sub.state_set(default_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_shape_wire_strip.get());
|
||||
sub.shader_set(res.shaders->armature_shape_wire_strip.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
sub.push_constant("do_smooth_wire", do_smooth_wire);
|
||||
sub.push_constant("use_arrow_drawing", false);
|
||||
@@ -320,7 +320,7 @@ class Armatures : Overlay {
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.shape_wire_strip");
|
||||
sub.state_set(default_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_shape_wire_strip.get());
|
||||
sub.shader_set(res.shaders->armature_shape_wire_strip.get());
|
||||
sub.bind_texture("depthTex", depth_tex);
|
||||
sub.push_constant("alpha", wire_alpha * 0.6f);
|
||||
sub.push_constant("do_smooth_wire", do_smooth_wire);
|
||||
@@ -335,13 +335,13 @@ class Armatures : Overlay {
|
||||
{
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.degrees_of_freedom_wire");
|
||||
sub.shader_set(res.shaders.armature_degrees_of_freedom.get());
|
||||
sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.degrees_of_freedom_wire = ⊂
|
||||
}
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.degrees_of_freedom_wire");
|
||||
sub.shader_set(res.shaders.armature_degrees_of_freedom.get());
|
||||
sub.shader_set(res.shaders->armature_degrees_of_freedom.get());
|
||||
sub.push_constant("alpha", wire_alpha);
|
||||
transparent_.degrees_of_freedom_wire = ⊂
|
||||
}
|
||||
@@ -353,14 +353,14 @@ class Armatures : Overlay {
|
||||
{
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.stick");
|
||||
sub.shader_set(res.shaders.armature_stick.get());
|
||||
sub.shader_set(res.shaders->armature_stick.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.stick = ⊂
|
||||
}
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.stick");
|
||||
sub.state_set(default_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_stick.get());
|
||||
sub.shader_set(res.shaders->armature_stick.get());
|
||||
sub.push_constant("alpha", wire_alpha);
|
||||
transparent_.stick = ⊂
|
||||
}
|
||||
@@ -373,7 +373,7 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.envelope_fill");
|
||||
sub.state_set(default_state | DRW_STATE_CULL_BACK, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_envelope_fill.get());
|
||||
sub.shader_set(res.shaders->armature_envelope_fill.get());
|
||||
sub.push_constant("isDistance", false);
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.envelope_fill = ⊂
|
||||
@@ -383,7 +383,7 @@ class Armatures : Overlay {
|
||||
sub.state_set((default_state & ~DRW_STATE_WRITE_DEPTH) |
|
||||
(DRW_STATE_BLEND_ALPHA | DRW_STATE_CULL_BACK),
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_envelope_fill.get());
|
||||
sub.shader_set(res.shaders->armature_envelope_fill.get());
|
||||
sub.push_constant("alpha", wire_alpha * 0.6f);
|
||||
transparent_.envelope_fill = ⊂
|
||||
}
|
||||
@@ -391,7 +391,7 @@ class Armatures : Overlay {
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.envelope_outline");
|
||||
sub.state_set(default_state | DRW_STATE_CULL_BACK, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_envelope_outline.get());
|
||||
sub.shader_set(res.shaders->armature_envelope_outline.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.envelope_outline = ⊂
|
||||
}
|
||||
@@ -400,7 +400,7 @@ class Armatures : Overlay {
|
||||
sub.state_set((default_state & ~DRW_STATE_WRITE_DEPTH) |
|
||||
(DRW_STATE_BLEND_ALPHA | DRW_STATE_CULL_BACK),
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_envelope_outline.get());
|
||||
sub.shader_set(res.shaders->armature_envelope_outline.get());
|
||||
sub.push_constant("alpha", wire_alpha);
|
||||
transparent_.envelope_outline = ⊂
|
||||
}
|
||||
@@ -411,14 +411,14 @@ class Armatures : Overlay {
|
||||
{
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.wire");
|
||||
sub.shader_set(res.shaders.armature_wire.get());
|
||||
sub.shader_set(res.shaders->armature_wire.get());
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
opaque_.wire = ⊂
|
||||
}
|
||||
if (use_wire_alpha) {
|
||||
auto &sub = armature_ps_.sub("transparent.wire");
|
||||
sub.state_set(default_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.armature_wire.get());
|
||||
sub.shader_set(res.shaders->armature_wire.get());
|
||||
sub.push_constant("alpha", wire_alpha);
|
||||
transparent_.wire = ⊂
|
||||
}
|
||||
@@ -429,14 +429,14 @@ class Armatures : Overlay {
|
||||
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.arrow");
|
||||
sub.shader_set(res.shaders.extra_shape.get());
|
||||
sub.shader_set(res.shaders->extra_shape.get());
|
||||
opaque_.arrows = ⊂
|
||||
transparent_.arrows = opaque_.arrows;
|
||||
}
|
||||
|
||||
{
|
||||
auto &sub = armature_ps_.sub("opaque.relations");
|
||||
sub.shader_set(res.shaders.extra_wire.get());
|
||||
sub.shader_set(res.shaders->extra_wire.get());
|
||||
opaque_.relations = ⊂
|
||||
transparent_.relations = opaque_.relations;
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ class AttributeViewer : Overlay {
|
||||
return ⊂
|
||||
};
|
||||
|
||||
mesh_sub_ = create_sub("mesh", res.shaders.attribute_viewer_mesh.get());
|
||||
pointcloud_sub_ = create_sub("pointcloud", res.shaders.attribute_viewer_pointcloud.get());
|
||||
curve_sub_ = create_sub("curve", res.shaders.attribute_viewer_curve.get());
|
||||
curves_sub_ = create_sub("curves", res.shaders.attribute_viewer_curves.get());
|
||||
instance_sub_ = create_sub("instance", res.shaders.uniform_color.get());
|
||||
mesh_sub_ = create_sub("mesh", res.shaders->attribute_viewer_mesh.get());
|
||||
pointcloud_sub_ = create_sub("pointcloud", res.shaders->attribute_viewer_pointcloud.get());
|
||||
curve_sub_ = create_sub("curve", res.shaders->attribute_viewer_curve.get());
|
||||
curves_sub_ = create_sub("curves", res.shaders->attribute_viewer_curves.get());
|
||||
instance_sub_ = create_sub("instance", res.shaders->uniform_color.get());
|
||||
}
|
||||
|
||||
void object_sync(Manager &manager,
|
||||
|
||||
@@ -82,7 +82,7 @@ class Axes : Overlay {
|
||||
}
|
||||
DRWState state_common = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH;
|
||||
ps_.state_set(state_common | DRW_STATE_DEPTH_LESS_EQUAL, state.clipping_plane_count);
|
||||
ps_.shader_set(res.shaders.extra_shape.get());
|
||||
ps_.shader_set(res.shaders->extra_shape.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
res.select_bind(ps_);
|
||||
|
||||
@@ -82,14 +82,14 @@ class Background : Overlay {
|
||||
Span<float3> bbox(reinterpret_cast<float3 *>(state.rv3d->clipbb->vec[0]), 8);
|
||||
|
||||
bg_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA | DRW_STATE_CULL_BACK);
|
||||
bg_ps_.shader_set(res.shaders.background_clip_bound.get());
|
||||
bg_ps_.shader_set(res.shaders->background_clip_bound.get());
|
||||
bg_ps_.push_constant("ucolor", res.theme_settings.color_clipping_border);
|
||||
bg_ps_.push_constant("boundbox", bbox.data(), 8);
|
||||
bg_ps_.draw(res.shapes.cube_solid.get());
|
||||
}
|
||||
|
||||
bg_ps_.state_set(pass_state);
|
||||
bg_ps_.shader_set(res.shaders.background_fill.get());
|
||||
bg_ps_.shader_set(res.shaders->background_fill.get());
|
||||
bg_ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
bg_ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
bg_ps_.bind_texture("colorBuffer", &res.color_render_tx);
|
||||
|
||||
@@ -204,7 +204,7 @@ class Bounds : Overlay {
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
ps_.shader_set(res.shaders.extra_shape.get());
|
||||
ps_.shader_set(res.shaders->extra_shape.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
res.select_bind(ps_);
|
||||
|
||||
@@ -122,7 +122,7 @@ class Cameras : Overlay {
|
||||
auto init_pass = [&](PassMain &pass, DRWState draw_state) {
|
||||
pass.init();
|
||||
pass.state_set(draw_state, state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.image_plane_depth_bias.get());
|
||||
pass.shader_set(res.shaders->image_plane_depth_bias.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.push_constant("depth_bias_winmat", &depth_bias_winmat_);
|
||||
@@ -176,7 +176,7 @@ class Cameras : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
sub_pass.shader_set(res.shaders->extra_shape.get());
|
||||
call_buffers_.volume_buf.end_sync(sub_pass, res.shapes.camera_volume.get());
|
||||
}
|
||||
{
|
||||
@@ -184,7 +184,7 @@ class Cameras : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
sub_pass.shader_set(res.shaders->extra_shape.get());
|
||||
call_buffers_.volume_wire_buf.end_sync(sub_pass, res.shapes.camera_volume_wire.get());
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class Cameras : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
sub_pass.shader_set(res.shaders->extra_shape.get());
|
||||
call_buffers_.distances_buf.end_sync(sub_pass, res.shapes.camera_distances.get());
|
||||
call_buffers_.frame_buf.end_sync(sub_pass, res.shapes.camera_frame.get());
|
||||
call_buffers_.tria_buf.end_sync(sub_pass, res.shapes.camera_tria.get());
|
||||
@@ -206,7 +206,7 @@ class Cameras : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_wire.get());
|
||||
sub_pass.shader_set(res.shaders->extra_wire.get());
|
||||
call_buffers_.stereo_connect_lines.end_sync(sub_pass);
|
||||
call_buffers_.tracking_path.end_sync(sub_pass);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class Curves : Overlay {
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.curve_edit_line.get());
|
||||
sub.shader_set(res.shaders->curve_edit_line.get());
|
||||
sub.bind_texture("weightTex", &res.weight_ramp_tx);
|
||||
sub.push_constant("useWeight", false);
|
||||
sub.push_constant("useGreasePencil", false);
|
||||
@@ -77,7 +77,7 @@ class Curves : Overlay {
|
||||
{
|
||||
auto &sub = pass.sub("Handles");
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.curve_edit_handles.get());
|
||||
sub.shader_set(res.shaders->curve_edit_handles.get());
|
||||
sub.push_constant("curveHandleDisplay", int(state.overlay.handle_display));
|
||||
edit_curves_handles_ = ⊂
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class Curves : Overlay {
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.curve_edit_points.get());
|
||||
sub.shader_set(res.shaders->curve_edit_points.get());
|
||||
sub.bind_texture("weightTex", &res.weight_ramp_tx);
|
||||
sub.push_constant("useWeight", false);
|
||||
sub.push_constant("useGreasePencil", false);
|
||||
@@ -109,7 +109,7 @@ class Curves : Overlay {
|
||||
auto &sub = pass.sub("Wires");
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.legacy_curve_edit_wires.get());
|
||||
sub.shader_set(res.shaders->legacy_curve_edit_wires.get());
|
||||
sub.push_constant("normalSize", 0.0f);
|
||||
edit_legacy_curve_wires_ = ⊂
|
||||
}
|
||||
@@ -117,7 +117,7 @@ class Curves : Overlay {
|
||||
auto &sub = pass.sub("Normals");
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.legacy_curve_edit_normals.get());
|
||||
sub.shader_set(res.shaders->legacy_curve_edit_normals.get());
|
||||
sub.push_constant("normalSize", state.overlay.normals_length);
|
||||
sub.push_constant("use_hq_normals", use_hq_normals);
|
||||
edit_legacy_curve_normals_ = ⊂
|
||||
@@ -128,7 +128,7 @@ class Curves : Overlay {
|
||||
{
|
||||
auto &sub = pass.sub("Handles");
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.legacy_curve_edit_handles.get());
|
||||
sub.shader_set(res.shaders->legacy_curve_edit_handles.get());
|
||||
sub.push_constant("showCurveHandles", state.overlay.handle_display != CURVE_HANDLE_NONE);
|
||||
sub.push_constant("curveHandleDisplay", int(state.overlay.handle_display));
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
@@ -138,7 +138,7 @@ class Curves : Overlay {
|
||||
{
|
||||
auto &sub = pass.sub("Points");
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.legacy_curve_edit_points.get());
|
||||
sub.shader_set(res.shaders->legacy_curve_edit_points.get());
|
||||
sub.push_constant("showCurveHandles", state.overlay.handle_display != CURVE_HANDLE_NONE);
|
||||
sub.push_constant("curveHandleDisplay", int(state.overlay.handle_display));
|
||||
sub.push_constant("useGreasePencil", false);
|
||||
@@ -156,7 +156,7 @@ class Curves : Overlay {
|
||||
auto create_sub = [&](const char *name, DRWState drw_state, float alpha) {
|
||||
auto &sub = pass.sub(name);
|
||||
sub.state_set(drw_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.legacy_curve_edit_handles.get());
|
||||
sub.shader_set(res.shaders->legacy_curve_edit_handles.get());
|
||||
sub.push_constant("showCurveHandles", state.overlay.handle_display != CURVE_HANDLE_NONE);
|
||||
sub.push_constant("curveHandleDisplay", int(state.overlay.handle_display));
|
||||
sub.push_constant("alpha", alpha);
|
||||
|
||||
@@ -59,7 +59,7 @@ class EditText : Overlay {
|
||||
{
|
||||
auto &sub = ps_.sub("text_selection");
|
||||
sub.state_set(default_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.uniform_color.get());
|
||||
sub.shader_set(res.shaders->uniform_color.get());
|
||||
UI_GetThemeColor4fv(TH_WIDGET_TEXT_SELECTION, color);
|
||||
srgb_to_linearrgb_v4(color, color);
|
||||
sub.push_constant("ucolor", color);
|
||||
@@ -72,7 +72,7 @@ class EditText : Overlay {
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_DEPTH_GREATER_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.uniform_color.get());
|
||||
sub.shader_set(res.shaders->uniform_color.get());
|
||||
UI_GetThemeColor4fv(TH_WIDGET_TEXT_HIGHLIGHT, color);
|
||||
srgb_to_linearrgb_v4(color, color);
|
||||
sub.push_constant("ucolor", color);
|
||||
@@ -83,7 +83,7 @@ class EditText : Overlay {
|
||||
{
|
||||
auto &sub = ps_.sub("text_cursor");
|
||||
sub.state_set(default_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.uniform_color.get());
|
||||
sub.shader_set(res.shaders->uniform_color.get());
|
||||
sub.state_set(default_state, state.clipping_plane_count);
|
||||
UI_GetThemeColor4fv(TH_WIDGET_TEXT_CURSOR, color);
|
||||
srgb_to_linearrgb_v4(color, color);
|
||||
@@ -120,7 +120,7 @@ class EditText : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_wire.get());
|
||||
sub_pass.shader_set(res.shaders->extra_wire.get());
|
||||
box_line_buf_.end_sync(sub_pass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class Empties : Overlay {
|
||||
auto init_pass = [&](PassMain &pass, DRWState draw_state) {
|
||||
pass.init();
|
||||
pass.state_set(draw_state, state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.image_plane_depth_bias.get());
|
||||
pass.shader_set(res.shaders->image_plane_depth_bias.get());
|
||||
pass.push_constant("depth_bias_winmat", &depth_bias_winmat_);
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
@@ -184,7 +184,7 @@ class Empties : Overlay {
|
||||
{
|
||||
ps.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
ps.shader_set(res.shaders.extra_shape.get());
|
||||
ps.shader_set(res.shaders->extra_shape.get());
|
||||
ps.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
|
||||
@@ -360,11 +360,11 @@ class Empties : Overlay {
|
||||
const float z = -math::dot(state.camera_forward, tmp);
|
||||
PassMain::Sub &sub = parent.sub("Sub", z);
|
||||
if (depth_bias) {
|
||||
sub.shader_set(res.shaders.image_plane_depth_bias.get());
|
||||
sub.shader_set(res.shaders->image_plane_depth_bias.get());
|
||||
sub.push_constant("depth_bias_winmat", &depth_bias_winmat_);
|
||||
}
|
||||
else {
|
||||
sub.shader_set(res.shaders.image_plane.get());
|
||||
sub.shader_set(res.shaders->image_plane.get());
|
||||
}
|
||||
sub.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
sub.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
|
||||
@@ -31,23 +31,9 @@ static void OVERLAY_next_engine_init(void *vedata)
|
||||
{
|
||||
OVERLAY_Data *ved = reinterpret_cast<OVERLAY_Data *>(vedata);
|
||||
|
||||
const DRWContext *draw_ctx = DRW_context_get();
|
||||
const RegionView3D *rv3d = draw_ctx->rv3d;
|
||||
const View3D *v3d = draw_ctx->v3d;
|
||||
const bool clipping_enabled = RV3D_CLIPPING_ENABLED(v3d, rv3d);
|
||||
|
||||
/* WORKAROUND: Restart the engine when clipping is being toggled. */
|
||||
if (ved->instance != nullptr &&
|
||||
reinterpret_cast<Instance *>(ved->instance)->clipping_enabled() != clipping_enabled)
|
||||
{
|
||||
delete reinterpret_cast<Instance *>(ved->instance);
|
||||
ved->instance = nullptr;
|
||||
}
|
||||
|
||||
if (ved->instance == nullptr) {
|
||||
ved->instance = new Instance(select::SelectionType::DISABLED, clipping_enabled);
|
||||
ved->instance = new Instance(select::SelectionType::DISABLED);
|
||||
}
|
||||
|
||||
reinterpret_cast<Instance *>(ved->instance)->init();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class Facing : Overlay {
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | depth_compare_state |
|
||||
backface_cull_state,
|
||||
state.clipping_plane_count);
|
||||
ps_.shader_set(res.shaders.facing.get());
|
||||
ps_.shader_set(res.shaders->facing.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class Fade : Overlay {
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
ps_.shader_set(res.shaders.uniform_color.get());
|
||||
ps_.shader_set(res.shaders->uniform_color.get());
|
||||
{
|
||||
PassMain::Sub &sub = ps_.sub("edit_mesh.fade");
|
||||
float4 color = res.background_color_get(state);
|
||||
|
||||
@@ -55,22 +55,22 @@ class Fluids : Overlay {
|
||||
/* TODO(fclem): Use either specialization constants or push constants to reduce the amount of
|
||||
* shader variants. */
|
||||
velocity_needle_ps_ = &fluid_ps_.sub("Velocity Needles");
|
||||
velocity_needle_ps_->shader_set(res.shaders.fluid_velocity_needle.get());
|
||||
velocity_needle_ps_->shader_set(res.shaders->fluid_velocity_needle.get());
|
||||
|
||||
velocity_mac_ps_ = &fluid_ps_.sub("Velocity Mac");
|
||||
velocity_mac_ps_->shader_set(res.shaders.fluid_velocity_mac.get());
|
||||
velocity_mac_ps_->shader_set(res.shaders->fluid_velocity_mac.get());
|
||||
|
||||
velocity_streamline_ps_ = &fluid_ps_.sub("Velocity Line");
|
||||
velocity_streamline_ps_->shader_set(res.shaders.fluid_velocity_streamline.get());
|
||||
velocity_streamline_ps_->shader_set(res.shaders->fluid_velocity_streamline.get());
|
||||
|
||||
grid_lines_flags_ps_ = &fluid_ps_.sub("Velocity Mac");
|
||||
grid_lines_flags_ps_->shader_set(res.shaders.fluid_grid_lines_flags.get());
|
||||
grid_lines_flags_ps_->shader_set(res.shaders->fluid_grid_lines_flags.get());
|
||||
|
||||
grid_lines_flat_ps_ = &fluid_ps_.sub("Velocity Needles");
|
||||
grid_lines_flat_ps_->shader_set(res.shaders.fluid_grid_lines_flat.get());
|
||||
grid_lines_flat_ps_->shader_set(res.shaders->fluid_grid_lines_flat.get());
|
||||
|
||||
grid_lines_range_ps_ = &fluid_ps_.sub("Velocity Line");
|
||||
grid_lines_range_ps_->shader_set(res.shaders.fluid_grid_lines_range.get());
|
||||
grid_lines_range_ps_->shader_set(res.shaders->fluid_grid_lines_range.get());
|
||||
}
|
||||
|
||||
cube_buf_.clear();
|
||||
@@ -235,7 +235,7 @@ class Fluids : Overlay {
|
||||
|
||||
void end_sync(Resources &res, const State & /*state*/) final
|
||||
{
|
||||
fluid_ps_.shader_set(res.shaders.extra_shape.get());
|
||||
fluid_ps_.shader_set(res.shaders->extra_shape.get());
|
||||
fluid_ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
fluid_ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ class ForceFields : Overlay {
|
||||
res.select_bind(ps_);
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
ps_.shader_set(res.shaders.extra_shape.get());
|
||||
ps_.shader_set(res.shaders->extra_shape.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ class GreasePencil : Overlay {
|
||||
|
||||
if (show_points_) {
|
||||
auto &sub = pass.sub("Points");
|
||||
sub.shader_set(res.shaders.curve_edit_points.get());
|
||||
sub.shader_set(res.shaders->curve_edit_points.get());
|
||||
sub.bind_texture("weightTex", &res.weight_ramp_tx);
|
||||
sub.push_constant("useWeight", show_weight_);
|
||||
sub.push_constant("useGreasePencil", true);
|
||||
@@ -131,7 +131,7 @@ class GreasePencil : Overlay {
|
||||
|
||||
if (show_lines_) {
|
||||
auto &sub = pass.sub("Lines");
|
||||
sub.shader_set(res.shaders.curve_edit_line.get());
|
||||
sub.shader_set(res.shaders->curve_edit_line.get());
|
||||
sub.bind_texture("weightTex", &res.weight_ramp_tx);
|
||||
sub.push_constant("useWeight", show_weight_);
|
||||
sub.push_constant("useGreasePencil", true);
|
||||
@@ -154,7 +154,7 @@ class GreasePencil : Overlay {
|
||||
if (show_grid_) {
|
||||
const float4 col_grid(float3(state.overlay.gpencil_grid_color),
|
||||
state.overlay.gpencil_grid_opacity);
|
||||
pass.shader_set(res.shaders.grid_grease_pencil.get());
|
||||
pass.shader_set(res.shaders->grid_grease_pencil.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.push_constant("color", col_grid);
|
||||
|
||||
@@ -67,7 +67,7 @@ class Grid : Overlay {
|
||||
if (state.is_space_image()) {
|
||||
/* Add quad background. */
|
||||
auto &sub = grid_ps_.sub("grid_background");
|
||||
sub.shader_set(res.shaders.grid_background.get());
|
||||
sub.shader_set(res.shaders->grid_background.get());
|
||||
const float4 color_back = math::interpolate(
|
||||
res.theme_settings.color_background, res.theme_settings.color_grid, 0.5);
|
||||
sub.push_constant("ucolor", color_back);
|
||||
@@ -77,7 +77,7 @@ class Grid : Overlay {
|
||||
}
|
||||
{
|
||||
auto &sub = grid_ps_.sub("grid");
|
||||
sub.shader_set(res.shaders.grid.get());
|
||||
sub.shader_set(res.shaders->grid.get());
|
||||
sub.bind_ubo("grid_buf", &data_);
|
||||
sub.bind_texture("depth_tx", depth_tx, GPUSamplerState::default_sampler());
|
||||
sub.bind_texture("depth_infront_tx", depth_infront_tx, GPUSamplerState::default_sampler());
|
||||
@@ -104,7 +104,7 @@ class Grid : Overlay {
|
||||
|
||||
/* Add wire border. */
|
||||
auto &sub = grid_ps_.sub("wire_border");
|
||||
sub.shader_set(res.shaders.grid_image.get());
|
||||
sub.shader_set(res.shaders->grid_image.get());
|
||||
sub.push_constant("ucolor", theme_color);
|
||||
tile_pos_buf_.clear();
|
||||
for (const int x : IndexRange(data_.size[0])) {
|
||||
|
||||
@@ -24,6 +24,10 @@ void Instance::init()
|
||||
/* Was needed by `object_wire_theme_id()` when doing the port. Not sure if needed nowadays. */
|
||||
BKE_view_layer_synced_ensure(ctx->scene, ctx->view_layer);
|
||||
|
||||
clipping_enabled_ = RV3D_CLIPPING_ENABLED(ctx->v3d, ctx->rv3d);
|
||||
|
||||
resources.init(clipping_enabled_);
|
||||
|
||||
state.depsgraph = ctx->depsgraph;
|
||||
state.view_layer = ctx->view_layer;
|
||||
state.space_data = ctx->space_data;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace blender::draw::overlay {
|
||||
*/
|
||||
class Instance {
|
||||
const SelectionType selection_type_;
|
||||
const bool clipping_enabled_;
|
||||
bool clipping_enabled_;
|
||||
|
||||
public:
|
||||
/* WORKAROUND: Legacy. Move to grid pass. */
|
||||
@@ -65,9 +65,7 @@ class Instance {
|
||||
ShapeCache shapes;
|
||||
|
||||
/** Global types. */
|
||||
Resources resources = {selection_type_,
|
||||
overlay::ShaderModule::module_get(selection_type_, clipping_enabled_),
|
||||
shapes};
|
||||
Resources resources = {selection_type_, shapes};
|
||||
State state;
|
||||
|
||||
/** Overlay types. */
|
||||
@@ -117,8 +115,7 @@ class Instance {
|
||||
AntiAliasing anti_aliasing;
|
||||
XrayFade xray_fade;
|
||||
|
||||
Instance(const SelectionType selection_type, const bool clipping_enabled)
|
||||
: selection_type_(selection_type), clipping_enabled_(clipping_enabled){};
|
||||
Instance(const SelectionType selection_type) : selection_type_(selection_type){};
|
||||
|
||||
~Instance()
|
||||
{
|
||||
@@ -131,11 +128,6 @@ class Instance {
|
||||
void end_sync();
|
||||
void draw(Manager &manager);
|
||||
|
||||
bool clipping_enabled() const
|
||||
{
|
||||
return clipping_enabled_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool object_is_selected(const ObjectRef &ob_ref);
|
||||
bool object_is_edit_mode(const Object *object);
|
||||
|
||||
@@ -50,10 +50,10 @@ class Lattices : Overlay {
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
res.select_bind(ps_);
|
||||
edit_lattice_wire_ps_ = create_sub_pass(
|
||||
"edit_lattice_wire", res.shaders.lattice_wire.get(), true);
|
||||
"edit_lattice_wire", res.shaders->lattice_wire.get(), true);
|
||||
edit_lattice_point_ps_ = create_sub_pass(
|
||||
"edit_lattice_points", res.shaders.lattice_points.get(), false);
|
||||
lattice_ps_ = create_sub_pass("lattice", res.shaders.extra_wire_object.get(), false);
|
||||
"edit_lattice_points", res.shaders->lattice_points.get(), false);
|
||||
lattice_ps_ = create_sub_pass("lattice", res.shaders->extra_wire_object.get(), false);
|
||||
}
|
||||
|
||||
void edit_object_sync(Manager &manager,
|
||||
|
||||
@@ -175,7 +175,7 @@ class Lights : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_FRONT,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.light_spot_cone.get());
|
||||
sub_pass.shader_set(res.shaders->light_spot_cone.get());
|
||||
call_buffers_.spot_cone_front_buf.end_sync(sub_pass, res.shapes.light_spot_volume.get());
|
||||
}
|
||||
{
|
||||
@@ -183,13 +183,13 @@ class Lights : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.light_spot_cone.get());
|
||||
sub_pass.shader_set(res.shaders->light_spot_cone.get());
|
||||
call_buffers_.spot_cone_back_buf.end_sync(sub_pass, res.shapes.light_spot_volume.get());
|
||||
}
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("light_shapes");
|
||||
sub_pass.state_set(pass_state, state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
sub_pass.shader_set(res.shaders->extra_shape.get());
|
||||
call_buffers_.icon_inner_buf.end_sync(sub_pass, res.shapes.light_icon_outer_lines.get());
|
||||
call_buffers_.icon_outer_buf.end_sync(sub_pass, res.shapes.light_icon_inner_lines.get());
|
||||
call_buffers_.icon_sun_rays_buf.end_sync(sub_pass, res.shapes.light_icon_sun_rays.get());
|
||||
@@ -202,7 +202,7 @@ class Lights : Overlay {
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("ground_line");
|
||||
sub_pass.state_set(pass_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_ground_line.get());
|
||||
sub_pass.shader_set(res.shaders->extra_ground_line.get());
|
||||
call_buffers_.ground_line_buf.end_sync(sub_pass, res.shapes.ground_line.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class LightProbes : Overlay {
|
||||
|
||||
ps_dots_.init();
|
||||
ps_dots_.state_set(DRW_STATE_WRITE_COLOR, state.clipping_plane_count);
|
||||
ps_dots_.shader_set(res.shaders.extra_grid.get());
|
||||
ps_dots_.shader_set(res.shaders->extra_grid.get());
|
||||
ps_dots_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_dots_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
ps_dots_.bind_texture("depthBuffer", &res.depth_tx);
|
||||
@@ -202,7 +202,7 @@ class LightProbes : Overlay {
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("empties");
|
||||
sub_pass.state_set(pass_state, state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_shape.get());
|
||||
sub_pass.shader_set(res.shaders->extra_shape.get());
|
||||
call_buffers_.probe_cube_buf.end_sync(sub_pass, res.shapes.lightprobe_cube.get());
|
||||
call_buffers_.probe_planar_buf.end_sync(sub_pass, res.shapes.lightprobe_planar.get());
|
||||
call_buffers_.probe_grid_buf.end_sync(sub_pass, res.shapes.lightprobe_grid.get());
|
||||
@@ -214,7 +214,7 @@ class LightProbes : Overlay {
|
||||
{
|
||||
PassSimple::Sub &sub_pass = ps_.sub("ground_line");
|
||||
sub_pass.state_set(pass_state | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_ground_line.get());
|
||||
sub_pass.shader_set(res.shaders->extra_ground_line.get());
|
||||
call_buffers_.ground_line_buf.end_sync(sub_pass, res.shapes.ground_line.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ class Meshes : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | face_culling,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.mesh_edit_depth.get());
|
||||
pass.shader_set(res.shaders->mesh_edit_depth.get());
|
||||
pass.push_constant("retopologyOffset", retopology_offset);
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
@@ -179,16 +179,16 @@ class Meshes : Overlay {
|
||||
face_normals_ = loop_normals_ = vert_normals_ = nullptr;
|
||||
|
||||
if (show_face_nor) {
|
||||
face_normals_subdiv_ = shader_pass(res.shaders.mesh_face_normal_subdiv.get(), "SubdFNor");
|
||||
face_normals_ = shader_pass(res.shaders.mesh_face_normal.get(), "FaceNor");
|
||||
face_normals_subdiv_ = shader_pass(res.shaders->mesh_face_normal_subdiv.get(), "SubdFNor");
|
||||
face_normals_ = shader_pass(res.shaders->mesh_face_normal.get(), "FaceNor");
|
||||
}
|
||||
if (show_loop_nor) {
|
||||
loop_normals_subdiv_ = shader_pass(res.shaders.mesh_loop_normal_subdiv.get(), "SubdLNor");
|
||||
loop_normals_ = shader_pass(res.shaders.mesh_loop_normal.get(), "LoopNor");
|
||||
loop_normals_subdiv_ = shader_pass(res.shaders->mesh_loop_normal_subdiv.get(), "SubdLNor");
|
||||
loop_normals_ = shader_pass(res.shaders->mesh_loop_normal.get(), "LoopNor");
|
||||
}
|
||||
if (show_vert_nor) {
|
||||
vert_normals_subdiv_ = shader_pass(res.shaders.mesh_vert_normal_subdiv.get(), "SubdVNor");
|
||||
vert_normals_ = shader_pass(res.shaders.mesh_vert_normal.get(), "VertexNor");
|
||||
vert_normals_subdiv_ = shader_pass(res.shaders->mesh_vert_normal_subdiv.get(), "SubdVNor");
|
||||
vert_normals_ = shader_pass(res.shaders->mesh_vert_normal.get(), "VertexNor");
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -200,8 +200,8 @@ class Meshes : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(shadeless ? res.shaders.paint_weight.get() :
|
||||
res.shaders.paint_weight_fake_shading.get());
|
||||
pass.shader_set(shadeless ? res.shaders->paint_weight.get() :
|
||||
res.shaders->paint_weight_fake_shading.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.bind_texture("colorramp", &res.weight_ramp_tx);
|
||||
@@ -217,7 +217,7 @@ class Meshes : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.mesh_analysis.get());
|
||||
pass.shader_set(res.shaders->mesh_analysis.get());
|
||||
pass.bind_texture("weightTex", res.weight_ramp_tx);
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ class Meshes : Overlay {
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_FIRST_VERTEX_CONVENTION,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.mesh_edit_edge.get());
|
||||
pass.shader_set(res.shaders->mesh_edit_edge.get());
|
||||
pass.push_constant("do_smooth_wire", do_smooth_wire);
|
||||
pass.push_constant("use_vertex_selection", select_vert_);
|
||||
mesh_edit_common_resource_bind(pass, backwire_opacity, edge_ndc_offset_);
|
||||
@@ -254,7 +254,7 @@ class Meshes : Overlay {
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA |
|
||||
face_culling,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.mesh_edit_face.get());
|
||||
pass.shader_set(res.shaders->mesh_edit_face.get());
|
||||
mesh_edit_common_resource_bind(pass, face_alpha, 0.0f);
|
||||
}
|
||||
{
|
||||
@@ -262,7 +262,7 @@ class Meshes : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.mesh_edit_face.get());
|
||||
pass.shader_set(res.shaders->mesh_edit_face.get());
|
||||
mesh_edit_common_resource_bind(pass, face_alpha, cage_ndc_offset_);
|
||||
}
|
||||
{
|
||||
@@ -271,7 +271,7 @@ class Meshes : Overlay {
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.mesh_edit_vert.get());
|
||||
pass.shader_set(res.shaders->mesh_edit_vert.get());
|
||||
mesh_edit_common_resource_bind(pass, backwire_opacity, vert_ndc_offset_);
|
||||
}
|
||||
{
|
||||
@@ -280,7 +280,7 @@ class Meshes : Overlay {
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.mesh_edit_facedot.get());
|
||||
pass.shader_set(res.shaders->mesh_edit_facedot.get());
|
||||
mesh_edit_common_resource_bind(pass, backwire_opacity, vert_ndc_offset_);
|
||||
}
|
||||
{
|
||||
@@ -289,7 +289,7 @@ class Meshes : Overlay {
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA |
|
||||
DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.mesh_edit_skin_root.get());
|
||||
pass.shader_set(res.shaders->mesh_edit_skin_root.get());
|
||||
pass.push_constant("retopologyOffset", retopology_offset);
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
@@ -660,7 +660,7 @@ class MeshUVs : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
|
||||
DRW_STATE_BLEND_ALPHA);
|
||||
pass.shader_set(res.shaders.uv_wireframe.get());
|
||||
pass.shader_set(res.shaders->uv_wireframe.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.push_constant("alpha", space_image->uv_opacity);
|
||||
@@ -673,7 +673,7 @@ class MeshUVs : Overlay {
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
|
||||
DRW_STATE_BLEND_ALPHA);
|
||||
|
||||
GPUShader *sh = res.shaders.uv_edit_edge.get();
|
||||
GPUShader *sh = res.shaders->uv_edit_edge.get();
|
||||
pass.specialize_constant(sh, "use_edge_select", !show_vert_);
|
||||
pass.shader_set(sh);
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
@@ -694,7 +694,7 @@ class MeshUVs : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
|
||||
DRW_STATE_BLEND_ALPHA);
|
||||
pass.shader_set(res.shaders.uv_edit_vert.get());
|
||||
pass.shader_set(res.shaders->uv_edit_vert.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.push_constant("pointSize", (point_size + 1.5f) * float(M_SQRT2));
|
||||
@@ -709,7 +709,7 @@ class MeshUVs : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
|
||||
DRW_STATE_BLEND_ALPHA);
|
||||
pass.shader_set(res.shaders.uv_edit_facedot.get());
|
||||
pass.shader_set(res.shaders->uv_edit_facedot.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.push_constant("pointSize", point_size);
|
||||
@@ -719,7 +719,7 @@ class MeshUVs : Overlay {
|
||||
auto &pass = faces_ps_;
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA);
|
||||
pass.shader_set(res.shaders.uv_edit_face.get());
|
||||
pass.shader_set(res.shaders->uv_edit_face.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.push_constant("uvOpacity", space_image->uv_opacity);
|
||||
@@ -730,8 +730,8 @@ class MeshUVs : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA);
|
||||
pass.shader_set(mesh_analysis_type_ == SI_UVDT_STRETCH_ANGLE ?
|
||||
res.shaders.uv_analysis_stretch_angle.get() :
|
||||
res.shaders.uv_analysis_stretch_area.get());
|
||||
res.shaders->uv_analysis_stretch_angle.get() :
|
||||
res.shaders->uv_analysis_stretch_area.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.push_constant("aspect", state.image_uv_aspect);
|
||||
@@ -842,7 +842,7 @@ class MeshUVs : Overlay {
|
||||
auto &pass = image_border_ps_;
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS);
|
||||
pass.shader_set(res.shaders.uv_image_borders.get());
|
||||
pass.shader_set(res.shaders->uv_image_borders.get());
|
||||
|
||||
auto draw_tile = [&](const ImageTile *tile, const bool is_active) {
|
||||
const int tile_x = ((tile->tile_number - 1001) % 10);
|
||||
@@ -899,7 +899,7 @@ class MeshUVs : Overlay {
|
||||
float2 size_image;
|
||||
BKE_image_get_size_fl(image, nullptr, &size_image[0]);
|
||||
|
||||
pass.shader_set(res.shaders.uv_brush_stencil.get());
|
||||
pass.shader_set(res.shaders->uv_brush_stencil.get());
|
||||
pass.bind_texture("imgTexture", stencil_texture);
|
||||
pass.push_constant("imgPremultiplied", true);
|
||||
pass.push_constant("imgAlphaBlend", true);
|
||||
@@ -920,7 +920,7 @@ class MeshUVs : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS |
|
||||
(is_combined ? DRW_STATE_BLEND_MUL : DRW_STATE_BLEND_ALPHA));
|
||||
pass.shader_set(res.shaders.uv_paint_mask.get());
|
||||
pass.shader_set(res.shaders->uv_paint_mask.get());
|
||||
pass.bind_texture("imgTexture", mask_texture_);
|
||||
pass.push_constant("color", float4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
pass.push_constant("opacity", opacity);
|
||||
|
||||
@@ -93,7 +93,7 @@ class Metaballs : Overlay {
|
||||
state.clipping_plane_count);
|
||||
/* NOTE: Use armature sphere outline shader to have perspective correct outline instead of
|
||||
* just a circle facing the camera. */
|
||||
ps_.shader_set(res.shaders.armature_sphere_outline.get());
|
||||
ps_.shader_set(res.shaders->armature_sphere_outline.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
res.select_bind(ps_);
|
||||
|
||||
@@ -53,7 +53,7 @@ class ModeTransfer : Overlay {
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH,
|
||||
state.clipping_plane_count);
|
||||
ps_.shader_set(res.shaders.uniform_color.get());
|
||||
ps_.shader_set(res.shaders->uniform_color.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
|
||||
|
||||
@@ -49,12 +49,12 @@ class MotionPath : Overlay {
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR, state.clipping_plane_count);
|
||||
{
|
||||
PassSimple::Sub &sub = pass.sub("Lines");
|
||||
sub.shader_set(res.shaders.motion_path_line.get());
|
||||
sub.shader_set(res.shaders->motion_path_line.get());
|
||||
line_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
PassSimple::Sub &sub = pass.sub("Points");
|
||||
sub.shader_set(res.shaders.motion_path_vert.get());
|
||||
sub.shader_set(res.shaders->motion_path_vert.get());
|
||||
vert_ps_ = ⊂
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class Origins : Overlay {
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
|
||||
res.select_bind(ps_);
|
||||
ps_.shader_set(res.shaders.extra_point.get());
|
||||
ps_.shader_set(res.shaders->extra_point.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
select_buf_.select_bind(ps_);
|
||||
|
||||
@@ -71,37 +71,37 @@ class Outline : Overlay {
|
||||
state.clipping_plane_count);
|
||||
{
|
||||
auto &sub = pass.sub("Curves");
|
||||
sub.shader_set(res.shaders.outline_prepass_curves.get());
|
||||
sub.shader_set(res.shaders->outline_prepass_curves.get());
|
||||
sub.push_constant("isTransform", is_transform);
|
||||
prepass_curves_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("PointCloud");
|
||||
sub.shader_set(res.shaders.outline_prepass_pointcloud.get());
|
||||
sub.shader_set(res.shaders->outline_prepass_pointcloud.get());
|
||||
sub.push_constant("isTransform", is_transform);
|
||||
prepass_pointcloud_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("GreasePencil");
|
||||
sub.shader_set(res.shaders.outline_prepass_gpencil.get());
|
||||
sub.shader_set(res.shaders->outline_prepass_gpencil.get());
|
||||
sub.push_constant("isTransform", is_transform);
|
||||
prepass_gpencil_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("Mesh");
|
||||
sub.shader_set(res.shaders.outline_prepass_mesh.get());
|
||||
sub.shader_set(res.shaders->outline_prepass_mesh.get());
|
||||
sub.push_constant("isTransform", is_transform);
|
||||
prepass_mesh_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("Volume");
|
||||
sub.shader_set(res.shaders.outline_prepass_mesh.get());
|
||||
sub.shader_set(res.shaders->outline_prepass_mesh.get());
|
||||
sub.push_constant("isTransform", is_transform);
|
||||
prepass_volume_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("Wire");
|
||||
sub.shader_set(res.shaders.outline_prepass_wire.get());
|
||||
sub.shader_set(res.shaders->outline_prepass_wire.get());
|
||||
sub.push_constant("isTransform", is_transform);
|
||||
prepass_wire_ps_ = ⊂
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class Outline : Overlay {
|
||||
auto &pass = outline_resolve_ps_;
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL);
|
||||
pass.shader_set(res.shaders.outline_detect.get());
|
||||
pass.shader_set(res.shaders->outline_detect.get());
|
||||
/* Don't occlude the outline if in xray mode as it causes too much flickering. */
|
||||
pass.push_constant("alphaOcclu", state.xray_enabled ? 1.0f : 0.35f);
|
||||
pass.push_constant("doThickOutlines", do_expand);
|
||||
@@ -205,7 +205,7 @@ class Outline : Overlay {
|
||||
pass.framebuffer_set(&prepass_fb_);
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.outline_prepass_wire.get());
|
||||
pass.shader_set(res.shaders->outline_prepass_wire.get());
|
||||
pass.push_constant("isTransform", is_transform);
|
||||
|
||||
for (FlatObjectRef flag_ob_ref : flat_objects_) {
|
||||
|
||||
@@ -75,7 +75,7 @@ class Paints : Overlay {
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
|
||||
DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.paint_region_face.get());
|
||||
sub.shader_set(res.shaders->paint_region_face.get());
|
||||
sub.push_constant("ucolor", float4(1.0, 1.0, 1.0, 0.2));
|
||||
paint_region_face_ps_ = ⊂
|
||||
}
|
||||
@@ -84,14 +84,14 @@ class Paints : Overlay {
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
|
||||
DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.paint_region_edge.get());
|
||||
sub.shader_set(res.shaders->paint_region_edge.get());
|
||||
paint_region_edge_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("Vert");
|
||||
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.paint_region_vert.get());
|
||||
sub.shader_set(res.shaders->paint_region_vert.get());
|
||||
paint_region_vert_ps_ = ⊂
|
||||
}
|
||||
}
|
||||
@@ -113,8 +113,8 @@ class Paints : Overlay {
|
||||
auto weight_subpass = [&](const char *name, DRWState drw_state) {
|
||||
auto &sub = pass.sub(name);
|
||||
sub.state_set(drw_state, state.clipping_plane_count);
|
||||
sub.shader_set(shadeless ? res.shaders.paint_weight.get() :
|
||||
res.shaders.paint_weight_fake_shading.get());
|
||||
sub.shader_set(shadeless ? res.shaders->paint_weight.get() :
|
||||
res.shaders->paint_weight_fake_shading.get());
|
||||
sub.bind_texture("colorramp", &res.weight_ramp_tx);
|
||||
sub.push_constant("drawContours", draw_contours);
|
||||
sub.push_constant("opacity", state.overlay.weight_paint_mode_opacity);
|
||||
@@ -144,7 +144,7 @@ class Paints : Overlay {
|
||||
auto &pass = paint_mask_ps_;
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.paint_texture.get());
|
||||
pass.shader_set(res.shaders->paint_texture.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.bind_texture("maskImage", mask_texture);
|
||||
|
||||
@@ -68,19 +68,19 @@ class Particles : Overlay {
|
||||
res.select_bind(pass);
|
||||
{
|
||||
auto &sub = pass.sub("Dots");
|
||||
sub.shader_set(res.shaders.particle_dot.get());
|
||||
sub.shader_set(res.shaders->particle_dot.get());
|
||||
sub.bind_texture("weightTex", res.weight_ramp_tx);
|
||||
dot_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("Shapes");
|
||||
sub.shader_set(res.shaders.particle_shape.get());
|
||||
sub.shader_set(res.shaders->particle_shape.get());
|
||||
sub.bind_texture("weightTex", res.weight_ramp_tx);
|
||||
shape_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("Hair");
|
||||
sub.shader_set(res.shaders.particle_hair.get());
|
||||
sub.shader_set(res.shaders->particle_hair.get());
|
||||
sub.push_constant("colorType", state.v3d->shading.wire_color_type);
|
||||
sub.push_constant("isTransform", is_transform);
|
||||
hair_ps_ = ⊂
|
||||
@@ -97,7 +97,7 @@ class Particles : Overlay {
|
||||
res.select_bind(pass);
|
||||
{
|
||||
auto &sub = pass.sub("Dots");
|
||||
sub.shader_set(res.shaders.particle_edit_vert.get());
|
||||
sub.shader_set(res.shaders->particle_edit_vert.get());
|
||||
sub.bind_texture("weightTex", res.weight_ramp_tx);
|
||||
sub.push_constant("useWeight", show_weight_);
|
||||
sub.push_constant("useGreasePencil", false);
|
||||
@@ -105,7 +105,7 @@ class Particles : Overlay {
|
||||
}
|
||||
{
|
||||
auto &sub = pass.sub("Edges");
|
||||
sub.shader_set(res.shaders.particle_edit_edge.get());
|
||||
sub.shader_set(res.shaders->particle_edit_edge.get());
|
||||
sub.bind_texture("weightTex", res.weight_ramp_tx);
|
||||
sub.push_constant("useWeight", false);
|
||||
sub.push_constant("useGreasePencil", false);
|
||||
|
||||
@@ -33,7 +33,7 @@ class PointClouds : Overlay {
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
ps_.shader_set(res.shaders.pointcloud_points.get());
|
||||
ps_.shader_set(res.shaders->pointcloud_points.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class ImagePrepass : Overlay {
|
||||
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
|
||||
ps_.shader_set(res.shaders.mesh_edit_depth.get());
|
||||
ps_.shader_set(res.shaders->mesh_edit_depth.get());
|
||||
ps_.draw(res.shapes.image_quad.get());
|
||||
}
|
||||
|
||||
@@ -96,33 +96,33 @@ class Prepass : Overlay {
|
||||
res.select_bind(ps_);
|
||||
{
|
||||
auto &sub = ps_.sub("Mesh");
|
||||
sub.shader_set(res.is_selection() ? res.shaders.depth_mesh_conservative.get() :
|
||||
res.shaders.depth_mesh.get());
|
||||
sub.shader_set(res.is_selection() ? res.shaders->depth_mesh_conservative.get() :
|
||||
res.shaders->depth_mesh.get());
|
||||
mesh_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = ps_.sub("MeshFlat");
|
||||
sub.shader_set(res.shaders.depth_mesh.get());
|
||||
sub.shader_set(res.shaders->depth_mesh.get());
|
||||
mesh_flat_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = ps_.sub("Hair");
|
||||
sub.shader_set(res.shaders.depth_mesh.get());
|
||||
sub.shader_set(res.shaders->depth_mesh.get());
|
||||
hair_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = ps_.sub("Curves");
|
||||
sub.shader_set(res.shaders.depth_curves.get());
|
||||
sub.shader_set(res.shaders->depth_curves.get());
|
||||
curves_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = ps_.sub("PointCloud");
|
||||
sub.shader_set(res.shaders.depth_pointcloud.get());
|
||||
sub.shader_set(res.shaders->depth_pointcloud.get());
|
||||
pointcloud_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = ps_.sub("GreasePencil");
|
||||
sub.shader_set(res.shaders.depth_grease_pencil.get());
|
||||
sub.shader_set(res.shaders->depth_grease_pencil.get());
|
||||
grease_pencil_ps_ = ⊂
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,7 +613,7 @@ struct GreasePencilDepthPlane {
|
||||
};
|
||||
|
||||
struct Resources : public select::SelectMap {
|
||||
ShaderModule &shaders;
|
||||
ShaderModule *shaders = nullptr;
|
||||
|
||||
/* Overlay Color. */
|
||||
Framebuffer overlay_color_only_fb = {"overlay_color_only_fb"};
|
||||
@@ -697,10 +697,8 @@ struct Resources : public select::SelectMap {
|
||||
|
||||
const ShapeCache &shapes;
|
||||
|
||||
Resources(const SelectionType selection_type_,
|
||||
ShaderModule &shader_module,
|
||||
const ShapeCache &shapes_)
|
||||
: select::SelectMap(selection_type_), shaders(shader_module), shapes(shapes_){};
|
||||
Resources(const SelectionType selection_type_, const ShapeCache &shapes_)
|
||||
: select::SelectMap(selection_type_), shapes(shapes_){};
|
||||
|
||||
~Resources()
|
||||
{
|
||||
@@ -710,6 +708,11 @@ struct Resources : public select::SelectMap {
|
||||
void update_theme_settings(const State &state);
|
||||
void update_clip_planes(const State &state);
|
||||
|
||||
void init(bool clipping_enabled)
|
||||
{
|
||||
shaders = &overlay::ShaderModule::module_get(selection_type, clipping_enabled);
|
||||
}
|
||||
|
||||
void begin_sync()
|
||||
{
|
||||
SelectMap::begin_sync();
|
||||
|
||||
@@ -203,7 +203,7 @@ class Relations : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_wire.get());
|
||||
sub_pass.shader_set(res.shaders->extra_wire.get());
|
||||
relations_buf_.end_sync(sub_pass);
|
||||
}
|
||||
{
|
||||
@@ -211,7 +211,7 @@ class Relations : Overlay {
|
||||
sub_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
sub_pass.shader_set(res.shaders.extra_loose_points.get());
|
||||
sub_pass.shader_set(res.shaders->extra_loose_points.get());
|
||||
points_buf_.end_sync(sub_pass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,14 +75,14 @@ class Sculpts : Overlay {
|
||||
state.clipping_plane_count);
|
||||
{
|
||||
auto &sub = sculpt_mask_.sub("Mesh");
|
||||
sub.shader_set(res.shaders.sculpt_mesh.get());
|
||||
sub.shader_set(res.shaders->sculpt_mesh.get());
|
||||
sub.push_constant("maskOpacity", mask_opacity);
|
||||
sub.push_constant("faceSetsOpacity", face_set_opacity);
|
||||
mesh_ps_ = ⊂
|
||||
}
|
||||
{
|
||||
auto &sub = sculpt_mask_.sub("Curves");
|
||||
sub.shader_set(res.shaders.sculpt_curves.get());
|
||||
sub.shader_set(res.shaders->sculpt_curves.get());
|
||||
sub.push_constant("selection_opacity", mask_opacity);
|
||||
curves_ps_ = ⊂
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class Sculpts : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA,
|
||||
state.clipping_plane_count);
|
||||
pass.shader_set(res.shaders.sculpt_curves_cage.get());
|
||||
pass.shader_set(res.shaders->sculpt_curves_cage.get());
|
||||
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
pass.push_constant("opacity", curve_cage_opacity);
|
||||
|
||||
@@ -65,7 +65,7 @@ class Speakers : Overlay {
|
||||
ps_.init();
|
||||
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
|
||||
state.clipping_plane_count);
|
||||
ps_.shader_set(res.shaders.extra_shape.get());
|
||||
ps_.shader_set(res.shaders->extra_shape.get());
|
||||
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
|
||||
ps_.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
|
||||
res.select_bind(ps_);
|
||||
|
||||
@@ -82,7 +82,7 @@ class Wireframe : Overlay {
|
||||
auto shader_pass =
|
||||
[&](GPUShader *shader, const char *name, bool use_coloring, float wire_threshold) {
|
||||
auto &sub = pass.sub(name);
|
||||
if (res.shaders.wireframe_mesh.get() == shader) {
|
||||
if (res.shaders->wireframe_mesh.get() == shader) {
|
||||
sub.specialize_constant(shader, "use_custom_depth_bias", do_smooth_lines);
|
||||
}
|
||||
sub.shader_set(shader);
|
||||
@@ -98,7 +98,7 @@ class Wireframe : Overlay {
|
||||
};
|
||||
|
||||
auto coloring_pass = [&](ColoringPass &ps, bool use_color) {
|
||||
overlay::ShaderModule &sh = res.shaders;
|
||||
overlay::ShaderModule &sh = *res.shaders;
|
||||
ps.mesh_ps_ = shader_pass(sh.wireframe_mesh.get(), "Mesh", use_color, wire_threshold);
|
||||
ps.mesh_all_edges_ps_ = shader_pass(sh.wireframe_mesh.get(), "Wire", use_color, 1.0f);
|
||||
ps.pointcloud_ps_ = shader_pass(sh.wireframe_points.get(), "PtCloud", use_color, 1.0f);
|
||||
|
||||
@@ -35,7 +35,7 @@ class XrayFade : Overlay {
|
||||
pass.init();
|
||||
pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_MUL);
|
||||
pass.framebuffer_set(&res.overlay_color_only_fb);
|
||||
pass.shader_set(res.shaders.xray_fade.get());
|
||||
pass.shader_set(res.shaders->xray_fade.get());
|
||||
/* TODO(fclem): Confusing. The meaning of xray depth texture changed between legacy engine
|
||||
* and overlay next. To be renamed after shaders are not shared anymore. */
|
||||
pass.bind_texture("depthTex", &res.xray_depth_tx);
|
||||
|
||||
@@ -33,14 +33,8 @@ static void SELECT_next_engine_init(void *vedata)
|
||||
OVERLAY_Data *ved = reinterpret_cast<OVERLAY_Data *>(vedata);
|
||||
|
||||
if (ved->instance == nullptr) {
|
||||
const DRWContext *draw_ctx = DRW_context_get();
|
||||
const RegionView3D *rv3d = draw_ctx->rv3d;
|
||||
const View3D *v3d = draw_ctx->v3d;
|
||||
const bool clipping_enabled = RV3D_CLIPPING_ENABLED(v3d, rv3d);
|
||||
|
||||
ved->instance = new Instance(select::SelectionType::ENABLED, clipping_enabled);
|
||||
ved->instance = new Instance(select::SelectionType::ENABLED);
|
||||
}
|
||||
|
||||
reinterpret_cast<Instance *>(ved->instance)->init();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user