summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2018-07-10 15:16:50 -0700
committerRider Linden <rider@lindenlab.com>2018-07-10 15:16:50 -0700
commit7724ace15248fefe35b7e1d567554833d6817f68 (patch)
tree265da1b823ca73a28a2602822e5701abd7370c5b /indra
parent294793b9a983a0c26c0e82bd432d4cc311ecb1ba (diff)
parent9da2480891a1b866437c0ba48dc649299c021ab8 (diff)
Merge
Diffstat (limited to 'indra')
-rw-r--r--indra/llinventory/llsettingssky.cpp15
-rw-r--r--indra/llinventory/llsettingssky.h2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/starsF.glsl8
-rw-r--r--indra/newview/lldrawpoolwlsky.cpp104
-rw-r--r--indra/newview/llsettingsvo.cpp1
-rw-r--r--indra/newview/llsky.cpp7
-rw-r--r--indra/newview/llsky.h1
-rw-r--r--indra/newview/llvosky.cpp38
-rw-r--r--indra/newview/llvosky.h15
-rw-r--r--indra/newview/llvowlsky.cpp2
11 files changed, 152 insertions, 45 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index d73ae5721a..2f5216eba9 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -382,7 +382,8 @@ LLSettingsSky::LLSettingsSky(const LLSD &data) :
LLSettingsBase(data),
mNextSunTextureId(),
mNextMoonTextureId(),
- mNextCloudTextureId()
+ mNextCloudTextureId(),
+ mNextBloomTextureId()
{
}
@@ -390,7 +391,8 @@ LLSettingsSky::LLSettingsSky():
LLSettingsBase(),
mNextSunTextureId(),
mNextMoonTextureId(),
- mNextCloudTextureId()
+ mNextCloudTextureId(),
+ mNextBloomTextureId()
{
}
@@ -412,6 +414,7 @@ void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf)
mNextSunTextureId = other->getSunTextureId();
mNextMoonTextureId = other->getMoonTextureId();
mNextCloudTextureId = other->getCloudNoiseTextureId();
+ mNextBloomTextureId = other->getBloomTextureId();
}
else
{
@@ -637,7 +640,7 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position)
dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue();
dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue();
- dfltsetting[SETTING_BLOOM_TEXTUREID] = IMG_BLOOM1;
+ dfltsetting[SETTING_BLOOM_TEXTUREID] = GetDefaultBloomTextureId();
dfltsetting[SETTING_CLOUD_TEXTUREID] = GetDefaultCloudNoiseTextureId();
dfltsetting[SETTING_MOON_TEXTUREID] = GetDefaultMoonTextureId();
dfltsetting[SETTING_SUN_TEXTUREID] = GetDefaultSunTextureId();
@@ -1366,3 +1369,9 @@ LLUUID LLSettingsSky::getNextCloudNoiseTextureId() const
{
return mNextCloudTextureId;
}
+
+LLUUID LLSettingsSky::getNextBloomTextureId() const
+{
+ return mNextBloomTextureId;
+}
+
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index e7b4678f7f..00b7c5b37b 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -183,6 +183,7 @@ public:
LLUUID getNextSunTextureId() const;
LLUUID getNextMoonTextureId() const;
LLUUID getNextCloudNoiseTextureId() const;
+ LLUUID getNextBloomTextureId() const;
//=====================================================================
virtual void loadTextures() { };
@@ -272,6 +273,7 @@ private:
LLUUID mNextSunTextureId;
LLUUID mNextMoonTextureId;
LLUUID mNextCloudTextureId;
+ LLUUID mNextBloomTextureId;
typedef std::map<std::string, S32> mapNameToUniformId_t;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
index 1a4cdff23d..3f81e3b0af 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
@@ -94,6 +94,10 @@ void main()
alpha1 = 1. - alpha1 * alpha1;
alpha1 = 1. - alpha1 * alpha1;
+ if (alpha1 < 0.001f)
+ {
+ discard;
+ }
// Compute alpha2, for self shadowing effect
// (1 - alpha2) will later be used as percentage of incoming sunlight
diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
index 9260075262..d6a1edbf42 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
@@ -35,11 +35,17 @@ VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
uniform sampler2D diffuseMap;
+uniform sampler2D altDiffuseMap;
+uniform float blend_factor;
uniform float custom_alpha;
+uniform vec4 sunlight_color;
void main()
{
- vec4 col = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy);
+ vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy);
+ vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy);
+ vec4 col = mix(col_a, col_b, blend_factor);
+ col.rgb *= vertex_color.rgb;
col.a *= custom_alpha;
frag_color = col;
}
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index 90d017dd0b..3557f5a1ce 100644
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -238,7 +238,22 @@ void LLDrawPoolWLSky::renderStars(void) const
return;
}
- gGL.getTexUnit(0)->bind(gSky.mVOSkyp->getBloomTex());
+ LLViewerTexture* tex_a = gSky.mVOSkyp->getBloomTex();
+ LLViewerTexture* tex_b = gSky.mVOSkyp->getBloomTexNext();
+
+ if (tex_a && (!tex_b || (tex_a == tex_b)))
+ {
+ // Bind current and next sun textures
+ gGL.getTexUnit(0)->bind(tex_a);
+ }
+ else if (tex_b && !tex_a)
+ {
+ gGL.getTexUnit(0)->bind(tex_b);
+ }
+ else if (tex_b != tex_a)
+ {
+ gGL.getTexUnit(0)->bind(tex_a);
+ }
gGL.pushMatrix();
gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f);
@@ -256,6 +271,8 @@ void LLDrawPoolWLSky::renderStars(void) const
gSky.mVOWLSkyp->drawStars();
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
gGL.popMatrix();
if (LLGLSLShader::sNoFixedFunction)
@@ -273,7 +290,7 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const
{
LLGLSPipelineSkyBox gls_sky;
LLGLEnable blend(GL_BLEND);
- gGL.setSceneBlendType(LLRender::BT_ALPHA);
+ gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA);
// *LAPRAS
F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle
@@ -286,8 +303,38 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const
}
gDeferredStarProgram.bind();
+
+ LLViewerTexture* tex_a = gSky.mVOSkyp->getBloomTex();
+ LLViewerTexture* tex_b = gSky.mVOSkyp->getBloomTexNext();
+
+ F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor();
+
+ if (tex_a && (!tex_b || (tex_a == tex_b)))
+ {
+ // Bind current and next sun textures
+ gGL.getTexUnit(0)->bind(tex_a);
+ gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+ blend_factor = 0;
+ }
+ else if (tex_b && !tex_a)
+ {
+ gGL.getTexUnit(0)->bind(tex_b);
+ gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+ blend_factor = 0;
+ }
+ else if (tex_b != tex_a)
+ {
+ gGL.getTexUnit(0)->bind(tex_a);
+ gGL.getTexUnit(1)->bind(tex_b);
+ }
+
+ gDeferredStarProgram.uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
gDeferredStarProgram.uniform1f(sCustomAlpha, star_alpha);
gSky.mVOWLSkyp->drawStars();
+
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+
gDeferredStarProgram.unbind();
}
@@ -318,6 +365,10 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
LLGLEnable blend_on(GL_BLEND);
gPipeline.disableLights();
+ LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
+ gGL.pushMatrix();
+ gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
+
LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_SUN];
F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor();
@@ -427,7 +478,9 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
{
moon_shader->unbind();
}
- }
+ }
+
+ gGL.popMatrix();
}
void LLDrawPoolWLSky::renderDeferred(S32 pass)
@@ -438,11 +491,9 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
}
LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY);
-
const F32 camHeightLocal = LLEnvironment::instance().getCamHeight();
- LLGLSNoFog disableFog;
- LLGLDepthTest depth(GL_TRUE, GL_FALSE);
+ LLGLSNoFog disableFog;
LLGLDisable clip(GL_CLIP_PLANE0);
gGL.setColorMask(true, false);
@@ -453,39 +504,46 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
if (gPipeline.canUseWindLightShaders())
{
- if (gPipeline.useAdvancedAtmospherics())
{
- renderSkyHazeDeferred(origin, camHeightLocal);
+ // 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();
}
- else
- {
- renderSkyHaze(origin, camHeightLocal);
-
- gGL.pushMatrix();
- gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
-
- renderHeavenlyBodies();
- gGL.popMatrix();
- }
+ renderSkyClouds(origin, camHeightLocal);
}
gGL.setColorMask(true, true);
}
void LLDrawPoolWLSky::renderPostDeferred(S32 pass)
{
- const F32 camHeightLocal = LLEnvironment::instance().getCamHeight();
-
LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
- gGL.pushMatrix();
+ LLGLSNoFog disableFog;
+ LLGLDisable clip(GL_CLIP_PLANE0);
+ LLGLSquashToFarClip far_clip(get_current_projection());
+
+ gGL.pushMatrix();
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
+ gGL.setColorMask(true, false);
+ // would be nice to do this here, but would need said bodies
+ // to render at a realistic distance for depth-testing against the clouds...
+ //renderHeavenlyBodies();
renderStarsDeferred();
gGL.popMatrix();
-
- renderSkyClouds(origin, camHeightLocal);
+ gGL.setColorMask(true, true);
}
void LLDrawPoolWLSky::render(S32 pass)
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index dba7e00b93..a5187b7363 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -538,6 +538,7 @@ void LLSettingsVOSky::updateSettings()
gSky.setSunTextures(getSunTextureId(), getNextSunTextureId());
gSky.setMoonTextures(getMoonTextureId(), getNextMoonTextureId());
gSky.setCloudNoiseTextures(getCloudNoiseTextureId(), getNextCloudNoiseTextureId());
+ gSky.setBloomTextures(getBloomTextureId(), getNextBloomTextureId());
}
void LLSettingsVOSky::applySpecial(void *ptarget)
diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp
index 5d85778da5..9c7fc225a0 100644
--- a/indra/newview/llsky.cpp
+++ b/indra/newview/llsky.cpp
@@ -150,6 +150,13 @@ void LLSky::setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLUUI
}
}
+void LLSky::setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_texture_next)
+{
+ if(mVOSkyp.notNull()) {
+ mVOSkyp->setBloomTextures(bloom_texture, bloom_texture_next);
+ }
+}
+
void LLSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_direction, const LLVector3 &moon_direction)
{
if(mVOSkyp.notNull()) {
diff --git a/indra/newview/llsky.h b/indra/newview/llsky.h
index cc5db2c7ec..d2067a58bb 100644
--- a/indra/newview/llsky.h
+++ b/indra/newview/llsky.h
@@ -59,6 +59,7 @@ public:
void setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_texture_next);
void setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_texture_next);
void setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLUUID& cloud_noise_texture_next);
+ void setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_texture_next);
LLColor4 getSkyFogColor() const;
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index b57652e3f5..e099b410bf 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -393,10 +393,6 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
mSun.setIntensity(SUN_INTENSITY);
mMoon.setIntensity(0.1f * SUN_INTENSITY);
- mBloomTexturep = LLViewerTextureManager::getFetchedTexture(LLSettingsSky::GetDefaultBloomTextureId());
- mBloomTexturep->setNoDelete() ;
- mBloomTexturep->setAddressMode(LLTexUnit::TAM_CLAMP);
-
mHeavenlyBodyUpdated = FALSE ;
mDrawRefl = 0;
@@ -492,10 +488,6 @@ void LLVOSky::restoreGL()
setMoonTextures(psky->getMoonTextureId(), psky->getNextMoonTextureId());
}
- mBloomTexturep = LLViewerTextureManager::getFetchedTexture(LLSettingsSky::GetDefaultBloomTextureId());
- mBloomTexturep->setNoDelete() ;
- mBloomTexturep->setAddressMode(LLTexUnit::TAM_CLAMP);
-
updateDirections();
if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap
@@ -762,9 +754,14 @@ void LLVOSky::updateTextures()
mMoonTexturep[1]->addTextureStats( (F32)MAX_IMAGE_AREA );
}
- if (mBloomTexturep)
+ if (mBloomTexturep[0])
+ {
+ mBloomTexturep[0]->addTextureStats( (F32)MAX_IMAGE_AREA );
+ }
+
+ if (mBloomTexturep[1])
{
- mBloomTexturep->addTextureStats( (F32)MAX_IMAGE_AREA );
+ mBloomTexturep[1]->addTextureStats( (F32)MAX_IMAGE_AREA );
}
}
@@ -858,6 +855,27 @@ void LLVOSky::setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLU
}
}
+void LLVOSky::setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_texture_next)
+{
+ LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
+
+ LLUUID bloom_tex = bloom_texture.isNull() ? psky->GetDefaultBloomTextureId() : bloom_texture;
+ LLUUID bloom_tex_next = bloom_texture_next.isNull() ? (bloom_texture.isNull() ? psky->GetDefaultBloomTextureId() : bloom_texture) : bloom_texture_next;
+
+ mBloomTexturep[0] = LLViewerTextureManager::getFetchedTexture(bloom_tex, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+ mBloomTexturep[1] = LLViewerTextureManager::getFetchedTexture(bloom_tex_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+
+ if (mBloomTexturep[0])
+ {
+ mBloomTexturep[0]->setAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+
+ if (mBloomTexturep[1])
+ {
+ mBloomTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
+ }
+}
+
static LLTrace::BlockTimerStatHandle FTM_GEO_SKY("Sky Geometry");
BOOL LLVOSky::updateGeometry(LLDrawable *drawable)
diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h
index a9a59681ff..758a4a8c94 100644
--- a/indra/newview/llvosky.h
+++ b/indra/newview/llvosky.h
@@ -263,19 +263,20 @@ public:
bool isReflFace(const LLFace* face) const { return face == mFace[FACE_REFLECTION]; }
LLFace* getReflFace() const { return mFace[FACE_REFLECTION]; }
- LLViewerTexture* getSunTex() const { return mSunTexturep[0]; }
- LLViewerTexture* getMoonTex() const { return mMoonTexturep[0]; }
- LLViewerTexture* getBloomTex() const { return mBloomTexturep; }
+ LLViewerTexture* getSunTex() const { return mSunTexturep[0]; }
+ LLViewerTexture* getMoonTex() const { return mMoonTexturep[0]; }
+ LLViewerTexture* getBloomTex() const { return mBloomTexturep[0]; }
LLViewerTexture* getCloudNoiseTex() const { return mCloudNoiseTexturep[0]; }
- LLViewerTexture* getSunTexNext() const { return mSunTexturep[1]; }
- LLViewerTexture* getMoonTexNext() const { return mMoonTexturep[1]; }
- LLViewerTexture* getBloomTexNext() const { return mBloomTexturep; }
+ LLViewerTexture* getSunTexNext() const { return mSunTexturep[1]; }
+ LLViewerTexture* getMoonTexNext() const { return mMoonTexturep[1]; }
+ LLViewerTexture* getBloomTexNext() const { return mBloomTexturep[1]; }
LLViewerTexture* getCloudNoiseTexNext() const { return mCloudNoiseTexturep[1]; }
void setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_texture_next);
void setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_texture_next);
void setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLUUID& cloud_noise_texture_next);
+ void setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_texture_next);
void forceSkyUpdate(void) { mForceUpdate = TRUE; }
@@ -294,7 +295,7 @@ protected:
LLPointer<LLViewerFetchedTexture> mSunTexturep[2];
LLPointer<LLViewerFetchedTexture> mMoonTexturep[2];
LLPointer<LLViewerFetchedTexture> mCloudNoiseTexturep[2];
- LLPointer<LLViewerFetchedTexture> mBloomTexturep;
+ LLPointer<LLViewerFetchedTexture> mBloomTexturep[2];
static S32 sResolution;
static S32 sTileResX;
diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp
index bdef2ed9fb..db9452cce9 100644
--- a/indra/newview/llvowlsky.cpp
+++ b/indra/newview/llvowlsky.cpp
@@ -36,7 +36,7 @@
#include "llenvironment.h"
#include "llsettingssky.h"
-const F32 LLVOWLSky::DISTANCE_TO_STARS = (HORIZON_DIST - 10.f)*0.25f;
+const F32 LLVOWLSky::DISTANCE_TO_STARS = (HORIZON_DIST - 10.f) * 0.8f;
const U32 LLVOWLSky::MIN_SKY_DETAIL = 3;
const U32 LLVOWLSky::MAX_SKY_DETAIL = 180;