43 lines
828 B
WebGPU Shading Language
43 lines
828 B
WebGPU Shading Language
struct Configuration {
|
|
viewProj: mat4x4f,
|
|
lightViewProj: mat4x4f,
|
|
lightPosition: vec4f,
|
|
eyePosition: vec4f,
|
|
};
|
|
|
|
@group(0) @binding(0) var<uniform> config: Configuration;
|
|
|
|
struct VertexInput {
|
|
@builtin(vertex_index) vertex_index: u32,
|
|
};
|
|
|
|
struct VertexOutput {
|
|
@builtin(position) position: vec4f,
|
|
@location(0) texture: vec2f,
|
|
};
|
|
|
|
const vertices = array(
|
|
vec2f(1.0, 0.0),
|
|
vec2f(0.0, 1.0),
|
|
vec2f(0.0, 0.0),
|
|
vec2f(1.0, 1.0),
|
|
);
|
|
|
|
@vertex
|
|
fn vertexMain(input: VertexInput) -> VertexOutput
|
|
{
|
|
let texture = vertices[input.vertex_index];
|
|
let position = vec4f(texture * 2.0 - 1.0, 0.0, 1.0);
|
|
|
|
var output: VertexOutput;
|
|
output.position = position;
|
|
output.texture = texture;
|
|
return output;
|
|
}
|
|
|
|
@fragment
|
|
fn fragmentMain(input: VertexOutput) -> @location(0) vec4f
|
|
{
|
|
return vec4(input.texture, 0.0, 1.0);
|
|
}
|