rust-game-engine/shaders/cube.wgsl

27 lines
559 B
WebGPU Shading Language
Raw Normal View History

2023-09-27 22:29:29 +02:00
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);
}