Skip to content

Commit 982e337

Browse files
authored
Fix parallax mapping (#9003)
# Objective Since 10f5c92, parallax mapping was broken. When #5703 was merged, the change from `in.uv` to `uv` in the pbr shader was reverted. So the shader would use the wrong coordinate to sample the various textures. ## Solution We revert to using the correct uv.
1 parent fd32c6f commit 982e337

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/bevy_pbr/src/render/pbr.wgsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn fragment(
5555
#endif
5656
#ifdef VERTEX_UVS
5757
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT) != 0u) {
58-
output_color = output_color * textureSampleBias(pbr_bindings::base_color_texture, pbr_bindings::base_color_sampler, in.uv, view.mip_bias);
58+
output_color = output_color * textureSampleBias(pbr_bindings::base_color_texture, pbr_bindings::base_color_sampler, uv, view.mip_bias);
5959
}
6060
#endif
6161

@@ -74,7 +74,7 @@ fn fragment(
7474
var emissive: vec4<f32> = pbr_bindings::material.emissive;
7575
#ifdef VERTEX_UVS
7676
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT) != 0u) {
77-
emissive = vec4<f32>(emissive.rgb * textureSampleBias(pbr_bindings::emissive_texture, pbr_bindings::emissive_sampler, in.uv, view.mip_bias).rgb, 1.0);
77+
emissive = vec4<f32>(emissive.rgb * textureSampleBias(pbr_bindings::emissive_texture, pbr_bindings::emissive_sampler, uv, view.mip_bias).rgb, 1.0);
7878
}
7979
#endif
8080
pbr_input.material.emissive = emissive;
@@ -83,7 +83,7 @@ fn fragment(
8383
var perceptual_roughness: f32 = pbr_bindings::material.perceptual_roughness;
8484
#ifdef VERTEX_UVS
8585
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_TEXTURE_BIT) != 0u) {
86-
let metallic_roughness = textureSampleBias(pbr_bindings::metallic_roughness_texture, pbr_bindings::metallic_roughness_sampler, in.uv, view.mip_bias);
86+
let metallic_roughness = textureSampleBias(pbr_bindings::metallic_roughness_texture, pbr_bindings::metallic_roughness_sampler, uv, view.mip_bias);
8787
// Sampling from GLTF standard channels for now
8888
metallic = metallic * metallic_roughness.b;
8989
perceptual_roughness = perceptual_roughness * metallic_roughness.g;
@@ -96,7 +96,7 @@ fn fragment(
9696
var occlusion: vec3<f32> = vec3(1.0);
9797
#ifdef VERTEX_UVS
9898
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_OCCLUSION_TEXTURE_BIT) != 0u) {
99-
occlusion = vec3(textureSampleBias(pbr_bindings::occlusion_texture, pbr_bindings::occlusion_sampler, in.uv, view.mip_bias).r);
99+
occlusion = vec3(textureSampleBias(pbr_bindings::occlusion_texture, pbr_bindings::occlusion_sampler, uv, view.mip_bias).r);
100100
}
101101
#endif
102102
#ifdef SCREEN_SPACE_AMBIENT_OCCLUSION

0 commit comments

Comments
 (0)