Skip to content

Commit

Permalink
fix ifdef
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSentry committed Feb 7, 2023
1 parent 26e838b commit 336fac6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions assets/shaders/show_prepass.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ var show_prepass_sampler: sampler;
@fragment
fn fragment(
@builtin(position) frag_coord: vec4<f32>,
#ifndef WEBGL
#ifndef WEBGL
@builtin(sample_index) sample_index: u32,
#endif// WEBGL
#endif // WEBGL
#import bevy_pbr::mesh_vertex_output
) -> @location(0) vec4<f32> {
if settings.show_depth == 1.0 {
#ifdef WEBGL
#ifdef WEBGL
// prepass_depth() uses textureLoad which doesn't work in WebGL for depth textures.
// Instead we need to use a sampler
let dims = textureDimensions(depth_prepass_texture);
let uv = frag_coord.xy / vec2<f32>(dims);
let depth = textureSample(depth_prepass_texture, show_prepass_sampler, uv);
#else
#else
let depth = prepass_depth(frag_coord, sample_index);
#endif // WEBGL
#endif // WEBGL
return vec4(depth, depth, depth, 1.0);
} else if settings.show_normals == 1.0 {
#ifdef WEBGL
#ifdef WEBGL
let normal = prepass_normal(frag_coord, 0u);
#else // WEBGL
#else // WEBGL
let normal = prepass_normal(frag_coord, sample_index);
#endif // WEBGL
#endif // WEBGL
return vec4(normal, 1.0);
}

Expand Down

0 comments on commit 336fac6

Please sign in to comment.