Files

27 lines
1.7 KiB
Plaintext

shader_type sky;
// Original painted panorama; no volume or per-frame sky pass.
uniform sampler2D painted_panorama : source_color, filter_linear_mipmap, repeat_enable;
uniform vec3 sky_top_color : source_color = vec3(0.12, 0.49, 0.69);
uniform vec3 sky_horizon_color : source_color = vec3(0.65, 0.84, 0.84);
uniform vec3 ground_bottom_color : source_color = vec3(0.12, 0.17, 0.12);
uniform vec3 ground_horizon_color : source_color = vec3(0.65, 0.84, 0.84);
uniform float daylight : hint_range(0.0, 1.0) = 1.0;
uniform float golden_hour : hint_range(0.0, 1.0) = 0.0;
void sky() {
float height = max(EYEDIR.y, 0.0);
vec3 sky_gradient = mix(sky_horizon_color, sky_top_color, pow(height, 0.45));
// Art horizon is at 69% of the sheet. Remap only the upper hemisphere;
// the ground bounce uses the day/night palette and never paints terrain.
vec2 panorama_uv = vec2(fract(SKY_COORDS.x * 2.0 + 0.40), clamp((SKY_COORDS.y - 0.26) * 2.875, 0.0, 0.69));
vec3 painted = texture(painted_panorama, panorama_uv).rgb;
vec3 seam_color = (texture(painted_panorama, vec2(0.001, panorama_uv.y)).rgb + texture(painted_panorama, vec2(0.999, panorama_uv.y)).rgb) * 0.5;
painted = mix(seam_color, painted, smoothstep(0.0, 0.025, min(panorama_uv.x, 1.0 - panorama_uv.x)));
painted = mix(painted, painted * vec3(1.18, 0.79, 0.66), golden_hour * 0.50);
vec3 night_paint = painted * vec3(0.045, 0.07, 0.14) + sky_gradient * 0.12;
vec3 sky_color = mix(night_paint, painted, daylight);
// Dissolve the panorama edge into the haze at the actual horizon.
sky_color = mix(sky_gradient, sky_color, smoothstep(0.0, 0.075, height));
COLOR = EYEDIR.y >= 0.0 ? sky_color : mix(ground_horizon_color, ground_bottom_color, pow(-EYEDIR.y, 0.4));
}