getting closer to a cube
This commit is contained in:
27
shaders/cube.wgsl
Normal file
27
shaders/cube.wgsl
Normal file
@@ -0,0 +1,27 @@
|
||||
struct VertexOutput {
|
||||
@location(0) color: vec3<f32>,
|
||||
@builtin(position) position: vec4<f32>
|
||||
};
|
||||
|
||||
struct Locals {
|
||||
transform: mat4x4<f32>
|
||||
};
|
||||
|
||||
@group(0) @binding(0)
|
||||
var r_locals: Locals;
|
||||
|
||||
@vertex
|
||||
fn vs_main(
|
||||
@location(0) position: vec4<f32>,
|
||||
@location(1) color: vec3<f32>,
|
||||
) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
out.color = color;
|
||||
out.position = r_locals.transform * position;
|
||||
return out;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(in.color.r, in.color.g, in.color.b, 1.0);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
@vertex
|
||||
fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4<f32> {
|
||||
let x = f32(i32(in_vertex_index) - 1);
|
||||
let y = f32(i32(in_vertex_index & 1u) * 2 - 1);
|
||||
return vec4<f32>(x, y, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user