From 32631f09a57548c2bbf7e09211a2053ff2e4e47d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 4 Sep 2018 23:41:36 +0100 Subject: 8283/4 WIP --- indra/llrender/llatmosphere.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp index 4edfd9efe9..4fd9764e07 100644 --- a/indra/llrender/llatmosphere.cpp +++ b/indra/llrender/llatmosphere.cpp @@ -34,6 +34,8 @@ #include "llshadermgr.h" #include "llglslshader.h" +#pragma optimize("", off) + LLAtmosphere* gAtmosphere = nullptr; // Values from "Reference Solar Spectral Irradiance: ASTM G-173", ETR column @@ -78,6 +80,8 @@ const double kMieScaleHeight = 1200.0; const double kMieAngstromAlpha = 0.0; const double kMieAngstromBeta = 5.328e-3; const double kMieSingleScatteringAlbedo = 0.9; +const double kGroundAlbedo = 0.1; + const double max_sun_zenith_angle = F_PI * 2.0 / 3.0; AtmosphericModelSettings::AtmosphericModelSettings() @@ -201,7 +205,7 @@ LLAtmosphere::LLAtmosphere() m_mie_scattering.push_back(mie * kMieSingleScatteringAlbedo); m_mie_extinction.push_back(mie); m_absorption_extinction.push_back(kMaxOzoneNumberDensity * kOzoneCrossSection[(l - kLambdaMin) / 10]); - m_ground_albedo.push_back(0.6f); + m_ground_albedo.push_back(kGroundAlbedo); } AtmosphericModelSettings defaults; @@ -268,7 +272,7 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) m_ground_albedo, max_sun_zenith_angle, 1000.0, - 15, + 3, false, true); -- cgit v1.2.3 From 451ab80ca65a7ae75316442086f42b6553ea6bbe Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 6 Sep 2018 22:50:26 +0100 Subject: 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. --- indra/llrender/llatmosphere.cpp | 45 +++++++++++++++++++++++++++++++++++------ indra/llrender/llrender.cpp | 10 ++------- 2 files changed, 41 insertions(+), 14 deletions(-) (limited to 'indra/llrender') 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); -- cgit v1.2.3 From 4bd2b8b98ba1c562dfd65975a87ef5ee3db35633 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 7 Sep 2018 17:24:29 +0100 Subject: Fix createDensityProfileLayer dropping passed in values. Enable sky density panel to update advanced atmo precomputed textures. Take wild stab at appropriate ranges for density parameters in edit panel UI. Clean up debug-only code that isn't necessary anymore. Point autobuild at latest version of libatmosphere package. --- indra/llrender/llatmosphere.cpp | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp index aaa1ff65e1..12c6685354 100644 --- a/indra/llrender/llatmosphere.cpp +++ b/indra/llrender/llatmosphere.cpp @@ -232,26 +232,6 @@ 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)) @@ -271,8 +251,6 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) getIlluminance()->setTexName(0); // Init libatmosphere model - m_config.num_scattering_orders = 4; - m_model = new atmosphere::Model( m_config, m_wavelengths, @@ -303,19 +281,7 @@ 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 - + m_settings = settings; } return m_model != nullptr; -- cgit v1.2.3