summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-03-02 07:17:46 -0800
committerGraham Linden <graham@lindenlab.com>2019-03-02 07:17:46 -0800
commitd8eff424a5fb340b828802351e2b7f6b63bfa30f (patch)
tree3f314288516fd8a708eda8014247afafb6bdd428 /indra/llrender
parentbf8dee73f90f74f3eb9fd544dc9673defa52817f (diff)
SL-10664
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/CMakeLists.txt2
-rw-r--r--indra/llrender/llatmosphere.cpp69
-rw-r--r--indra/llrender/llatmosphere.h73
-rw-r--r--indra/llrender/llshadermgr.h2
4 files changed, 71 insertions, 75 deletions
diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt
index bcb5a847f6..0a23b6c041 100644
--- a/indra/llrender/CMakeLists.txt
+++ b/indra/llrender/CMakeLists.txt
@@ -13,7 +13,6 @@ include(LLVFS)
include(LLWindow)
include(LLXML)
include(LLVFS)
-include(Atmosphere)
include_directories(
${FREETYPE_INCLUDE_DIRS}
@@ -25,7 +24,6 @@ include_directories(
${LLWINDOW_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
${LLVFS_INCLUDE_DIRS}
- ${ATMOSPHERE_INCLUDE_DIR}
)
include_directories(SYSTEM
${LLCOMMON_SYSTEM_INCLUDE_DIRS}
diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp
index 12c6685354..a0b92564c3 100644
--- a/indra/llrender/llatmosphere.cpp
+++ b/indra/llrender/llatmosphere.cpp
@@ -88,8 +88,8 @@ AtmosphericModelSettings::AtmosphericModelSettings()
, m_sunArcRadians(0.00045f)
, m_mieAnisotropy(0.8f)
{
- atmosphere::DensityProfileLayer rayleigh_density(0.0, 1.0, -1.0 / kRayleighScaleHeight, 0.0, 0.0);
- atmosphere::DensityProfileLayer mie_density(0.0, 1.0, -1.0 / kMieScaleHeight, 0.0, 0.0);
+ DensityLayer rayleigh_density(0.0, 1.0, -1.0 / kRayleighScaleHeight, 0.0, 0.0);
+ DensityLayer mie_density(0.0, 1.0, -1.0 / kMieScaleHeight, 0.0, 0.0);
m_rayleighProfile.push_back(rayleigh_density);
m_mieProfile.push_back(mie_density);
@@ -98,8 +98,8 @@ AtmosphericModelSettings::AtmosphericModelSettings()
// decreasing linearly from 1 to 0 between 25 and 40km. This is an approximate
// profile from http://www.kln.ac.lk/science/Chemistry/Teaching_Resources/
// Documents/Introduction%20to%20atmospheric%20chemistry.pdf (page 10).
- m_absorptionProfile.push_back(atmosphere::DensityProfileLayer(25000.0, 0.0, 0.0, 1.0 / 15000.0, -2.0 / 3.0));
- m_absorptionProfile.push_back(atmosphere::DensityProfileLayer(0.0, 0.0, 0.0, -1.0 / 15000.0, 8.0 / 3.0));
+ m_absorptionProfile.push_back(DensityLayer(25000.0, 0.0, 0.0, 1.0 / 15000.0, -2.0 / 3.0));
+ m_absorptionProfile.push_back(DensityLayer(0.0, 0.0, 0.0, -1.0 / 15000.0, 8.0 / 3.0));
}
AtmosphericModelSettings::AtmosphericModelSettings(
@@ -227,64 +227,12 @@ LLAtmosphere::~LLAtmosphere()
{
m_mie_scatter_texture->setTexName(0);
}
-
- delete m_model;
- m_model = nullptr;
}
bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings)
{
- if ((m_model != nullptr) && (settings == m_settings))
- {
- return true;
- }
-
- if (m_model)
- {
- delete m_model;
- }
- m_model = nullptr;
-
- getTransmittance()->setTexName(0);
- getScattering()->setTexName(0);
- getMieScattering()->setTexName(0);
- getIlluminance()->setTexName(0);
-
- // Init libatmosphere model
- m_model = new atmosphere::Model(
- m_config,
- m_wavelengths,
- m_solar_irradiance,
- settings.m_sunArcRadians,
- settings.m_skyBottomRadius * 1000.0f,
- settings.m_skyTopRadius * 1000.0f,
- settings.m_rayleighProfile,
- m_rayleigh_scattering,
- settings.m_mieProfile,
- m_mie_scattering,
- m_mie_extinction,
- settings.m_mieAnisotropy,
- settings.m_absorptionProfile,
- m_absorption_extinction,
- m_ground_albedo,
- max_sun_zenith_angle,
- 1000.0,
- 3,
- false, // do not combine_scattering...we want indep textures
- false, // use 32F for 2d textures to avoid artifacts
- true); // use 16F for 3d textures to reduce footprint
-
- if (m_model)
- {
- m_model->Init(m_config, m_textures);
- getTransmittance()->setTexName(m_textures.transmittance_texture);
- getScattering()->setTexName(m_textures.scattering_texture);
- getMieScattering()->setTexName(m_textures.single_mie_scattering_texture);
- getIlluminance()->setTexName(m_textures.illuminance_texture);
- m_settings = settings;
- }
-
- return m_model != nullptr;
+ // TBD
+ return true;
}
LLGLTexture* LLAtmosphere::getTransmittance()
@@ -342,8 +290,3 @@ LLGLTexture* LLAtmosphere::getIlluminance()
}
return m_illuminance;
}
-
-GLhandleARB LLAtmosphere::getAtmosphericShaderForLink() const
-{
- return m_model ? m_model->GetShader() : 0;
-}
diff --git a/indra/llrender/llatmosphere.h b/indra/llrender/llatmosphere.h
index a010803595..572365d864 100644
--- a/indra/llrender/llatmosphere.h
+++ b/indra/llrender/llatmosphere.h
@@ -1,6 +1,6 @@
/**
* @file llatmosphere.h
- * @brief LLAtmosphere class for integration with libatmosphere
+ * @brief LLAtmosphere class
*
* $LicenseInfo:firstyear=2018&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -29,9 +29,70 @@
#include "llglheaders.h"
#include "llgltexture.h"
-#include "libatmosphere/model.h"
-typedef std::vector<atmosphere::DensityProfileLayer> DensityProfile;
+// An atmosphere layer of width 'width' (in m), and whose density is defined as
+// 'exp_term' * exp('exp_scale' * h) + 'linear_term' * h + 'constant_term',
+// clamped to [0,1], and where h is the altitude (in m). 'exp_term' and
+// 'constant_term' are unitless, while 'exp_scale' and 'linear_term' are in
+// m^-1.
+class DensityLayer {
+ public:
+ DensityLayer()
+ : width(0.0f)
+ , exp_term(0.0f)
+ , exp_scale(0.0f)
+ , linear_term(0.0f)
+ , constant_term(0.0f)
+ {
+ }
+
+ DensityLayer(float width, float exp_term, float exp_scale, float linear_term, float constant_term)
+ : width(width)
+ , exp_term(exp_term)
+ , exp_scale(exp_scale)
+ , linear_term(linear_term)
+ , constant_term(constant_term)
+ {
+ }
+
+ bool operator==(const DensityLayer& rhs) const
+ {
+ if (width != rhs.width)
+ {
+ return false;
+ }
+
+ if (exp_term != rhs.exp_term)
+ {
+ return false;
+ }
+
+ if (exp_scale != rhs.exp_scale)
+ {
+ return false;
+ }
+
+ if (linear_term != rhs.linear_term)
+ {
+ return false;
+ }
+
+ if (constant_term != rhs.constant_term)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ float width = 1024.0f;
+ float exp_term = 1.0f;
+ float exp_scale = 1.0f;
+ float linear_term = 1.0f;
+ float constant_term = 0.0f;
+};
+
+typedef std::vector<DensityLayer> DensityProfile;
class AtmosphericModelSettings
{
@@ -83,8 +144,6 @@ public:
LLGLTexture* getMieScattering();
LLGLTexture* getIlluminance();
- GLhandleARB getAtmosphericShaderForLink() const;
-
bool configureAtmosphericModel(AtmosphericModelSettings& settings);
protected:
@@ -93,10 +152,6 @@ protected:
*this = rhs;
}
- atmosphere::ModelConfig m_config;
- atmosphere::PrecomputedTextures m_textures;
- atmosphere::Model* m_model = nullptr;
-
LLPointer<LLGLTexture> m_transmittance;
LLPointer<LLGLTexture> m_scattering;
LLPointer<LLGLTexture> m_mie_scatter_texture;
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index 497c3eb231..e0a67e6198 100644
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -226,7 +226,7 @@ public:
SUN_SIZE,
FOG_COLOR,
- // precomputed textures from libatmosphere
+ // precomputed textures
TRANSMITTANCE_TEX,
SCATTER_TEX,
SINGLE_MIE_SCATTER_TEX,