Skip to content

Commit dddcd68

Browse files
committed
fix: atmosphere and night side rendering tuning
Atmosphere: - Increase day color blue saturation (0.25,0.58→0.15,0.45) - Limb whitening only without bloom (bloom washes out naturally) - Add limbWhitening uniform gated by bloom state Earth shader: - Crush dark night texture floor with bloom on (70% floor, 0.1–0.3 threshold) to counteract bloom lifting ocean noise and satellite pass artifacts - Boost rim scatter intensity ×1.4 with wider falloff (pow 4.0→3.5) - Match rim scatter color to new saturated atmosphere blue
1 parent 01177ca commit dddcd68

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/scene/atmosphere.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void main() {
1616
const ATMO_FRAG = `
1717
uniform vec3 sunDir;
1818
uniform float atmosphereStrength;
19+
uniform float limbWhitening;
1920
2021
varying vec3 vWorldNormal;
2122
varying vec3 vViewDir;
@@ -31,13 +32,13 @@ void main() {
3132
float VdotL = dot(vViewDir, sunDir);
3233
3334
// Sunset shift near terminator
34-
vec3 dayColor = vec3(0.25, 0.58, 1.0);
35+
vec3 dayColor = vec3(0.15, 0.45, 1.0);
3536
vec3 sunsetColor = vec3(1.0, 0.5, 0.2);
3637
float sunsetBlend = smoothstep(0.35, -0.15, NdotL);
3738
vec3 atmosColor = mix(dayColor, sunsetColor, sunsetBlend);
3839
3940
// Limb whitening — thicker atmosphere at edges shifts toward blue-white
40-
atmosColor = mix(atmosColor, vec3(0.7, 0.85, 1.0), pow(fresnel, 1.5) * 0.7);
41+
atmosColor = mix(atmosColor, vec3(0.7, 0.85, 1.0), pow(fresnel, 1.5) * 0.7 * limbWhitening);
4142
4243
// Forward-scatter glow when looking toward the sun through the limb
4344
float forwardGlow = pow(max(VdotL, 0.0), 8.0) * 0.15;
@@ -66,6 +67,7 @@ export class Atmosphere {
6667
uniforms: {
6768
sunDir: { value: new THREE.Vector3(1, 0, 0) },
6869
atmosphereStrength: { value: 5.0 },
70+
limbWhitening: { value: 1.0 },
6971
},
7072
vertexShader: ATMO_VERT,
7173
fragmentShader: ATMO_FRAG,
@@ -87,6 +89,7 @@ export class Atmosphere {
8789

8890
setBloomEnabled(on: boolean) {
8991
this.material.uniforms.atmosphereStrength.value = on ? 5.0 : 1.0;
92+
this.material.uniforms.limbWhitening.value = on ? 0.0 : 1.0;
9093
}
9194

9295
setSphereDetail(segments: number) {

src/shaders/earth-daynight.frag.glsl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void main() {
7272

7373
vec4 night = texture2D(nightTexture, vUv, -2.0);
7474
if (nightEmission < 1.01) night.rgb *= 1.0 + smoothstep(0.05, 0.3, night.rgb) * 0.5;
75+
else night.rgb *= mix(vec3(0.7), vec3(1.0), smoothstep(0.1, 0.3, night.rgb));
7576

7677
// Perturb normal with tangent-space normal map (for terminator shading, not eclipse)
7778
vec3 normal = baseNormal;
@@ -166,8 +167,8 @@ void main() {
166167
if (showRimScatter > 0.5) {
167168
vec3 rimViewDir = normalize(viewPos - baseNormal * EARTH_R);
168169
float rimNdotV = max(dot(baseNormal, rimViewDir), 0.0);
169-
float rim = pow(1.0 - rimNdotV, 4.0) * smoothstep(-0.1, 0.3, rawIntensity);
170-
scatteredDay += vec3(0.25, 0.58, 1.0) * rim;
170+
float rim = pow(1.0 - rimNdotV, 3.5) * smoothstep(-0.1, 0.3, rawIntensity);
171+
scatteredDay += vec3(0.15, 0.45, 1.0) * rim * 1.4;
171172
}
172173

173174
// Boost night emission for bloom (HDR values > 1.0)

0 commit comments

Comments
 (0)