Amiga Like effect
Log in to post a comment.
#version 300 es precision highp float; uniform float iTime; uniform vec2 iResolution; out vec4 fragColor; float noise(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123); } float smoothNoise(vec2 p) { vec2 i = floor(p); vec2 f = fract(p); float a = noise(i + vec2(0.0,0.0)); float b = noise(i + vec2(1.0,0.0)); float c = noise(i + vec2(0.0,1.0)); float d = noise(i + vec2(1.0,1.0)); 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; } void main() { vec2 uv = gl_FragCoord.xy / iResolution.xy; uv = (uv - 0.5) * vec2(iResolution.x / iResolution.y, 1.0); uv *= 32.0; float time = iTime * 0.6; // faster light movement // Height map float h = smoothNoise(uv + vec2(0.0, time * 0.2)); // Approximate normal float eps = 0.01; float hx = smoothNoise(uv + vec2(eps, 0.0) + vec2(0.0, time * 0.2)); float hy = smoothNoise(uv + vec2(0.0, eps) + vec2(0.0, time * 0.2)); vec3 n = normalize(vec3(h - hx, h - hy, eps)); // Light and view directions vec3 lightDir = normalize(vec3(sin(time * 2.0) * 1.0, cos(time * 1.7) * 1.0, 1.5)); // faster swing vec3 viewDir = normalize(vec3(0.0, 0.0, 1.0)); // viewing from above // Diffuse lighting float diff = max(dot(n, lightDir), 0.0); // Specular (Blinn-Phong) vec3 halfDir = normalize(lightDir + viewDir); float spec = pow(max(dot(n, halfDir), 0.0), 50.0); // higher exponent = sharper highlight // Base color vec3 baseColor = mix(vec3(0.2, 0.2, 0.3), vec3(0.9, 0.85, 0.7), h); // Combine lighting vec3 color = baseColor * diff + vec3(1.0) * spec * 0.8; fragColor = vec4(color, 1.0); }