Add graphical CCS Cases 2 prototype
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform float patient_scale : hint_range(0.4, 1.0) = 0.82;
|
||||
uniform vec2 anchor = vec2(0.5, 0.985);
|
||||
uniform vec2 patient_offset = vec2(0.0, 0.0);
|
||||
uniform float breathing_speed : hint_range(0.5, 3.0) = 1.0;
|
||||
uniform float breathing_amount : hint_range(0.0, 0.03) = 0.012;
|
||||
uniform float blink_amount : hint_range(0.0, 1.0) = 0.0;
|
||||
|
||||
void fragment() {
|
||||
// Size the patient around his original centerline, then lower the complete
|
||||
// seated pose until the knee crease meets the front edge of the cushion.
|
||||
vec2 source_uv = (UV - anchor - patient_offset) / patient_scale + anchor;
|
||||
|
||||
// Deform only the upper body so his hips, knees, and contact with the bench
|
||||
// remain perfectly still. Two slow, slightly different cycles prevent the
|
||||
// idle from reading as a mechanical scale pulse.
|
||||
float torso_mask = smoothstep(0.13, 0.25, source_uv.y)
|
||||
* (1.0 - smoothstep(0.48, 0.58, source_uv.y));
|
||||
float breath = 0.5 + 0.5 * sin(TIME * breathing_speed * 1.75);
|
||||
float chest_scale = 1.0 + breathing_amount * breath * torso_mask;
|
||||
source_uv.x = 0.5 + (source_uv.x - 0.5) / chest_scale;
|
||||
source_uv.y = 0.37 + (source_uv.y - 0.37) / (1.0 + breathing_amount * 0.45 * breath * torso_mask);
|
||||
float upper_body_mask = 1.0 - smoothstep(0.50, 0.62, source_uv.y);
|
||||
source_uv.x -= sin(TIME * breathing_speed * 0.63) * 0.0015 * upper_body_mask;
|
||||
if (source_uv.x < 0.0 || source_uv.x > 1.0 || source_uv.y < 0.0 || source_uv.y > 1.0) {
|
||||
COLOR = vec4(0.0);
|
||||
} else {
|
||||
vec4 patient_color = texture(TEXTURE, source_uv);
|
||||
|
||||
// Cover each eye with color sampled from the lower eyelid, then retain a
|
||||
// narrow crease at full closure. Coordinates are in the canonical patient
|
||||
// texture, so scaling and positioning do not disturb the blink placement.
|
||||
vec2 eye_size = vec2(0.0105, 0.0065);
|
||||
vec2 left_eye_delta = (source_uv - vec2(0.4835, 0.1125)) / eye_size;
|
||||
vec2 right_eye_delta = (source_uv - vec2(0.5165, 0.1125)) / eye_size;
|
||||
float left_eye = 1.0 - smoothstep(0.72, 1.0, length(left_eye_delta));
|
||||
float right_eye = 1.0 - smoothstep(0.72, 1.0, length(right_eye_delta));
|
||||
float eye_mask = max(left_eye, right_eye) * blink_amount;
|
||||
vec3 lid_color = texture(TEXTURE, source_uv + vec2(0.0, 0.009)).rgb;
|
||||
patient_color.rgb = mix(patient_color.rgb, lid_color, eye_mask);
|
||||
|
||||
float horizontal_extent = max(
|
||||
1.0 - smoothstep(0.65, 1.0, abs(left_eye_delta.x)),
|
||||
1.0 - smoothstep(0.65, 1.0, abs(right_eye_delta.x))
|
||||
);
|
||||
float crease = (1.0 - smoothstep(0.0, 0.24, min(
|
||||
abs(left_eye_delta.y), abs(right_eye_delta.y)
|
||||
))) * horizontal_extent * blink_amount;
|
||||
patient_color.rgb = mix(patient_color.rgb, lid_color * 0.58, crease * 0.72);
|
||||
COLOR = patient_color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://l06nw4ake0q
|
||||
@@ -0,0 +1,42 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D tex : repeat_enable;
|
||||
uniform float n_rows = 6.0;
|
||||
uniform float y_offset = 0.0;
|
||||
uniform float x_offset = 0.0;
|
||||
uniform float win_intensity : hint_range(0.0, 1.0) = 0.0;
|
||||
uniform vec4 win_glow_color : source_color = vec4(1.0, 0.62, 0.08, 1.0);
|
||||
|
||||
void fragment() {
|
||||
vec2 uv = UV;
|
||||
uv.x += x_offset;
|
||||
uv.y /= n_rows;
|
||||
uv.y += y_offset;
|
||||
|
||||
vec4 base = texture(tex, uv);
|
||||
if (win_intensity <= 0.001) {
|
||||
COLOR = base;
|
||||
} else {
|
||||
// Derive a compact halo from the existing symbol alpha so no replacement
|
||||
// sprite or second texture is needed.
|
||||
vec2 pixel = 1.0 / vec2(textureSize(tex, 0));
|
||||
vec2 radius = pixel * 5.0;
|
||||
float nearby_alpha = 0.0;
|
||||
nearby_alpha = max(nearby_alpha, texture(tex, uv + vec2(radius.x, 0.0)).a);
|
||||
nearby_alpha = max(nearby_alpha, texture(tex, uv - vec2(radius.x, 0.0)).a);
|
||||
nearby_alpha = max(nearby_alpha, texture(tex, uv + vec2(0.0, radius.y)).a);
|
||||
nearby_alpha = max(nearby_alpha, texture(tex, uv - vec2(0.0, radius.y)).a);
|
||||
nearby_alpha = max(nearby_alpha, texture(tex, uv + radius).a);
|
||||
nearby_alpha = max(nearby_alpha, texture(tex, uv - radius).a);
|
||||
nearby_alpha = max(nearby_alpha, texture(tex, uv + vec2(radius.x, -radius.y)).a);
|
||||
nearby_alpha = max(nearby_alpha, texture(tex, uv + vec2(-radius.x, radius.y)).a);
|
||||
|
||||
float halo = max(nearby_alpha - base.a, 0.0) * win_intensity;
|
||||
float flash = smoothstep(0.82, 1.0, win_intensity);
|
||||
vec3 rich_color = min(base.rgb * 1.18 + win_glow_color.rgb * 0.12, vec3(1.0));
|
||||
vec3 symbol_color = mix(base.rgb, rich_color, win_intensity);
|
||||
symbol_color = mix(symbol_color, vec3(1.0), flash * 0.34 * base.a);
|
||||
vec3 final_rgb = symbol_color * base.a + win_glow_color.rgb * halo;
|
||||
COLOR = vec4(final_rgb, max(base.a, halo * 0.9));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://l6j3wkyf1ygq
|
||||
Reference in New Issue
Block a user