Fix: Overlay-Next: Grid is occluded by scene geometry in wireframe mode
It was still using the depth buffer from Workbench. Use the dummy texture and point sampling to avoid more invasive changes.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "ED_image.hh"
|
||||
#include "ED_view3d.hh"
|
||||
#include "GPU_texture.hh"
|
||||
|
||||
#include "draw_shader_shared.hh"
|
||||
#include "overlay_next_private.hh"
|
||||
@@ -47,6 +48,9 @@ class Grid {
|
||||
|
||||
data_.push_update();
|
||||
|
||||
/* Use dummy depth texture in xray mode to avoid occluding the grid with the scene geometry. */
|
||||
GPUTexture **depth_tx = state.xray_enabled ? &res.dummy_depth_tx : &res.depth_tx;
|
||||
|
||||
grid_ps_.init();
|
||||
grid_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA);
|
||||
if (state.space_type == SPACE_IMAGE) {
|
||||
@@ -57,7 +61,7 @@ class Grid {
|
||||
res.theme_settings.color_background, res.theme_settings.color_grid, 0.5);
|
||||
sub.push_constant("ucolor", color_back);
|
||||
sub.push_constant("tile_scale", float3(data_.size));
|
||||
sub.bind_texture("depthBuffer", &res.depth_tx);
|
||||
sub.bind_texture("depthBuffer", depth_tx);
|
||||
sub.draw(shapes.quad_solid.get());
|
||||
}
|
||||
{
|
||||
@@ -65,7 +69,7 @@ class Grid {
|
||||
sub.shader_set(res.shaders.grid.get());
|
||||
sub.bind_ubo("grid_buf", &data_);
|
||||
sub.bind_ubo("globalsBlock", &res.globals_buf);
|
||||
sub.bind_texture("depth_tx", &res.depth_tx);
|
||||
sub.bind_texture("depth_tx", depth_tx, GPUSamplerState::default_sampler());
|
||||
if (zneg_flag_ & SHOW_AXIS_Z) {
|
||||
sub.push_constant("grid_flag", zneg_flag_);
|
||||
sub.push_constant("plane_axes", zplane_axes_);
|
||||
|
||||
@@ -203,7 +203,7 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
float scene_depth = texelFetch(depth_tx, ivec2(gl_FragCoord.xy), 0).r;
|
||||
float scene_depth = texture(depth_tx, gl_FragCoord.xy / vec2(textureSize(depth_tx, 0)), 0).r;
|
||||
if (flag_test(grid_flag, GRID_BACK)) {
|
||||
fade *= (scene_depth == 1.0) ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user