uniform vec3 horiz_color, mid_color, zenith_color, fog_color; const float mid_point = 0.25; const float horiz_scale = 20.0; vec3 sky_grad(float t, float mid); float pnoise(float p, float rep); float fbm(float p, int octaves, float rep); void main() { float tx = gl_TexCoord[0].x; float ty = 1.0 - gl_TexCoord[0].y; vec3 color = sky_grad(ty, mid_point); float horiz = ty + fbm(tx * horiz_scale, 4, horiz_scale) * 0.035; color = mix(fog_color, color, smoothstep(0.034, 0.035, horiz)); gl_FragColor.rgb = color; gl_FragColor.a = 1.0; } vec3 sky_grad(float t, float mid) { float t_low = min(t / mid, 1.0); float t_high = min((1.0 - t) / (1.0 - mid), 1.0); return mix(zenith_color, mix(horiz_color, mid_color, t_low), t_high); } float pnoise(vec2 p, vec2 rep); float pnoise(float p, float rep) { return pnoise(vec2(p, 0.0), vec2(rep, rep)); } float fbm(float p, int octaves, float rep) { float res = 0.0; float freq = 1.0; float scale = 1.0; for(int i=0; i