Skip to content

Commit

Permalink
Rename uv_a back to uv per consensus
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Oct 24, 2023
1 parent ff21b6c commit 44a64a9
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion assets/shaders/animate_shader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
let t_1 = sin(globals.time * speed) * 0.5 + 0.5;
let t_2 = cos(globals.time * speed);

let distance_to_center = distance(in.uv_a, vec2<f32>(0.5)) * 1.4;
let distance_to_center = distance(in.uv, vec2<f32>(0.5)) * 1.4;

// blending is done in a perceptual color space: https://bottosson.github.io/posts/oklab/
let red = vec3<f32>(0.627955, 0.224863, 0.125846);
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/array_texture.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn fragment(
// the material members
var pbr_input: PbrInput = pbr_input_new();

pbr_input.material.base_color = textureSample(my_array_texture, my_array_texture_sampler, mesh.uv_a, layer);
pbr_input.material.base_color = textureSample(my_array_texture, my_array_texture_sampler, mesh.uv, layer);
#ifdef VERTEX_COLORS
pbr_input.material.base_color = pbr_input.material.base_color * mesh.color;
#endif
Expand All @@ -43,7 +43,7 @@ fn fragment(
mesh.world_tangent,
#endif
#endif
mesh.uv_a,
mesh.uv,
view.mip_bias,
);
pbr_input.V = fns::calculate_view(mesh.world_position, pbr_input.is_orthographic);
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/custom_material.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ struct CustomMaterial {
fn fragment(
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
return material.color * textureSample(base_color_texture, base_color_sampler, mesh.uv_a) * COLOR_MULTIPLIER;
return material.color * textureSample(base_color_texture, base_color_sampler, mesh.uv) * COLOR_MULTIPLIER;
}
4 changes: 2 additions & 2 deletions assets/shaders/texture_binding_array.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ fn fragment(
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
// Select the texture to sample from using non-uniform uv coordinates
let coords = clamp(vec2<u32>(mesh.uv_a * 4.0), vec2<u32>(0u), vec2<u32>(3u));
let coords = clamp(vec2<u32>(mesh.uv * 4.0), vec2<u32>(0u), vec2<u32>(3u));
let index = coords.y * 4u + coords.x;
let inner_uv = fract(mesh.uv_a * 4.0);
let inner_uv = fract(mesh.uv * 4.0);
return textureSample(textures[index], nearest_sampler, inner_uv);
}
2 changes: 1 addition & 1 deletion assets/shaders/tonemapping_test_patterns.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn continuous_hue(uv: vec2<f32>) -> vec3<f32> {
fn fragment(
in: VertexOutput,
) -> @location(0) vec4<f32> {
var uv = in.uv_a;
var uv = in.uv;
var out = vec3(0.0);
if uv.y > 0.5 {
uv.y = 1.0 - uv.y;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/prepass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ where
}

if layout.contains(Mesh::ATTRIBUTE_UV_0) {
shader_defs.push("VERTEX_UVS_A".into());
shader_defs.push("VERTEX_UVS".into());
vertex_attributes.push(Mesh::ATTRIBUTE_UV_0.at_shader_location(1));
}

Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_pbr/src/prepass/prepass.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
out.position.z = min(out.position.z, 1.0);
#endif // DEPTH_CLAMP_ORTHO

#ifdef VERTEX_UVS_A
out.uv_a = vertex.uv_a;
#endif // VERTEX_UVS_A
#ifdef VERTEX_UVS
out.uv = vertex.uv;
#endif // VERTEX_UVS

#ifdef NORMAL_PREPASS_OR_DEFERRED_PREPASS
#ifdef SKINNED
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/prepass/prepass_io.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct Vertex {
@builtin(instance_index) instance_index: u32,
@location(0) position: vec3<f32>,

#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
@location(1) uv: vec2<f32>,
#endif

Expand Down Expand Up @@ -36,7 +36,7 @@ struct VertexOutput {
// and `frag coord` when used as a fragment stage input
@builtin(position) position: vec4<f32>,

#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
@location(0) uv: vec2<f32>,
#endif

Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_pbr/src/render/forward_io.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ struct Vertex {
#ifdef VERTEX_NORMALS
@location(1) normal: vec3<f32>,
#endif
#ifdef VERTEX_UVS_A
@location(2) uv_a: vec2<f32>,
#ifdef VERTEX_UVS
@location(2) uv: vec2<f32>,
#endif
#ifdef VERTEX_UVS_B
@location(3) uv_b: vec2<f32>,
Expand All @@ -35,8 +35,8 @@ struct VertexOutput {
@builtin(position) position: vec4<f32>,
@location(0) world_position: vec4<f32>,
@location(1) world_normal: vec3<f32>,
#ifdef VERTEX_UVS_A
@location(2) uv_a: vec2<f32>,
#ifdef VERTEX_UVS
@location(2) uv: vec2<f32>,
#endif
#ifdef VERTEX_UVS_B
@location(3) uv_b: vec2<f32>,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ impl SpecializedMeshPipeline for MeshPipeline {
}

if layout.contains(Mesh::ATTRIBUTE_UV_0) {
shader_defs.push("VERTEX_UVS_A".into());
shader_defs.push("VERTEX_UVS".into());
vertex_attributes.push(Mesh::ATTRIBUTE_UV_0.at_shader_location(2));
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/render/mesh.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
out.position = mesh_functions::mesh_position_world_to_clip(out.world_position);
#endif

#ifdef VERTEX_UVS_A
out.uv_a = vertex.uv_a;
#ifdef VERTEX_UVS
out.uv = vertex.uv;
#endif

#ifdef VERTEX_UVS_B
Expand Down
14 changes: 7 additions & 7 deletions crates/bevy_pbr/src/render/pbr_fragment.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ fn pbr_input_from_standard_material(
pbr_input.material.base_color *= pbr_bindings::material.base_color;
pbr_input.material.deferred_lighting_pass_id = pbr_bindings::material.deferred_lighting_pass_id;

#ifdef VERTEX_UVS_A
var uv = in.uv_a;
#ifdef VERTEX_UVS
var uv = in.uv;

#ifdef VERTEX_TANGENTS
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_DEPTH_MAP_BIT) != 0u) {
Expand All @@ -95,7 +95,7 @@ fn pbr_input_from_standard_material(
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT) != 0u) {
pbr_input.material.base_color *= textureSampleBias(pbr_bindings::base_color_texture, pbr_bindings::base_color_sampler, uv, view.mip_bias);
}
#endif // VERTEX_UVS_A
#endif // VERTEX_UVS

pbr_input.material.flags = pbr_bindings::material.flags;

Expand All @@ -108,7 +108,7 @@ fn pbr_input_from_standard_material(
// emissive
// TODO use .a for exposure compensation in HDR
var emissive: vec4<f32> = pbr_bindings::material.emissive;
#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT) != 0u) {
emissive = vec4<f32>(emissive.rgb * textureSampleBias(pbr_bindings::emissive_texture, pbr_bindings::emissive_sampler, uv, view.mip_bias).rgb, 1.0);
}
Expand All @@ -118,7 +118,7 @@ fn pbr_input_from_standard_material(
// metallic and perceptual roughness
var metallic: f32 = pbr_bindings::material.metallic;
var perceptual_roughness: f32 = pbr_bindings::material.perceptual_roughness;
#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_METALLIC_ROUGHNESS_TEXTURE_BIT) != 0u) {
let metallic_roughness = textureSampleBias(pbr_bindings::metallic_roughness_texture, pbr_bindings::metallic_roughness_sampler, uv, view.mip_bias);
// Sampling from GLTF standard channels for now
Expand All @@ -132,7 +132,7 @@ fn pbr_input_from_standard_material(
// occlusion
// TODO: Split into diffuse/specular occlusion?
var occlusion: vec3<f32> = vec3(1.0);
#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_OCCLUSION_TEXTURE_BIT) != 0u) {
occlusion = vec3(textureSampleBias(pbr_bindings::occlusion_texture, pbr_bindings::occlusion_sampler, uv, view.mip_bias).r);
}
Expand All @@ -154,7 +154,7 @@ fn pbr_input_from_standard_material(
in.world_tangent,
#endif
#endif
#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
uv,
#endif
view.mip_bias,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/render/pbr_functions.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn apply_normal_mapping(
world_tangent: vec4<f32>,
#endif
#endif
#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
uv: vec2<f32>,
#endif
mip_bias: f32,
Expand All @@ -91,7 +91,7 @@ fn apply_normal_mapping(
#endif

#ifdef VERTEX_TANGENTS
#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
#ifdef STANDARDMATERIAL_NORMAL_MAP
// Nt is the tangent-space normal.
var Nt = textureSampleBias(pbr_bindings::normal_map_texture, pbr_bindings::normal_map_sampler, uv, mip_bias).rgb;
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_pbr/src/render/pbr_prepass.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ fn fragment(
in.world_tangent,
#endif // STANDARDMATERIAL_NORMAL_MAP
#endif // VERTEX_TANGENTS
#ifdef VERTEX_UVS_A
in.uv_a,
#endif // VERTEX_UVS_A
#ifdef VERTEX_UVS
in.uv,
#endif // VERTEX_UVS
view.mip_bias,
);

Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_pbr/src/render/pbr_prepass_functions.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ fn prepass_alpha_discard(in: VertexOutput) {
#ifdef MAY_DISCARD
var output_color: vec4<f32> = pbr_bindings::material.base_color;

#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
if (pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT) != 0u {
output_color = output_color * textureSampleBias(pbr_bindings::base_color_texture, pbr_bindings::base_color_sampler, in.uv_a, view.mip_bias);
output_color = output_color * textureSampleBias(pbr_bindings::base_color_texture, pbr_bindings::base_color_sampler, in.uv, view.mip_bias);
}
#endif // VERTEX_UVS_A
#endif // VERTEX_UVS

let alpha_mode = pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_ALPHA_MODE_RESERVED_BITS;
if alpha_mode == pbr_types::STANDARD_MATERIAL_FLAGS_ALPHA_MODE_MASK {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/mesh2d/color_material.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn fragment(
output_color = output_color * mesh.color;
#endif
if ((material.flags & COLOR_MATERIAL_FLAGS_TEXTURE_BIT) != 0u) {
output_color = output_color * textureSample(texture, texture_sampler, mesh.uv_a);
output_color = output_color * textureSample(texture, texture_sampler, mesh.uv);
}
#ifdef TONEMAP_IN_SHADER
output_color = tonemapping::tone_mapping(output_color, view.color_grading);
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/mesh2d/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ impl SpecializedMeshPipeline for Mesh2dPipeline {
}

if layout.contains(Mesh::ATTRIBUTE_UV_0) {
shader_defs.push("VERTEX_UVS_A".into());
shader_defs.push("VERTEX_UVS".into());
vertex_attributes.push(Mesh::ATTRIBUTE_UV_0.at_shader_location(2));
}

Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_sprite/src/mesh2d/mesh2d.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct Vertex {
#ifdef VERTEX_NORMALS
@location(1) normal: vec3<f32>,
#endif
#ifdef VERTEX_UVS_A
#ifdef VERTEX_UVS
@location(2) uv: vec2<f32>,
#endif
#ifdef VERTEX_TANGENTS
Expand All @@ -30,8 +30,8 @@ struct Vertex {
@vertex
fn vertex(vertex: Vertex) -> VertexOutput {
var out: VertexOutput;
#ifdef VERTEX_UVS_A
out.uv_a = vertex.uv_a;
#ifdef VERTEX_UVS
out.uv = vertex.uv;
#endif

#ifdef VERTEX_POSITIONS
Expand Down
6 changes: 3 additions & 3 deletions examples/3d/generate_custom_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ fn create_cube_mesh() -> Mesh {
// Function that changes the UV mapping of the mesh, to apply the other texture.
fn toggle_texture(mesh_to_change: &mut Mesh) {
// Get a mutable reference to the values of the UV attribute, so we can iterate over it.
let uv_attribute = mesh_to_change.attribute_mut(Mesh::ATTRIBUTE_UV_0).unwrap();
let uvttribute = mesh_to_change.attribute_mut(Mesh::ATTRIBUTE_UV_0).unwrap();
// The format of the UV coordinates should be Float32x2.
let VertexAttributeValues::Float32x2(uv_attribute) = uv_attribute else {
let VertexAttributeValues::Float32x2(uvttribute) = uvttribute else {
panic!("Unexpected vertex format, expected Float32x2.");
};

// Iterate over the UV coordinates, and change them as we want.
for uv_coord in uv_attribute.iter_mut() {
for uv_coord in uvttribute.iter_mut() {
// If the UV coordinate points to the upper, "dirt+grass" part of the texture...
if (uv_coord[1] + 0.5) < 1.0 {
// ... point to the equivalent lower, "sand+water" part instead,
Expand Down

0 comments on commit 44a64a9

Please sign in to comment.