From 7ccd52ee8308c37a33cbb05fb884517192776f36 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Sat, 21 Oct 2023 01:57:44 +0100 Subject: [PATCH] Remove unused vertex attributes. --- src/outline.wgsl | 42 +++++++++++++++--------------------------- src/pipeline.rs | 10 ---------- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/src/outline.wgsl b/src/outline.wgsl index a61bb68..6e462b7 100644 --- a/src/outline.wgsl +++ b/src/outline.wgsl @@ -2,27 +2,6 @@ #import bevy_pbr::mesh_types Mesh #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 { #ifdef VERTEX_POSITIONS @location(0) position: vec3, @@ -30,12 +9,6 @@ struct Vertex { #ifndef OFFSET_ZERO @location(1) outline_normal: vec3, #endif -#ifdef VERTEX_NORMALS - @location(2) normal: vec3, -#endif -#ifdef VERTEX_TANGENTS - @location(3) tangent: vec4, -#endif #ifdef SKINNED @location(5) joint_indices: vec4, @location(6) joint_weights: vec4, @@ -78,6 +51,21 @@ var view_uniform: OutlineViewUniform; @group(3) @binding(0) var 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) -> mat3x3 { return mat3x3( m[0].xyz, m[1].xyz, m[2].xyz diff --git a/src/pipeline.rs b/src/pipeline.rs index 57674cf..10e8f69 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -251,16 +251,6 @@ impl SpecializedMeshPipeline for OutlinePipeline { 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 { self.mesh_pipeline.view_layout.clone() } else {