diff options
author | Graham Linden <graham@lindenlab.com> | 2018-09-06 22:50:26 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-09-06 22:50:26 +0100 |
commit | 451ab80ca65a7ae75316442086f42b6553ea6bbe (patch) | |
tree | c9ed6fa0517eaf48d60c8a0be2eb226fd4d00d1b /indra/llrender | |
parent | 59a36c2037b6ee87c656d5b314745d3bf82ede1a (diff) |
Fix tex format mismatch between what libatmosphere was generating and what we were claiming to use in rendering.
First pass at sky shader using libatmosphere sky radiance lookup.
Add atmo density controls to ext daycycle floater tabs.
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/llatmosphere.cpp | 45 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 10 |
2 files changed, 41 insertions, 14 deletions
diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp index 4fd9764e07..aaa1ff65e1 100644 --- a/indra/llrender/llatmosphere.cpp +++ b/indra/llrender/llatmosphere.cpp @@ -34,8 +34,6 @@ #include "llshadermgr.h" #include "llglslshader.h" -#pragma optimize("", off) - LLAtmosphere* gAtmosphere = nullptr; // Values from "Reference Solar Spectral Irradiance: ASTM G-173", ETR column @@ -234,6 +232,26 @@ LLAtmosphere::~LLAtmosphere() m_model = nullptr; } +#if DEBUG_ATMO_TEX_GEN +uint8_t* GetTexture2d(int width, int height, int components, GLuint texture) +{ + glActiveTextureARB(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texture); + uint8_t* storage = (uint8_t*)malloc(width * height * components * sizeof(float)); + glGetTexImage(GL_TEXTURE_2D, 0, components == 3 ? GL_RGB : GL_RGBA, GL_FLOAT, storage); + return storage; +} + +uint8_t* GetTexture3d(int width, int height, int depth, int components, GLuint texture) +{ + glActiveTextureARB(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_3D, texture); + uint8_t* storage = (uint8_t*)malloc(width * height * depth * components * sizeof(float)); + glGetTexImage(GL_TEXTURE_3D, 0, components == 3 ? GL_RGB : GL_RGBA, GL_FLOAT, storage); + return storage; +} +#endif + bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) { if ((m_model != nullptr) && (settings == m_settings)) @@ -256,6 +274,7 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) m_config.num_scattering_orders = 4; m_model = new atmosphere::Model( + m_config, m_wavelengths, m_solar_irradiance, settings.m_sunArcRadians, @@ -273,8 +292,9 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) max_sun_zenith_angle, 1000.0, 3, - false, - true); + 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) { @@ -283,6 +303,19 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) getScattering()->setTexName(m_textures.scattering_texture); getMieScattering()->setTexName(m_textures.single_mie_scattering_texture); getIlluminance()->setTexName(m_textures.illuminance_texture); + +#if DEBUG_ATMO_TEX_GEN + // for debug only... + U8* transmittance = GetTexture2d(m_config.transmittanceTextureWidth, m_config.transmittanceTextureHeight, 3, m_textures.transmittance_texture); + U8* scattering = GetTexture3d(m_config.scatteringTextureWidth, m_config.scatteringTextureHeight, m_config.scatteringTextureDepth, 3, m_textures.scattering_texture); + U8* single_mie_scattering = GetTexture3d(m_config.scatteringTextureWidth, m_config.scatteringTextureHeight, m_config.scatteringTextureDepth, 3, m_textures.single_mie_scattering_texture); + U8* illuminance = GetTexture2d(m_config.illuminanceTextureWidth, m_config.illuminanceTextureHeight, 3, m_textures.illuminance_texture); + free(transmittance); + free(scattering); + free(single_mie_scattering); + free(illuminance); +#endif + } return m_model != nullptr; @@ -296,7 +329,7 @@ LLGLTexture* LLAtmosphere::getTransmittance() m_transmittance->generateGLTexture(); m_transmittance->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP); m_transmittance->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR); - m_transmittance->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT); + m_transmittance->setExplicitFormat(GL_RGB32F_ARB, GL_RGB, GL_FLOAT); m_transmittance->setTarget(GL_TEXTURE_2D, LLTexUnit::TT_TEXTURE); } return m_transmittance; @@ -338,7 +371,7 @@ LLGLTexture* LLAtmosphere::getIlluminance() m_illuminance->generateGLTexture(); m_illuminance->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP); m_illuminance->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR); - m_illuminance->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT); + m_illuminance->setExplicitFormat(GL_RGB32F_ARB, GL_RGB, GL_FLOAT); m_illuminance->setTarget(GL_TEXTURE_2D, LLTexUnit::TT_TEXTURE); } return m_illuminance; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 67898f1258..251c02dd77 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1241,16 +1241,10 @@ void LLRender::syncMatrices() } if (shader->getUniformLocation(LLShaderMgr::INVERSE_MODELVIEW_MATRIX)) - { - glh::matrix4f ogl_to_cfr = copy_matrix((F32*)OGL_TO_CFR_ROTATION); - glh::matrix4f modelview = ogl_to_cfr.inverse() * get_current_modelview(); - - glh::matrix4f inv_modelview = modelview.inverse(); - shader->uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_MATRIX, 1, FALSE, inv_modelview.m); + { + shader->uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_MATRIX, 1, GL_FALSE, cached_inv_mdv.m); } - shader->uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_MATRIX, 1, GL_FALSE, cached_inv_mdv.m); - //update MVP matrix mvp_done = true; loc = shader->getUniformLocation(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX); |