diff options
-rw-r--r-- | indra/llrender/llatmosphere.cpp | 45 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 10 | ||||
-rw-r--r-- | indra/newview/app_settings/settings.xml | 2 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/skyF.glsl | 49 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/skyV.glsl | 14 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 20 | ||||
-rw-r--r-- | indra/newview/llenvironment.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llfloatereditextdaycycle.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llfloaterfixedenvironment.cpp | 16 | ||||
-rw-r--r-- | indra/newview/llpaneleditsky.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml | 9 |
11 files changed, 109 insertions, 74 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); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index e32eeb4779..8f4faf51da 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10165,7 +10165,7 @@ <key>Type</key> <string>Boolean</string> <key>Value</key> - <integer>1</integer> + <integer>0</integer> </map> <key>RenderUseTriStrips</key> <map> diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl index 01c873584f..ef94190d45 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl @@ -24,17 +24,19 @@ */ #ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; +out vec4 frag_data[4]; #else -#define frag_color gl_FragColor +#define frag_data gl_FragData #endif -in vec3 view_pos; -in vec3 view_dir; +VARYING vec2 vary_frag; -uniform vec3 cameraPosLocal; +uniform vec3 camPosLocal; uniform vec3 sun_dir; uniform float sun_size; +uniform float far_z; +uniform mat4 inv_proj; +uniform mat4 inv_modelview; uniform sampler2D transmittance_texture; uniform sampler3D scattering_texture; @@ -44,42 +46,33 @@ uniform sampler2D irradiance_texture; vec3 GetSolarLuminance(); vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance); vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 dir, out vec3 transmittance); -vec3 GetSunAndSkyIlluminance(vec3 pos, vec3 norm, vec3 dir, out vec3 sky_irradiance); void main() { - vec3 view_direction = normalize(view_dir); + vec3 pos = vec3((vary_frag * 2.0) - vec2(1.0, 1.0), 0.0); + vec4 view_pos = (inv_proj * vec4(pos, 1.0f)); + view_pos /= view_pos.w; + vec3 view_ray = (inv_modelview * vec4(view_pos.xyz, 0.0f)).xyz; - vec3 sun_direction = sun_dir; + vec3 view_direction = normalize(view_ray); + vec3 sun_direction = normalize(sun_dir); - vec3 camPos = cameraPosLocal + vec3(0, 0, 6360.0f); + vec3 camPos = (camPosLocal / 1000.0f) + vec3(0, 0, 6360.0f); vec3 transmittance; - vec3 sky_illum; - - vec3 radiance_sun = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance); - vec3 radiance2_sun = GetSunAndSkyIlluminance(camPos, view_direction, sun_direction, sky_illum); - - radiance_sun *= transmittance; - + vec3 radiance_sun = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance); vec3 solar_luminance = transmittance * GetSolarLuminance(); // If the view ray intersects the Sun, add the Sun radiance. if (dot(view_direction, sun_direction) >= sun_size) { - radiance_sun = radiance_sun + solar_luminance; + radiance_sun += solar_luminance; } - vec3 color = radiance_sun; - - color = vec3(1.0) - exp(-color * 0.0001); - - //float d = dot(view_direction, sun_direction); - //frag_color.rgb = vec3(d, d >= sun_size ? 1.0f : 0.0f, 0.0f); - - frag_color.rgb = color; - //frag_color.rgb = vec3(dot(view_direction, sun_direction) > 0.95f ? 1.0 : 0.0, 0,0); - //frag_color.rgb = normalize(view_pos); + vec3 color = vec3(1.0) - exp(-radiance_sun * 0.0001); + color = pow(color, vec3(1.0 / 2.2)); - frag_color.a = 1.0; + frag_data[0] = vec4(color, 1.0); + frag_data[1] = vec4(0.0); + frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl index cf3eb658fc..90217aed02 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl @@ -30,22 +30,14 @@ uniform mat4 inv_proj; uniform mat4 inv_modelview; ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; -// Inputs -uniform vec3 camPosLocal; - -out vec3 view_pos; -out vec3 view_dir; +VARYING vec2 vary_frag; void main() { // pass through untransformed fullscreen pos (clipspace) gl_Position = vec4(position.xyz, 1.0); - - view_pos = (inv_proj * vec4(position, 1.0f)).xyz; - - // this will be normalized in the frag shader... - //view_dir = (inv_modelview * view_pos).xyz; - view_dir = view_pos - camPosLocal; + vary_frag = texcoord0; } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 8a2941e20a..3b3d67243a 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -93,6 +93,10 @@ void LLDrawPoolWLSky::beginRenderPass( S32 pass ) void LLDrawPoolWLSky::endRenderPass( S32 pass ) { + sky_shader = nullptr; + cloud_shader = nullptr; + sun_shader = nullptr; + moon_shader = nullptr; } void LLDrawPoolWLSky::beginDeferredPass(S32 pass) @@ -113,7 +117,10 @@ void LLDrawPoolWLSky::beginDeferredPass(S32 pass) void LLDrawPoolWLSky::endDeferredPass(S32 pass) { - + sky_shader = nullptr; + cloud_shader = nullptr; + sun_shader = nullptr; + moon_shader = nullptr; } void LLDrawPoolWLSky::renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const @@ -167,8 +174,8 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->bindTexture(LLShaderMgr::ILLUMINANCE_TEX, gAtmosphere->getIlluminance()); LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLVector4 sun_dir = LLEnvironment::instance().getClampedSunNorm(); - LLVector4 moon_dir = LLEnvironment::instance().getClampedMoonNorm(); + LLVector3 sun_dir = LLEnvironment::instance().getSunDirection(); + LLVector3 moon_dir = LLEnvironment::instance().getMoonDirection(); F32 sunSize = (float)cosf(psky->getSunArcRadians()); sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); @@ -182,13 +189,6 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); - /* clouds are rendered along with sky in adv atmo - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) - { - sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, gSky.mVOSkyp->getCloudNoiseTex()); - sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, gSky.mVOSkyp->getCloudNoiseTexNext()); - }*/ - sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); renderFsSky(camPosLocal, camHeightLocal, sky_shader); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3a1aec6319..e437003520 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1633,12 +1633,15 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky->update(); mBlenderSky.reset(); +#if 0 if (gAtmosphere) { AtmosphericModelSettings settings; LLEnvironment::getAtmosphericModelSettings(settings, psky); gAtmosphere->configureAtmosphericModel(settings); } +#endif + } void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index ed60dd4303..7d20a27813 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -62,6 +62,8 @@ #include "llenvironment.h" #include "lltrans.h" +extern LLControlGroup gSavedSettings; + //========================================================================= namespace { const std::string track_tabs[] = { @@ -821,10 +823,17 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) { panel->setSky(p_sky); } - panel = dynamic_cast<LLPanelSettingsSkyDensityTab*>(tab_container->getChildView("advanced_atmo_panel")); + panel = dynamic_cast<LLPanelSettingsSkyDensityTab*>(tab_container->getChildView("density_panel")); if (panel) { - panel->setSky(p_sky); + if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) + { + panel->setSky(p_sky); + } + else + { + panel->setVisible(false); + } } } diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index d38098c0a6..1104717dc1 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -55,6 +55,8 @@ #include "llsettingsvo.h" #include "llinventorymodel.h" +extern LLControlGroup gSavedSettings; + namespace { const std::string FIELD_SETTINGS_NAME("settings_name"); @@ -599,12 +601,14 @@ BOOL LLFloaterFixedEnvironmentSky::postBuild() panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); - panel = new LLPanelSettingsSkyDensityTab; - panel->buildFromFile("panel_settings_sky_density.xml"); - panel->setSky(std::static_pointer_cast<LLSettingsSky>(mSettings)); - panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); - mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); - + if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) + { + panel = new LLPanelSettingsSkyDensityTab; + panel->buildFromFile("panel_settings_sky_density.xml"); + panel->setSky(std::static_pointer_cast<LLSettingsSky>(mSettings)); + panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + } return TRUE; } diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index 451e15c73d..a13efbc54b 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -37,8 +37,6 @@ #include "llenvironment.h" #include "llatmosphere.h" -#pragma optimize("", off) - namespace { // Atmosphere Tab diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index c8843db28b..7a5c9cb63f 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -520,6 +520,15 @@ Select a key frame from the timeline above to edit settings. left_delta="0" top_pad="5" name="moon_panel" /> + <panel + border="true" + class="panel_settings_density" + filename="panel_settings_sky_density.xml" + label="Density" + layout="topleft" + left_delta="0" + top_pad="5" + name="density_panel" /> </tab_container> </layout_panel> </layout_stack> |