Files
OneCAD-Draft/src/shaders/viewcube_text.wgsl
T
Hakan Seven 53cf31f33d feat(web): unify fonts and refine viewcube
Preload one language-aware font resource across the interface, drawing text, and navigation labels.\n\nRender the navigation cube, ring, outlines, and labels through a 4x MSAA target.
2026-08-03 15:28:51 +03:00

40 lines
929 B
WebGPU Shading Language

struct Uniforms {
screen: vec2<f32>,
_pad: vec2<f32>,
};
@group(0) @binding(0) var<uniform> u: Uniforms;
@group(0) @binding(1) var samp: sampler;
@group(0) @binding(2) var tex: texture_2d<f32>;
struct VsIn {
@location(0) pos: vec3<f32>,
@location(1) uv: vec2<f32>,
@location(2) color: vec4<f32>,
};
struct VsOut {
@builtin(position) pos: vec4<f32>,
@location(0) uv: vec2<f32>,
@location(1) color: vec4<f32>,
};
@vertex
fn vs_main(input: VsIn) -> VsOut {
var out: VsOut;
let ndc = vec2<f32>(
(input.pos.x / u.screen.x) * 2.0 - 1.0,
1.0 - (input.pos.y / u.screen.y) * 2.0
);
out.pos = vec4<f32>(ndc, input.pos.z, 1.0);
out.uv = input.uv;
out.color = input.color;
return out;
}
@fragment
fn fs_main(input: VsOut) -> @location(0) vec4<f32> {
let a = textureSample(tex, samp, input.uv).r;
return vec4<f32>(input.color.rgb, input.color.a * a);
}