Fix #116985: Workbench: Skip volume depth test in Wireframe mode

This commit is contained in:
Miguel Pozo 2024-01-11 16:35:44 +01:00
parent c78a0f3aa6
commit 2bbf65f6e5
3 changed files with 6 additions and 3 deletions

View File

@ -17,6 +17,7 @@ GPU_SHADER_CREATE_INFO(workbench_volume_common)
.push_constant(Type::FLOAT, "noiseOfs")
.push_constant(Type::FLOAT, "stepLength")
.push_constant(Type::FLOAT, "densityScale")
.push_constant(Type::BOOL, "do_depth_test")
.vertex_source("workbench_volume_vert.glsl")
.fragment_source("workbench_volume_frag.glsl");

View File

@ -227,7 +227,7 @@ void main()
{
uint stencil = texelFetch(stencil_tx, ivec2(gl_FragCoord.xy), 0).r;
const uint in_front_stencil_bits = 1u << 1;
if ((stencil & in_front_stencil_bits) != 0) {
if (do_depth_test && (stencil & in_front_stencil_bits) != 0) {
/* Don't draw on top of "in front" objects. */
discard;
return;
@ -236,7 +236,7 @@ void main()
#ifdef VOLUME_SLICE
/* Manual depth test. TODO: remove. */
float depth = texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r;
if (gl_FragCoord.z >= depth) {
if (do_depth_test && gl_FragCoord.z >= depth) {
/* NOTE: In the Metal API, prior to Metal 2.3, Discard is not an explicit return and can
* produce undefined behavior. This is especially prominent with derivatives if control-flow
* divergence is present.
@ -260,7 +260,7 @@ void main()
vec3 volume_center = ModelMatrix[3].xyz;
float depth = texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r;
float depth = do_depth_test ? texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r : 1.0;
float depth_end = min(depth, gl_FragCoord.z);
vec3 vs_ray_end = get_view_space_from_depth(screen_uv, depth_end);
vec3 vs_ray_ori = get_view_space_from_depth(screen_uv, 0.0);

View File

@ -62,6 +62,7 @@ void VolumePass::object_sync_volume(Manager &manager,
const bool use_slice = (volume->display.axis_slice_method == AXIS_SLICE_SINGLE);
sub_ps.shader_set(get_shader(use_slice, false, volume->display.interpolation_method, false));
sub_ps.push_constant("do_depth_test", scene_state.shading.type >= OB_SOLID);
const float density_scale = volume->display.density *
BKE_volume_density_scale(volume, ob->object_to_world);
@ -128,6 +129,7 @@ void VolumePass::object_sync_modifier(Manager &manager,
const bool use_slice = settings.axis_slice_method == AXIS_SLICE_SINGLE;
sub_ps.shader_set(get_shader(use_slice, settings.use_coba, settings.interp_method, true));
sub_ps.push_constant("do_depth_test", scene_state.shading.type >= OB_SOLID);
if (settings.use_coba) {
const bool show_flags = settings.coba_field == FLUID_DOMAIN_FIELD_FLAGS;