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/newview/lldrawpoolwlsky.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/lldrawpoolwlsky.cpp') diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 4bf47f4fd6..04f358ba79 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -44,6 +44,8 @@ #include "llenvironment.h" #include "llatmosphere.h" +#pragma optimize("", off) + static LLStaticHashedString sCamPosLocal("camPosLocal"); static LLStaticHashedString sCustomAlpha("custom_alpha"); @@ -180,12 +182,12 @@ 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 + /* 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]); -- 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/newview/lldrawpoolwlsky.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/lldrawpoolwlsky.cpp') 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); -- 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/newview/lldrawpoolwlsky.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'indra/newview/lldrawpoolwlsky.cpp') diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 3b3d67243a..41bf024942 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -505,22 +505,19 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { + if (gPipeline.useAdvancedAtmospherics()) + { + renderSkyHazeDeferred(origin, camHeightLocal); + renderHeavenlyBodies(); + } + else { // Disable depth-test for sky, but re-enable depth writes for the cloud // rendering below so the cloud shader can write out depth for the stars to test against LLGLDepthTest depth(GL_TRUE, GL_FALSE); - if (gPipeline.useAdvancedAtmospherics()) - { - renderSkyHazeDeferred(origin, camHeightLocal); - } - else - { - renderSkyHaze(origin, camHeightLocal); - - } - renderHeavenlyBodies(); + renderSkyHaze(origin, camHeightLocal); + renderHeavenlyBodies(); } - renderSkyClouds(origin, camHeightLocal); } gGL.setColorMask(true, true); -- cgit v1.2.3 From e075c65ee22a54b114808057399b5c7546dfb08a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Sep 2018 16:43:49 +0100 Subject: First pass at preferences and feature table hookup for advanced atmospherics. --- indra/newview/lldrawpoolwlsky.cpp | 136 ++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 72 deletions(-) (limited to 'indra/newview/lldrawpoolwlsky.cpp') diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 41bf024942..0d49c5a339 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -230,10 +230,9 @@ void LLDrawPoolWLSky::renderStars(void) const // clamping and allow the star_alpha param to brighten the stars. LLColor4 star_alpha(LLColor4::black); - // *LAPRAS - star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle - - // If start_brightness is not set, exit + star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 512.f; + + // If star brightness is not set, exit if( star_alpha.mV[3] < 0.001 ) { LL_DEBUGS("SKY") << "star_brightness below threshold." << LL_ENDL; @@ -293,9 +292,8 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const LLGLSPipelineSkyBox gls_sky; LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - - // *LAPRAS - F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle + + F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 512.0f; // If start_brightness is not set, exit if(star_alpha < 0.001f) @@ -332,6 +330,11 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const gDeferredStarProgram.uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); gDeferredStarProgram.uniform1f(sCustomAlpha, star_alpha); + + sStarTime = (F32)LLFrameTimer::getElapsedSeconds() * 0.5f; + + gDeferredStarProgram.uniform1f(LLShaderMgr::WATER_TIME, sStarTime); + gSky.mVOWLSkyp->drawStars(); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -375,6 +378,8 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); bool can_use_vertex_shaders = gPipeline.canUseVertexShaders(); + bool can_use_windlight_shaders = gPipeline.canUseWindLightShaders(); + if (gSky.mVOSkyp->getSun().getDraw() && face && face->getGeomCount()) { @@ -388,45 +393,39 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() if (tex_a || tex_b) { // if and only if we have a texture defined, render the sun disc - if (can_use_vertex_shaders) - { - sun_shader->bind(); - } - - if (tex_a && (!tex_b || (tex_a == tex_b))) + if (can_use_vertex_shaders && can_use_windlight_shaders) { - // Bind current and next sun textures - sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); - blend_factor = 0; - } - else if (tex_b && !tex_a) - { - sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); - blend_factor = 0; - } - else if (tex_b != tex_a) - { - sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); - sun_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); - } - - LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); + sun_shader->bind(); + + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + // Bind current and next sun textures + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b && !tex_a) + { + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b != tex_a) + { + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + sun_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + } + + LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); - if (can_use_vertex_shaders) - { sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); sun_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - } - LLFacePool::LLOverrideFaceColor color_override(this, color); - face->renderIndexed(); + LLFacePool::LLOverrideFaceColor color_override(this, color); + face->renderIndexed(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - if (can_use_vertex_shaders) - { - sun_shader->unbind(); + sun_shader->unbind(); } } } @@ -440,46 +439,39 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor()); - if (can_use_vertex_shaders) - { - moon_shader->bind(); - } - - if (tex_a && (!tex_b || (tex_a == tex_b))) + if (can_use_vertex_shaders && can_use_windlight_shaders) { - // Bind current and next sun textures - moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); - blend_factor = 0; - } - else if (tex_b && !tex_a) - { - moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); - blend_factor = 0; - } - else if (tex_b != tex_a) - { - moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); - moon_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); - } + moon_shader->bind(); + + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + // Bind current and next sun textures + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b && !tex_a) + { + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b != tex_a) + { + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + moon_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + } - if (can_use_vertex_shaders) - { moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - } - LLFacePool::LLOverrideFaceColor color_override(this, color); - - face->renderIndexed(); + LLFacePool::LLOverrideFaceColor color_override(this, color); + face->renderIndexed(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - if (can_use_vertex_shaders) - { - moon_shader->unbind(); - } - } + moon_shader->unbind(); + } + } gGL.popMatrix(); } -- cgit v1.2.3 From 642a4ddd60745db292c543a5cea3b1e5fe606795 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Sep 2018 20:39:48 +0100 Subject: Fixes for switching between atmospherics implementations on the fly. --- indra/newview/lldrawpoolwlsky.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'indra/newview/lldrawpoolwlsky.cpp') diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 0d49c5a339..205b6441e7 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -163,7 +163,7 @@ void LLDrawPoolWLSky::renderDome(const LLVector3& camPosLocal, F32 camHeightLoca void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const { - if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere) + if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders()) { sky_shader->bind(); @@ -192,7 +192,7 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); renderFsSky(camPosLocal, camHeightLocal, sky_shader); - + sky_shader->unbind(); } } @@ -497,18 +497,22 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { - if (gPipeline.useAdvancedAtmospherics()) { - renderSkyHazeDeferred(origin, camHeightLocal); - renderHeavenlyBodies(); - } - else - { - // Disable depth-test for sky, but re-enable depth writes for the cloud - // rendering below so the cloud shader can write out depth for the stars to test against LLGLDepthTest depth(GL_TRUE, GL_FALSE); - renderSkyHaze(origin, camHeightLocal); - renderHeavenlyBodies(); + + if (gPipeline.useAdvancedAtmospherics()) + { + //LLGLSquashToFarClip far_clip(get_current_projection()); + renderSkyHazeDeferred(origin, camHeightLocal); + } + else + { + // Disable depth-test for sky, but re-enable depth writes for the cloud + // rendering below so the cloud shader can write out depth for the stars to test against + renderSkyHaze(origin, camHeightLocal); + + } + renderHeavenlyBodies(); } renderSkyClouds(origin, camHeightLocal); } -- cgit v1.2.3 From 24e0e64f2f226fb87df5d6b42d868e2a0e3daff7 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 11 Sep 2018 00:23:10 +0100 Subject: Fix cloud shader tex binding to be more robust. Make vert generation not skip dome verts used for clouds when doing advanced atmospherics. --- indra/newview/lldrawpoolwlsky.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/lldrawpoolwlsky.cpp') diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 205b6441e7..e7929e0bbf 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -350,10 +350,11 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ALPHA); - gGL.getTexUnit(0)->bind(gSky.mVOSkyp->getCloudNoiseTex()); - gGL.getTexUnit(1)->bind(gSky.mVOSkyp->getCloudNoiseTexNext()); - cloud_shader->bind(); + + cloud_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, gSky.mVOSkyp->getCloudNoiseTex()); + cloud_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, gSky.mVOSkyp->getCloudNoiseTexNext()); + F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); cloud_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); -- cgit v1.2.3