Remove unused vertex attributes.

This commit is contained in:
Robin KAY 2023-10-21 01:57:44 +01:00
parent 0351b05978
commit 7ccd52ee83
2 changed files with 15 additions and 37 deletions

View File

@ -2,27 +2,6 @@
#import bevy_pbr::mesh_types Mesh #import bevy_pbr::mesh_types Mesh
#import bevy_pbr::mesh_types SkinnedMesh #import bevy_pbr::mesh_types SkinnedMesh
#ifdef MORPH_TARGETS
fn morph_vertex(vertex_in: Vertex) -> Vertex {
var vertex = vertex_in;
let weight_count = bevy_pbr::morph::layer_count();
for (var i: u32 = 0u; i < weight_count; i ++) {
let weight = bevy_pbr::morph::weight_at(i);
if weight == 0.0 {
continue;
}
vertex.position += weight * bevy_pbr::morph::morph(vertex.index, bevy_pbr::morph::position_offset, i);
#ifdef VERTEX_NORMALS
vertex.normal += weight * bevy_pbr::morph::morph(vertex.index, bevy_pbr::morph::normal_offset, i);
#endif
#ifdef VERTEX_TANGENTS
vertex.tangent += vec4(weight * bevy_pbr::morph::morph(vertex.index, bevy_pbr::morph::tangent_offset, i), 0.0);
#endif
}
return vertex;
}
#endif
struct Vertex { struct Vertex {
#ifdef VERTEX_POSITIONS #ifdef VERTEX_POSITIONS
@location(0) position: vec3<f32>, @location(0) position: vec3<f32>,
@ -30,12 +9,6 @@ struct Vertex {
#ifndef OFFSET_ZERO #ifndef OFFSET_ZERO
@location(1) outline_normal: vec3<f32>, @location(1) outline_normal: vec3<f32>,
#endif #endif
#ifdef VERTEX_NORMALS
@location(2) normal: vec3<f32>,
#endif
#ifdef VERTEX_TANGENTS
@location(3) tangent: vec4<f32>,
#endif
#ifdef SKINNED #ifdef SKINNED
@location(5) joint_indices: vec4<u32>, @location(5) joint_indices: vec4<u32>,
@location(6) joint_weights: vec4<f32>, @location(6) joint_weights: vec4<f32>,
@ -78,6 +51,21 @@ var<uniform> view_uniform: OutlineViewUniform;
@group(3) @binding(0) @group(3) @binding(0)
var<uniform> vstage: OutlineVertexUniform; var<uniform> vstage: OutlineVertexUniform;
#ifdef MORPH_TARGETS
fn morph_vertex(vertex_in: Vertex) -> Vertex {
var vertex = vertex_in;
let weight_count = bevy_pbr::morph::layer_count();
for (var i: u32 = 0u; i < weight_count; i ++) {
let weight = bevy_pbr::morph::weight_at(i);
if weight == 0.0 {
continue;
}
vertex.position += weight * bevy_pbr::morph::morph(vertex.index, bevy_pbr::morph::position_offset, i);
}
return vertex;
}
#endif
fn mat4to3(m: mat4x4<f32>) -> mat3x3<f32> { fn mat4to3(m: mat4x4<f32>) -> mat3x3<f32> {
return mat3x3<f32>( return mat3x3<f32>(
m[0].xyz, m[1].xyz, m[2].xyz m[0].xyz, m[1].xyz, m[2].xyz

View File

@ -251,16 +251,6 @@ impl SpecializedMeshPipeline for OutlinePipeline {
buffer_attrs.push(Mesh::ATTRIBUTE_POSITION.at_shader_location(0)); buffer_attrs.push(Mesh::ATTRIBUTE_POSITION.at_shader_location(0));
} }
if layout.contains(Mesh::ATTRIBUTE_NORMAL) {
vertex_defs.push("VERTEX_NORMALS".into());
buffer_attrs.push(Mesh::ATTRIBUTE_NORMAL.at_shader_location(2));
}
if layout.contains(Mesh::ATTRIBUTE_TANGENT) {
vertex_defs.push("VERTEX_TANGENTS".into());
buffer_attrs.push(Mesh::ATTRIBUTE_TANGENT.at_shader_location(3));
}
let mut bind_layouts = vec![if key.msaa() == Msaa::Off { let mut bind_layouts = vec![if key.msaa() == Msaa::Off {
self.mesh_pipeline.view_layout.clone() self.mesh_pipeline.view_layout.clone()
} else { } else {