facett-graph3d/src/logo3d/logo.wgsl
// 3D znippy rabbit logo — yaw/tilt rotation + Lambert shading against the theme
// accent. Matches `Uniforms` / `Vertex` in gpu.rs.
struct Uniforms {
yaw: f32,
tilt: f32,
scale: f32,
_pad0: f32,
accent: vec3<f32>,
_pad1: f32,
};
@group(0) @binding(0) var<uniform> U: Uniforms;
struct VsIn {
@location(0) pos: vec3<f32>,
@location(1) nrm: vec3<f32>,
};
struct VsOut {
@builtin(position) clip: vec4<f32>,
@location(0) nrm: vec3<f32>,
};
fn rotate(p: vec3<f32>) -> vec3<f32> {
let cy = cos(U.yaw);
let sy = sin(U.yaw);
let x1 = p.x * cy + p.z * sy;
let z1 = -p.x * sy + p.z * cy;
let ct = cos(U.tilt);
let st = sin(U.tilt);
let y2 = p.y * ct - z1 * st;
let z2 = p.y * st + z1 * ct;
return vec3<f32>(x1, y2, z2);
}
@vertex
fn vs(in: VsIn) -> VsOut {
var out: VsOut;
let rp = rotate(in.pos) * U.scale;
// Map design-space y-up to clip-space (y up), push z into [0,1] depth.
out.clip = vec4<f32>(rp.x, rp.y, rp.z * 0.5 + 0.5, 1.0);
out.nrm = rotate(in.nrm);
return out;
}
@fragment
fn fs(in: VsOut) -> @location(0) vec4<f32> {
let light = normalize(vec3<f32>(-0.4, 0.6, 0.7));
let n = normalize(in.nrm);
let diff = max(dot(n, light), 0.0);
let shade = clamp(0.28 + 0.72 * diff, 0.0, 1.0);
return vec4<f32>(U.accent * shade, 1.0);
}