diff --git a/data/shaders/opengl/basesphere_uniforms.glsl b/data/shaders/opengl/basesphere_uniforms.glsl index 0749230aee5..f568facca34 100644 --- a/data/shaders/opengl/basesphere_uniforms.glsl +++ b/data/shaders/opengl/basesphere_uniforms.glsl @@ -26,7 +26,7 @@ layout(std140) uniform BaseSphereData { vec4 atmosColor; vec3 coefficientsR; // coefficients for approximating the Rayleigh contribution vec3 coefficientsM; // coefficients for approximating the Mie contribution - vec2 baricStep; // height for (R, M) in km, at which density will be reduced by e + vec2 scaleHeight; // height for (R, M) in km, at which density will be reduced by e // Eclipse data Eclipse eclipse; diff --git a/data/shaders/opengl/rayleigh.glsl b/data/shaders/opengl/rayleigh.glsl index a14d5e67df3..fc4025a3cb3 100644 --- a/data/shaders/opengl/rayleigh.glsl +++ b/data/shaders/opengl/rayleigh.glsl @@ -10,7 +10,7 @@ void scatter(out vec2 density, const in vec3 orig, const in vec3 center) { float height = height(orig, center); - density = -height / baricStep; + density = -height / scaleHeight; // earth atmospheric density: 1.225 kg/m^3, divided by 1e5 // 1/1.225e-5 = 81632.65306 diff --git a/src/BaseSphere.cpp b/src/BaseSphere.cpp index 06a656a862d..324074e8ef3 100644 --- a/src/BaseSphere.cpp +++ b/src/BaseSphere.cpp @@ -21,7 +21,7 @@ struct BaseSphereDataBlock { Color4f atmosColor; alignas(16) vector3f coefficientsR; alignas(16) vector3f coefficientsM; - alignas(16) vector2f baricStep; + alignas(16) vector2f scaleHeight; // Eclipse struct data alignas(16) vector3f shadowCentreX; @@ -102,7 +102,7 @@ void BaseSphere::SetMaterialParameters(const matrix4x4d &trans, const float radi matData.atmosColor = ap.atmosCol.ToColor4f(); matData.coefficientsR = ap.rayleighCoefficients; matData.coefficientsM = ap.mieCoefficients; - matData.baricStep = ap.baricStep; + matData.scaleHeight = ap.scaleHeight; // we handle up to three shadows at a time auto it = shadows.cbegin(), itEnd = shadows.cend(); diff --git a/src/galaxy/AtmosphereParameters.h b/src/galaxy/AtmosphereParameters.h index bc0cc66bc4f..70d3bcc528d 100644 --- a/src/galaxy/AtmosphereParameters.h +++ b/src/galaxy/AtmosphereParameters.h @@ -13,7 +13,7 @@ struct AtmosphereParameters { vector3d center; vector3f rayleighCoefficients; vector3f mieCoefficients; - vector2f baricStep; + vector2f scaleHeight; }; #endif // ATMOSPHEREPARAMETERS_H_INCLUDED diff --git a/src/galaxy/SystemBody.cpp b/src/galaxy/SystemBody.cpp index 88f97246b40..f9b988c1204 100644 --- a/src/galaxy/SystemBody.cpp +++ b/src/galaxy/SystemBody.cpp @@ -267,7 +267,7 @@ bool SystemBody::IsScoopable() const // planet radius, height of atmosphere (not its radius), length of perpendicular between ray and planet center, lapse rate at which density fades out by rate of e // this function is used in GetCoefficients // all input units are in km -double SystemBody::ComputeDensity(const double radius, const double atmosphereHeight, const double h, const double baricStep) const +double SystemBody::ComputeDensity(const double radius, const double atmosphereHeight, const double h, const double scaleHeight) const { int numSamples = 16; double totalHeight = radius + atmosphereHeight; @@ -281,7 +281,7 @@ double SystemBody::ComputeDensity(const double radius, const double atmosphereHe for (int i = 0; i < numSamples; ++i) { double t = tmin + step * (i + 0.5); double h = sqrt(minHeight * minHeight + t * t) - radius; - density += step * exp(-h / baricStep); + density += step * exp(-h / scaleHeight); } return density; @@ -290,20 +290,20 @@ double SystemBody::ComputeDensity(const double radius, const double atmosphereHe // these coefficients are to be passed into shaders, meant to accelerate scattering computation per-pixel // instead of sampling each one (which I suspect is VERY SLOW) // all input units are in km -vector3f SystemBody::GetCoefficients(const double radius, const double atmHeight, const double baricStep) const +vector3f SystemBody::GetCoefficients(const double radius, const double atmHeight, const double scaleHeight) const { float k, b, c; // compute full out-scattering densities at 0 and 1 km heights // k = density at 0 km // b = log(density0km / density1km) - log is used to multiply it by actual height - k = ComputeDensity(radius, atmHeight, 0.f, baricStep); - b = log(k / ComputeDensity(radius, atmHeight, 1.f, baricStep)); + k = ComputeDensity(radius, atmHeight, 0.f, scaleHeight); + b = log(k / ComputeDensity(radius, atmHeight, 1.f, scaleHeight)); // compute c - erf coefficient, which adjusts slope of erf near t=0 to match actual in-scattering float erf1_minus_erf0 = 0.421463; float sHeight = sqrt(radius * radius + 1.f) - radius; - float c1 = exp(-sHeight / baricStep); + float c1 = exp(-sHeight / scaleHeight); float c2 = k * erf1_minus_erf0; c = c1 / c2; return vector3f(k, b, c); @@ -371,7 +371,7 @@ AtmosphereParameters SystemBody::CalcAtmosphereParams() const const float atmosHeight_in_km = radiusPlanet_in_km * (params.atmosRadius - 1); params.rayleighCoefficients = GetCoefficients(radiusPlanet_in_km, atmosHeight_in_km, atmosScaleHeight); params.mieCoefficients = GetCoefficients(radiusPlanet_in_km, atmosHeight_in_km, atmosScaleHeight / 6.66); // 7994 / 1200 = 6.61 - params.baricStep = vector2f(atmosScaleHeight, atmosScaleHeight / 6.66); + params.scaleHeight = vector2f(atmosScaleHeight, atmosScaleHeight / 6.66); return params; } diff --git a/src/galaxy/SystemBody.h b/src/galaxy/SystemBody.h index d50ac0f0b7b..c91fc7ea3ec 100644 --- a/src/galaxy/SystemBody.h +++ b/src/galaxy/SystemBody.h @@ -293,8 +293,8 @@ class SystemBody : public RefCounted, public SystemBodyType, protected SystemBod double GetAtmDensity(double altitude, double pressure) const; // for rayleigh scattering - double ComputeDensity(const double radius, const double atmosphereHeight, const double h, const double baricStep) const; - vector3f GetCoefficients(const double radius, const double atmHeight, const double baricStep) const; + double ComputeDensity(const double radius, const double atmosphereHeight, const double h, const double scaleHeight) const; + vector3f GetCoefficients(const double radius, const double atmHeight, const double scaleHeight) const; AtmosphereParameters CalcAtmosphereParams() const;