Copenhagen to JFK
On a recent trip to Greece I ended up on a flight back to New York via Copenhagen that took off at 3 PM. Flying west, the sky was in this beautiful partial sunset almost the entire flight where the horizon was at sunset but the rest of the sky was still a vibrant blue. I ended up with a window seat and passed the time by making a quick shader painting of the view.
The code is below. This one is simple: it’s just gradients and some noise for the clouds, both of which are slowly moving. I originally had masked it with an ellipse to show the airplane window but I like it better without it. No need to restrict the view in my fantasy memory flight.
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
float rand(vec2 n) {
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
}
float noise(vec2 p) {
vec2 ip = floor(p);
vec2 u = fract(p);
u = u*u*(3.0-2.0*u);
float res = mix(
mix(rand(ip),rand(ip+vec2(1.0,0.0)),u.x),
mix(rand(ip+vec2(0.0,1.0)),rand(ip+vec2(1.0,1.0)),u.x),u.y);
return res*res;
}
void main() {
vec2 st = gl_FragCoord.xy / u_resolution.xy;
// Blue sky
vec3 color = mix(vec3(0.7765, 0.9333, 1.0), vec3(0.0039, 0.6196, 1.0), pow(st.y, 4.));
color *= step(0.5, st.y);
// Sunset
color += vec3(0.9843, 0.702, 0.3569) * (smoothstep(0.45, 0.48, st.y) - step(0.5, st.y));
// Top layer of clouds
color -= vec3(0.0824, 0.4235, 0.4314) * (smoothstep(0.47, 0.52, st.y + noise(st * 2. - u_time / 5.) * 0.01) - smoothstep(0.5, 0.55, st.y - noise(st * 2. + u_time / 5.) * 0.01));
// Bottom layer of clouds
color += mix(vec3(0.2, 0.1725, 0.2549), vec3(0.9843, 0.702, 0.3569), noise(st * 15. + vec2(u_time * 0.3)) * 0.07) * (1.0 - step(0.5, st.y));
gl_FragColor = vec4(color, 1.0);
}