Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1// `custom_phase_item.wgsl`
2//
3// This shader goes with the `custom_phase_item` example. It demonstrates how to
4// enqueue custom rendering logic in a `RenderPhase`.
6// The GPU-side vertex structure.
7struct Vertex {
8 // The world-space position of the vertex.
9 @location(0) position: vec3<f32>,
10 // The color of the vertex.
11 @location(1) color: vec3<f32>,
12};
14// Information passed from the vertex shader to the fragment shader.
15struct VertexOutput {
16 // The clip-space position of the vertex.
17 @builtin(position) clip_position: vec4<f32>,
18 // The color of the vertex.
19 @location(0) color: vec3<f32>,
20};
22// The vertex shader entry point.
23@vertex
24fn vertex(vertex: Vertex) -> VertexOutput {
25 // Use an orthographic projection.
26 var vertex_output: VertexOutput;
27 vertex_output.clip_position = vec4(vertex.position.xyz, 1.0);
28 vertex_output.color = vertex.color;
29 return vertex_output;
32// The fragment shader entry point.
33@fragment
34fn fragment(vertex_output: VertexOutput) -> @location(0) vec4<f32> {
35 return vec4(vertex_output.color, 1.0);
Contents