atmosphere: simulate Earth-Sun distance for solar irradiance
This commit is contained in:
1 parent
185d9d2ff4
commit
629b1b6ab2
2 files changed
+15
No files matched your search
Vendored
+14
@@ -2484,6 +2484,18 @@ function beamLuma(altRad) {
|
||||
var c = beamColor(altRad);
|
||||
return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
|
||||
}
|
||||
// Earth-Sun distance from the simulated scene date. This is not a scene
|
||||
// light source: it only scales the solar irradiance entering the top of
|
||||
// the atmosphere (perihelion ~+3.4 %, aphelion ~-3.3 %).
|
||||
function sunDistanceFactor(date) {
|
||||
var d = date || new Date();
|
||||
var year = d.getUTCFullYear();
|
||||
var start = Date.UTC(year, 0, 0);
|
||||
var day = Math.floor((d.getTime() - start) / 86400000);
|
||||
var g = 2 * Math.PI * (day - 3) / 365.24;
|
||||
var au = 1.0 - 0.0167 * Math.cos(g);
|
||||
return 1.0 / (au * au);
|
||||
}
|
||||
// Diffuse skylight: grows with sun altitude, then decays through civil
|
||||
// twilight (-6 deg) toward the night floor (airglow + starlight).
|
||||
function skyAmbient(altRad) {
|
||||
@@ -5418,6 +5430,8 @@ window.clouds3dRender = function(target) {
|
||||
? window.__currentMoonDir[1] : 0)));
|
||||
var _moonFrac = (typeof window.__currentMoonFrac === 'number') ? window.__currentMoonFrac : 0.6;
|
||||
var _beam = beamColor(sunAlt), _beamL = beamLuma(sunAlt);
|
||||
var _sunDist = sunDistanceFactor(window.__currentSceneDate);
|
||||
_beamL *= _sunDist;
|
||||
var _star = starAmbient(sunAlt);
|
||||
var _mBeam = beamColor(_moonAlt), _mL = beamLuma(_moonAlt);
|
||||
var _moonUp = Math.max(0, Math.sin(_moonAlt));
|
||||
|
||||
Reference in new issue
Block a user