Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
karimnaaji committed Mar 18, 2022
1 parent 066fe4f commit bb1902a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
9 changes: 1 addition & 8 deletions src/render/draw_atmosphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions src/shaders/atmosphere.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

0 comments on commit bb1902a

Please sign in to comment.