Rain and more
This commit is contained in:
Binary file not shown.
@@ -35,7 +35,10 @@ void main() {
|
||||
vec2 ps = pc.xy / pc.w * 0.5 + 0.5;
|
||||
vec2 d = (gl_FragCoord.xy * uScreen.zw - ps) * vec2(uScreen.x * uScreen.w, 1.0);
|
||||
float fragDepth = (uViewProj * vec4(v.worldPos, 1.0)).w;
|
||||
float fade = (1.0 - smoothstep(0.07, 0.15, length(d))) * step(fragDepth, pc.w - 1.0);
|
||||
// Only geometry above the sprite's head fades: low walls and trunk bases
|
||||
// stay solid, the player is still readable over them.
|
||||
float aboveHead = smoothstep(uBlob.y + 0.9, uBlob.y + 1.4, v.worldPos.y);
|
||||
float fade = (1.0 - smoothstep(0.07, 0.15, length(d))) * step(fragDepth, pc.w - 1.0) * aboveHead;
|
||||
if (ign(gl_FragCoord.xy) < fade * 0.85) discard;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,25 @@ void main() {
|
||||
fragColor = vec4(vColor.rgb * a, a);
|
||||
return;
|
||||
}
|
||||
if (vKind == 3) { // flame: teardrop eroded by scrolling noise, more as it ages
|
||||
float taper = 1.0 + 0.7 * (p.y * 0.5 + 0.5);
|
||||
float d = length(vec2(p.x * taper, p.y * 0.9 + 0.1));
|
||||
vec2 q = vec2(p.x * 2.5, p.y * 2.0 - uTime * 3.5) + seed * 37.0;
|
||||
float n = vnoise(q) * 0.6 + vnoise(q * 2.3 + 11.0) * 0.4;
|
||||
float shape = 1.0 - smoothstep(0.45, 0.85, d + (n - 0.5) * (0.6 + 0.9 * life));
|
||||
float core = 1.0 - smoothstep(0.0, 0.55, d);
|
||||
float a = shape * vColor.a;
|
||||
// Mostly additive, but each tongue also dims what is behind it a little,
|
||||
// so flames stay saturated orange over bright daytime ground.
|
||||
fragColor = vec4(vColor.rgb * a * (0.7 + 0.8 * core), a * 0.3);
|
||||
if (vKind == 3) {
|
||||
// Flame lick: a soft-topped blob with a crisp, noise-eroded silhouette,
|
||||
// shaded from a hot yellow center to orange and a red rim; it reddens
|
||||
// and erodes as it rises. Nearly opaque (HD-2D fires read as solid,
|
||||
// painterly shapes), emissive HDR so the core blooms.
|
||||
float taper = 1.0 + 0.45 * (p.y * 0.5 + 0.5);
|
||||
float d = length(vec2(p.x * taper, p.y * 0.8 + 0.1));
|
||||
vec2 q = vec2(p.x * 1.8, p.y * 1.5 - uTime * 2.6) + seed * 37.0;
|
||||
float n = vnoise(q) * 0.7 + vnoise(q * 2.4 + 11.0) * 0.3;
|
||||
float e = d + (n - 0.5) * (0.35 + 0.7 * life);
|
||||
float body = 1.0 - smoothstep(0.62, 0.76, e);
|
||||
if (body <= 0.0) discard;
|
||||
// Young licks stay hot right to their rim so the mass merges into one
|
||||
// bright body; only older, higher licks get the red edge.
|
||||
float heat = clamp((1.0 - e / 0.72) * 1.35 + 0.25 * (1.0 - life), 0.0, 1.0) * (1.0 - 0.65 * life);
|
||||
vec3 red = vec3(0.8, 0.1, 0.02), orange = vec3(1.8, 0.5, 0.06), yellow = vec3(2.3, 1.4, 0.32);
|
||||
vec3 c = heat < 0.5 ? mix(red, orange, heat * 2.0) : mix(orange, yellow, heat * 2.0 - 1.0);
|
||||
float a = body * vColor.a;
|
||||
fragColor = vec4(c * vColor.rgb * a, a * 0.92);
|
||||
return;
|
||||
}
|
||||
if (vKind == 4) { // ember
|
||||
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
if (kind == 2 || kind == 4 || kind == 6) extent = 1.0;
|
||||
if (kind == 3) { // flame tongues are taller than wide
|
||||
extent = 1.0;
|
||||
offset *= vec2(1.0, 1.7);
|
||||
offset *= vec2(1.0, 1.3);
|
||||
}
|
||||
if (kind == 5) { // smoke puffs rotate slowly
|
||||
extent = 1.0;
|
||||
|
||||
Reference in New Issue
Block a user