A lightweight Clip Studio Paint alternative with real-time multiplayer collaborative drawing. Built with Tauri and React.
TypeScript animationcartoonclip-studio-paintcollaborativedesktop-appdigital-paintingdrawing-appillustrationmangamultiplayeropen-sourcerusttaurithreejswebglwebtoon
//! Document-space solid polygon WGSL shader for Comic Frame Border Folders (`frame-folder`).
//!
//! Renders triangulated polygon interiors (into the frame clip mask and optional panel
//! background fill) and mitered panel border strokes strictly clipped to `[0, doc_size]`
//! so off-canvas manga bleed (*tachikiri*) frames never spill onto the pasteboard.
pub const FRAME_POLY_SHADER_WGSL: &str = r#"
struct FramePolyUniforms {
viewport_size_phys: vec2<f32>,
doc_size: vec2<f32>,
pan_css: vec2<f32>,
zoom: f32,
rotation_rad: f32,
flip: vec2<f32>,
dpr: f32,
_pad: f32,
color: vec4<f32>,
};
@group(0) @binding(0) var<uniform> u: FramePolyUniforms;
struct VsIn {
@location(0) doc_pos: vec2<f32>,
};
struct VsOut {
@builtin(position) pos: vec4<f32>,
@location(0) doc_pos: vec2<f32>,
};
@vertex
fn vs_main(in: VsIn) -> VsOut {
let centered = (in.doc_pos - u.doc_size * 0.5) * u.flip;
let cos_r = cos(u.rotation_rad);
let sin_r = sin(u.rotation_rad);
let rotated = vec2<f32>(
centered.x * cos_r - centered.y * sin_r,
centered.x * sin_r + centered.y * cos_r,
);
let screen_phys = (u.pan_css + rotated * u.zoom) * u.dpr;
let ndc = vec2<f32>(
(2.0 * screen_phys.x / max(1.0, u.viewport_size_phys.x)) - 1.0,
1.0 - (2.0 * screen_phys.y / max(1.0, u.viewport_size_phys.y)),
);
var out: VsOut;
out.pos = vec4<f32>(ndc, 0.0, 1.0);
out.doc_pos = in.doc_pos;
return out;
}
@fragment
fn fs_main(in: VsOut) -> @location(0) vec4<f32> {
if (
in.doc_pos.x < 0.0 ||
in.doc_pos.y < 0.0 ||
in.doc_pos.x > u.doc_size.x ||
in.doc_pos.y > u.doc_size.y
) {
discard;
}
return vec4<f32>(u.color.rgb * u.color.a, u.color.a);
}
"#;