-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shader WGSL example - split single shader into vertex and fragment (#…
…7310) Co-authored-by: Martin Valigursky <[email protected]>
- Loading branch information
1 parent
3b12d5e
commit a354950
Showing
3 changed files
with
30 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
examples/src/examples/graphics/wgsl-shader.shader.vert.wgsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
struct ub_mesh { | ||
matrix_model : mat4x4f, | ||
amount : f32, | ||
} | ||
|
||
struct ub_view { | ||
matrix_viewProjection : mat4x4f, | ||
} | ||
|
||
struct VertexOutput { | ||
@builtin(position) position : vec4f, | ||
@location(0) fragPosition: vec4f, | ||
} | ||
|
||
@group(2) @binding(0) var<uniform> uvMesh : ub_mesh; | ||
@group(0) @binding(0) var<uniform> ubView : ub_view; | ||
|
||
struct VertexInput { | ||
@location(0) position : vec4f, | ||
} | ||
|
||
@vertex | ||
fn vertexMain(input : VertexInput) -> VertexOutput { | ||
var output : VertexOutput; | ||
output.position = ubView.matrix_viewProjection * (uvMesh.matrix_model * input.position); | ||
output.fragPosition = 0.5 * (input.position + vec4(1.0)); | ||
return output; | ||
} |