Use new WEBGL2 shader def, remove PREPASS_DEPTH_SUPPORTED shader def

This commit is contained in:
Marco Buono 2023-10-15 16:36:18 -03:00
parent 59c9bcd01a
commit 912defbdeb
5 changed files with 12 additions and 14 deletions

View File

@ -23,10 +23,10 @@ fn fragment(
let sample_index = 0u;
#endif
if settings.show_depth == 1u {
#ifdef PREPASS_DEPTH_SUPPORTED
let depth = bevy_pbr::prepass_utils::prepass_depth(frag_coord, sample_index);
#else
#ifdef WEBGL2
let depth = 0.0;
#else
let depth = bevy_pbr::prepass_utils::prepass_depth(frag_coord, sample_index);
#endif
return vec4(depth, depth, depth, 1.0);
} else if settings.show_normals == 1u {

View File

@ -3,7 +3,7 @@
#import bevy_pbr::mesh_view_bindings as view_bindings
#ifndef DEPTH_PREPASS
#ifdef PREPASS_DEPTH_SUPPORTED
#ifndef WEBGL2
fn prepass_depth(frag_coord: vec4<f32>, sample_index: u32) -> f32 {
#ifdef MULTISAMPLED
return textureLoad(view_bindings::depth_prepass_texture, vec2<i32>(frag_coord.xy), i32(sample_index));
@ -11,7 +11,7 @@ fn prepass_depth(frag_coord: vec4<f32>, sample_index: u32) -> f32 {
return textureLoad(view_bindings::depth_prepass_texture, vec2<i32>(frag_coord.xy), 0);
#endif // MULTISAMPLED
}
#endif // PREPASS_DEPTH_SUPPORTED
#endif // WEBGL2
#endif // DEPTH_PREPASS
#ifndef NORMAL_PREPASS

View File

@ -843,10 +843,6 @@ impl SpecializedMeshPipeline for MeshPipeline {
vertex_attributes.push(Mesh::ATTRIBUTE_COLOR.at_shader_location(5));
}
if cfg!(any(not(feature = "webgl"), not(target_arch = "wasm32"))) {
shader_defs.push("PREPASS_DEPTH_SUPPORTED".into());
}
if cfg!(feature = "pbr_transmission_textures") {
shader_defs.push("PBR_TRANSMISSION_TEXTURES_SUPPORTED".into());
}

View File

@ -42,15 +42,15 @@
@group(0) @binding(16) var dt_lut_sampler: sampler;
#ifdef MULTISAMPLED
#ifdef PREPASS_DEPTH_SUPPORTED
#ifndef WEBGL2
@group(0) @binding(17) var depth_prepass_texture: texture_depth_multisampled_2d;
#endif // PREPASS_DEPTH_SUPPORTED
#endif // WEBGL2
@group(0) @binding(18) var normal_prepass_texture: texture_multisampled_2d<f32>;
@group(0) @binding(19) var motion_vector_prepass_texture: texture_multisampled_2d<f32>;
#else
#ifdef PREPASS_DEPTH_SUPPORTED
#ifndef WEBGL2
@group(0) @binding(17) var depth_prepass_texture: texture_depth_2d;
#endif // PREPASS_DEPTH_SUPPORTED
#endif // WEBGL2
@group(0) @binding(18) var normal_prepass_texture: texture_2d<f32>;
@group(0) @binding(19) var motion_vector_prepass_texture: texture_2d<f32>;
@group(0) @binding(20) var deferred_prepass_texture: texture_2d<u32>;

View File

@ -413,11 +413,13 @@ fn fetch_transmissive_background(offset_position: vec2<f32>, frag_coord: vec3<f3
// Calculate final offset position, with blur and spiral offset
let modified_offset_position = offset_position + rotated_spiral_offset * blur_intensity * (1.0 - f32(pixel_checkboard) * 0.1);
#ifdef PREPASS_DEPTH_SUPPORTED
#ifndef DEPTH_PREPASS
#ifndef WEBGL2
// Use depth prepass data to reject values that are in front of the current fragment
if prepass_utils::prepass_depth(vec4<f32>(modified_offset_position * view_bindings::view.viewport.zw, 0.0, 0.0), 0u) > frag_coord.z {
continue;
}
#endif
#endif
// Sample the view transmission texture at the offset position + noise offset, to get the background color