daily update

This commit is contained in:
lennlouisgeek
2026-06-28 23:07:10 +08:00
parent b3fa3c8341
commit f74d8e5013
14 changed files with 623 additions and 357 deletions

View File

@@ -336,7 +336,6 @@ fn fs_glyph(in: GlyphVertexOutput) -> @location(0) vec4f {
return output_color(color, alpha);
}
// dot
struct DotVertexInput {
@location(0) local: vec2f,
@@ -358,12 +357,71 @@ fn circle_alpha(local: vec2f, radius: f32, softness: f32) -> f32 {
return 1.0 - smoothstep(radius, radius + softness, dist);
}
// Convert a point authored in hand.png UV space into clip space.
// This mirrors fs_hand_image's aspect-fit math, so fingertip dots stay attached
// to the same image pixels when the app window changes shape.
fn hand_image_uv_to_clip(image_uv: vec2f) -> vec2f {
let viewport_aspect = u.viewport.x / max(u.viewport.y, 1.0);
let image_aspect = u.image.x / max(u.image.y, 1.0);
var screen_uv = image_uv;
if (viewport_aspect > image_aspect) {
let image_width = image_aspect / viewport_aspect;
screen_uv.x = image_uv.x * image_width + (1.0 - image_width) * 0.5;
} else {
let image_height = viewport_aspect / image_aspect;
screen_uv.y = image_uv.y * image_height + (1.0 - image_height) * 0.5;
}
return vec2f(screen_uv.x * 2.0 - 1.0, 1.0 - screen_uv.y * 2.0);
}
@vertex
fn vs_hand_dot(vertex: DotVertexInput, instance: DotInstanceInput) -> DotVertexOutput {
let intensity = saturate(instance.style.x);
let shaped = smoothstep(0.0, 1.0, intensity);
// Hand instances store hand.png UV in world_position.xy instead of 3D world space.
let center = hand_image_uv_to_clip(instance.world_position.xy);
// Hand fingertip matrices are much smaller than the full Finger view.
// Keep each bead below the local cell spacing so the 12x7 matrix remains visibly separated.
let pixel_size = u.glyph.x * mix(0.38, 0.56, shaped);
let ndc_offset = vertex.local * vec2f(pixel_size / u.viewport.x, pixel_size / u.viewport.y) * 2.0;
var out: DotVertexOutput;
out.clip_position = vec4f(center + ndc_offset, 0.0, 1.0);
out.local = vertex.local;
out.intensity = intensity;
return out;
}
@fragment
fn fs_hand_dot(in: DotVertexOutput) -> @location(0) vec4f {
let intensity = saturate(in.intensity);
// Use a compact round bead instead of the larger Finger-mode glow marker.
let core = circle_alpha(in.local, 0.56, 0.08);
let halo = circle_alpha(in.local, 0.78, 0.14) * 0.16;
// Keep the fingertip matrix visually close to JE-Skin's cyan model dots,
// while still letting pressure brighten the bead a little.
let cyan = vec3f(0.34, 0.86, 1.0);
let hot = sample_range_color(intensity);
let color = mix(cyan, hot, 0.22) * mix(0.88, 1.18, intensity);
return output_color(color, max(core, halo));
}
@vertex
fn vs_dot(vertex: DotVertexInput, instance: DotInstanceInput) -> DotVertexOutput {
let center = u.view_proj * vec4f(instance.world_position.xyz, 1.0);
let intensity = saturate(instance.style.x);
let shaped = pow(intensity, 0.9);
let pixel_size = u.glyph.x * mix(0.72, 1.85, shaped);
let shaped = smoothstep(0.0, 1.0, intensity);
let pixel_size = u.glyph.x * mix(1.07, 2.23, shaped);
let ndc_offset = vertex.local * vec2f(pixel_size / u.viewport.x, pixel_size / u.viewport.y) * 2.0;
var out: DotVertexOutput;
out.clip_position = vec4f(center.xy + ndc_offset * center.w, center.z, center.w);
@@ -379,7 +437,7 @@ fn fs_dot(in: DotVertexOutput) -> @location(0) vec4f {
let core = circle_alpha(in.local, 0.42, 0.055);
let glow = circle_alpha(in.local, 0.78, 0.18) * intensity * 0.45;
let glow = circle_alpha(in.local, 0.92, 0.20) * intensity * 0.32;
let highlight_pos = in.local - vec2f(-0.18, 0.20);