hyperboloid/src/mesh.wgsl
2026-07-20 04:24:05 +03:00

28 lines
509 B
WebGPU Shading Language

struct LookParams {
m: mat4x4f,
}
struct Vertex {
@location(0) position: vec3f,
@location(1) normal: vec3f,
}
struct Varying {
@builtin(position) screen: vec4f,
@location(0) normal: vec3f,
}
@group(0) @binding(0) var<uniform> look: LookParams;
@vertex
fn on_vertex(in: Vertex) -> Varying {
let pos = look.m * vec4f(in.position, 1.0);
let normal = in.normal;
return Varying(pos, normal);
}
@fragment
fn on_fragment(in: Varying) -> @location(0) vec4f {
return vec4f(0.5 + 0.5 * in.normal, 1.0);
}