diff --git a/src/render/draw_atmosphere.js b/src/render/draw_atmosphere.js index 7ebbe8cd650..029d34f78e5 100644 --- a/src/render/draw_atmosphere.js +++ b/src/render/draw_atmosphere.js @@ -64,13 +64,6 @@ function drawAtmosphere(painter: Painter) { skyColor.a ]; const spaceColor = fog.properties.get('space-color'); - const spaceColorUnpremultiplied = [ - spaceColor.a === 0.0 ? 0 : spaceColor.r / spaceColor.a, - spaceColor.a === 0.0 ? 0 : spaceColor.g / spaceColor.a, - spaceColor.a === 0.0 ? 0 : spaceColor.b / spaceColor.a, - spaceColor.a - ]; - const temporalOffset = (painter.frameCounter / 1000.0) % 1; const latlon = [ degToRad(transform._center.lat) / (Math.PI * 0.5), @@ -90,7 +83,7 @@ function drawAtmosphere(painter: Painter) { fog.properties.get('horizon-blend'), fogColorUnpremultiplied, skyColorUnpremultiplied, - spaceColorUnpremultiplied, + [spaceColor.r, spaceColor.g, spaceColor.b, spaceColor.a], latlon, starIntensity, temporalOffset); diff --git a/src/shaders/atmosphere.fragment.glsl b/src/shaders/atmosphere.fragment.glsl index 3173ea2565d..c801f49cc1f 100644 --- a/src/shaders/atmosphere.fragment.glsl +++ b/src/shaders/atmosphere.fragment.glsl @@ -61,16 +61,14 @@ void main() { vec3 c1 = mix(c0, color_stop_0, alpha_0); vec3 c2 = mix(c0, c1, t); vec3 c3 = mix(color_stop_2, c2, t); - - vec3 color = c2 * t + c3 * (1.0 - t); + vec3 c = mix(c3, c2, t); // Blend alphas float a0 = mix(alpha_2, 1.0, alpha_1); float a1 = mix(a0, 1.0, alpha_0); float a2 = mix(a0, a1, t); float a3 = mix(alpha_2, a2, t); - - float composited_alpha = a2 * t + a3 * (1.0 - t); + float a = mix(a3, a2, t); vec2 uv = (gl_FragCoord.xy / u_viewport) * (2.0 - 1.0); vec3 D = vec3(uv + vec2(-u_latlon.y, -u_latlon.x), 1.0); @@ -89,10 +87,10 @@ void main() { star_field *= (1.0 - pow(t, 0.25 + (1.0 - u_sky_color.a) * 0.75)); // Additive star field - color = color + star_field * alpha_2; + c = c + star_field * alpha_2; // Dither - color = dither(color, gl_FragCoord.xy + u_temporal_offset); + c = dither(c, gl_FragCoord.xy + u_temporal_offset); - gl_FragColor = vec4(color, composited_alpha); + gl_FragColor = vec4(c, a); }