Skip to content

Commit f3ef677

Browse files
committed
use custom vertex shader
1 parent f3e8ae6 commit f3ef677

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed
+41-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
1+
#import bevy_pbr::mesh_types
2+
#import bevy_pbr::mesh_view_bindings
3+
4+
@group(2) @binding(0)
5+
var<uniform> mesh: Mesh;
6+
7+
#ifdef SKINNED
8+
@group(2) @binding(1)
9+
var<uniform> joint_matrices: SkinnedMesh;
10+
#import bevy_pbr::skinning
11+
#endif
12+
13+
// NOTE: Bindings must come before functions that use them!
14+
#import bevy_pbr::mesh_functions
15+
16+
struct Vertex {
17+
@location(0) position: vec3<f32>,
18+
#ifdef SKINNED
19+
@location(4) joint_indexes: vec4<u32>,
20+
@location(5) joint_weights: vec4<f32>,
21+
#endif
22+
};
23+
24+
struct VertexOutput {
25+
@builtin(position) clip_position: vec4<f32>,
26+
};
27+
28+
@vertex
29+
fn vertex(vertex: Vertex) -> VertexOutput {
30+
#ifdef SKINNED
31+
let model = skin_model(vertex.joint_indexes, vertex.joint_weights);
32+
#else
33+
let model = mesh.model;
34+
#endif
35+
36+
var out: VertexOutput;
37+
out.clip_position = mesh_position_local_to_clip(model, vec4<f32>(vertex.position, 1.0));
38+
return out;
39+
}
40+
141
@fragment
2-
fn fragment(
3-
#import bevy_pbr::mesh_vertex_output
4-
) -> @location(0) vec4<f32> {
42+
fn fragment() -> @location(0) vec4<f32> {
543
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
644
}

crates/bevy_pbr/src/wireframe.rs

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ fn apply_global(
110110
struct WireframeMaterial {}
111111

112112
impl Material for WireframeMaterial {
113+
fn vertex_shader() -> ShaderRef {
114+
WIREFRAME_SHADER_HANDLE.typed().into()
115+
}
116+
113117
fn fragment_shader() -> ShaderRef {
114118
WIREFRAME_SHADER_HANDLE.typed().into()
115119
}

0 commit comments

Comments
 (0)