Amiga Like effect
Log in to post a comment.
#version 300 es
precision highp float;
// Forked from "Plasma" by mintymighty
// https://oneshader.net/shader/7c2e46eb0d
uniform float iTime;
uniform vec2 iResolution;
out vec4 fragColor;
// 2D pseudorandom
float rand(vec2 p){
return fract(sin(dot(p, vec2(127.1,311.7))) * 43758.5453123);
}
// Smooth noise
float noise(vec2 p){
vec2 i = floor(p);
vec2 f = fract(p);
// corners
float a = rand(i + vec2(0.0,0.0));
float b = rand(i + vec2(1.0,0.0));
float c = rand(i + vec2(0.0,1.0));
float d = rand(i + vec2(1.0,1.0));
// smooth interp
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(a, b, u.x) +
(c - a) * u.y * (1.0 - u.x) +
(d - b) * u.x * u.y;
}
// 4-octave fBm
float fbm(vec2 p){
float v = 0.0;
float a = 0.5;
for(int i = 0; i < 4; i++){
v += a * noise(p);
p *= 2.0;
a *= 0.5;
}
return v;
}
// Fire palette: black → red → orange → yellow → white
vec3 firePalette(float t){
if(t < 0.3){
// black to dark red
return mix(vec3(0.0), vec3(0.8, 0.0, 0.0), t/0.3);
}
else if(t < 0.6){
// dark red to orange
return mix(vec3(0.8,0.0,0.0), vec3(1.0,0.6,0.0), (t-0.3)/0.3);
}
else if(t < 0.85){
// orange to yellow
return mix(vec3(1.0,0.6,0.0), vec3(1.0,1.0,0.2), (t-0.6)/0.25);
}
else {
// yellow to white
return mix(vec3(1.0,1.0,0.2), vec3(1.0), (t-0.85)/0.15);
}
}
void main(){
// normalized uv (0 at bottom)
vec2 uv = gl_FragCoord.xy / iResolution.xy;
// stretch vertically to give more “height”
vec2 p = uv * vec2(1.0, 1.5);
// move noise upwards over time, and add a twisting motion
float n = fbm(p * 3.0 - vec2(0.0, iTime * 1.5) +
vec2(sin(iTime*0.5)*0.5, 0.0));
// create a sharp cutoff so fire “dies” toward the top
float cutoff = smoothstep(0.0, 1.0, n - (1.0 - uv.y*1.2));
// optionally boost contrast
float fire = pow(cutoff, 1.5);
// palette lookup
vec3 col = firePalette(fire);
fragColor = vec4(col, 1.0);
}