
# Objective - The StandardMaterial always uses ATTRIBUTE_UV_0 for each texture except lightmap. This is not flexible enough for a lot of gltf Files. - Fixes #12496 - Fixes #13086 - Fixes #13122 - Closes #13153 ## Solution - The StandardMaterial gets extended for each texture by an UvChannel enum. It defaults to Uv0 but can also be set to Uv1. - The gltf loader now handles the texcoord information. If the texcoord is not supported it creates a warning. - It uses StandardMaterial shader defs to define which attribute to use. ## Testing This fixes #12496 for example:  For testing of all kind of textures I used the TextureTransformMultiTest from https://github.com/KhronosGroup/glTF-Sample-Assets/tree/main/Models/TextureTransformMultiTest Its purpose is to test multiple texture transfroms but it is also a good test for different texcoords. It also shows the issue with emission #13133. Before:  After: 
61 lines
1.5 KiB
WebGPU Shading Language
61 lines
1.5 KiB
WebGPU Shading Language
#define_import_path bevy_pbr::forward_io
|
|
|
|
struct Vertex {
|
|
@builtin(instance_index) instance_index: u32,
|
|
#ifdef VERTEX_POSITIONS
|
|
@location(0) position: vec3<f32>,
|
|
#endif
|
|
#ifdef VERTEX_NORMALS
|
|
@location(1) normal: vec3<f32>,
|
|
#endif
|
|
#ifdef VERTEX_UVS_A
|
|
@location(2) uv: vec2<f32>,
|
|
#endif
|
|
#ifdef VERTEX_UVS_B
|
|
@location(3) uv_b: vec2<f32>,
|
|
#endif
|
|
#ifdef VERTEX_TANGENTS
|
|
@location(4) tangent: vec4<f32>,
|
|
#endif
|
|
#ifdef VERTEX_COLORS
|
|
@location(5) color: vec4<f32>,
|
|
#endif
|
|
#ifdef SKINNED
|
|
@location(6) joint_indices: vec4<u32>,
|
|
@location(7) joint_weights: vec4<f32>,
|
|
#endif
|
|
#ifdef MORPH_TARGETS
|
|
@builtin(vertex_index) index: u32,
|
|
#endif
|
|
};
|
|
|
|
struct VertexOutput {
|
|
// This is `clip position` when the struct is used as a vertex stage output
|
|
// and `frag coord` when used as a fragment stage input
|
|
@builtin(position) position: vec4<f32>,
|
|
@location(0) world_position: vec4<f32>,
|
|
@location(1) world_normal: vec3<f32>,
|
|
#ifdef VERTEX_UVS_A
|
|
@location(2) uv: vec2<f32>,
|
|
#endif
|
|
#ifdef VERTEX_UVS_B
|
|
@location(3) uv_b: vec2<f32>,
|
|
#endif
|
|
#ifdef VERTEX_TANGENTS
|
|
@location(4) world_tangent: vec4<f32>,
|
|
#endif
|
|
#ifdef VERTEX_COLORS
|
|
@location(5) color: vec4<f32>,
|
|
#endif
|
|
#ifdef VERTEX_OUTPUT_INSTANCE_INDEX
|
|
@location(6) @interpolate(flat) instance_index: u32,
|
|
#endif
|
|
#ifdef VISIBILITY_RANGE_DITHER
|
|
@location(7) @interpolate(flat) visibility_range_dither: i32,
|
|
#endif
|
|
}
|
|
|
|
struct FragmentOutput {
|
|
@location(0) color: vec4<f32>,
|
|
}
|