summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolwlsky.cpp
diff options
context:
space:
mode:
authorGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-04-26 22:35:26 +0100
committerGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-04-26 22:35:26 +0100
commit21ddbd64af44672e4b20dc4cdf99fd1fbc5c07c2 (patch)
tree826990df06b16c98d59f8930161ef11897c0da58 /indra/newview/lldrawpoolwlsky.cpp
parent6dfa720e75cd61e6b502c30d15511d2b447f7eb4 (diff)
Mods to make adv atmo WL sky render using 2 tris instead of dome.
Diffstat (limited to 'indra/newview/lldrawpoolwlsky.cpp')
-rw-r--r--indra/newview/lldrawpoolwlsky.cpp100
1 files changed, 55 insertions, 45 deletions
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index a28041034b..01d10502a1 100644
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -44,6 +44,8 @@
#include "llenvironment.h"
#include "llatmosphere.h"
+static LLStaticHashedString sCamPosLocal("camPosLocal");
+
LLPointer<LLViewerTexture> LLDrawPoolWLSky::sCloudNoiseTexture = NULL;
LLPointer<LLImageRaw> LLDrawPoolWLSky::sCloudNoiseRawImage = NULL;
@@ -124,56 +126,55 @@ void LLDrawPoolWLSky::endDeferredPass(S32 pass)
}
-void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) const
+void LLDrawPoolWLSky::renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const
{
- llassert_always(NULL != shader);
+ gGL.pushMatrix();
+ gGL.matrixMode(LLRender::MM_PROJECTION);
+ gGL.loadIdentity();
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
+ gGL.loadIdentity();
- static LLStaticHashedString sCamPosLocal("camPosLocal");
-
- LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
+ // Draw WL Sky w/ normal cam pos (where you are) for adv atmo sky
+ sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]);
+ gSky.mVOWLSkyp->drawFsSky();
- if (gPipeline.useAdvancedAtmospherics())
- {
- // Draw WL Sky w/ normal cam pos (where you are) for adv atmo sky
- sky_shader->uniform3f(sCamPosLocal, origin.mV[0], origin.mV[1], origin.mV[2]);
+ gGL.popMatrix();
+}
-// TBD replace this with a FS tri pass, there's little point to the tess when you have fragment shaders...
+void LLDrawPoolWLSky::renderDome(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const
+{
+ llassert_always(NULL != shader);
- gSky.mVOWLSkyp->drawDome();
- }
- else
- {
- gGL.pushMatrix();
+ gGL.pushMatrix();
- //chop off translation
- if (LLPipeline::sReflectionRender && origin.mV[2] > 256.f)
- {
- gGL.translatef(origin.mV[0], origin.mV[1], 256.f-origin.mV[2]*0.5f);
- }
- else
- {
- gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
- }
+ //chop off translation
+ if (LLPipeline::sReflectionRender && camPosLocal.mV[2] > 256.f)
+ {
+ gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], 256.f-camPosLocal.mV[2]*0.5f);
+ }
+ else
+ {
+ gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]);
+ }
- // the windlight sky dome works most conveniently in a coordinate system
- // where Y is up, so permute our basis vectors accordingly.
- gGL.rotatef(120.f, 1.f / F_SQRT3, 1.f / F_SQRT3, 1.f / F_SQRT3);
+ // the windlight sky dome works most conveniently in a coordinate system
+ // where Y is up, so permute our basis vectors accordingly.
+ gGL.rotatef(120.f, 1.f / F_SQRT3, 1.f / F_SQRT3, 1.f / F_SQRT3);
- gGL.scalef(0.333f, 0.333f, 0.333f);
+ gGL.scalef(0.333f, 0.333f, 0.333f);
- gGL.translatef(0.f,-camHeightLocal, 0.f);
+ gGL.translatef(0.f,-camHeightLocal, 0.f);
- // Draw WL Sky
- shader->uniform3f(sCamPosLocal, 0.f, camHeightLocal, 0.f);
+ // Draw WL Sky
+ shader->uniform3f(sCamPosLocal, 0.f, camHeightLocal, 0.f);
- gSky.mVOWLSkyp->drawDome();
+ gSky.mVOWLSkyp->drawDome();
- gGL.popMatrix();
- }
+ gGL.popMatrix();
}
-void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const
+void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const
{
if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))
{
@@ -181,6 +182,8 @@ void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const
sky_shader->bind();
+ LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
+
if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere)
{
// bind precomputed textures necessary for calculating sun and sky luminance
@@ -206,10 +209,14 @@ void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const
{
sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, sCloudNoiseTexture);
}
- }
- /// Render the skydome
- renderDome(camHeightLocal, sky_shader);
+ renderFsSky(origin, camHeightLocal, sky_shader);
+ }
+ else
+ {
+ /// Render the skydome
+ renderDome(origin, camHeightLocal, sky_shader);
+ }
sky_shader->unbind();
}
@@ -274,7 +281,7 @@ void LLDrawPoolWLSky::renderStars(void) const
}
}
-void LLDrawPoolWLSky::renderSkyClouds(F32 camHeightLocal) const
+void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal) const
{
if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && sCloudNoiseTexture.notNull())
{
@@ -286,7 +293,7 @@ void LLDrawPoolWLSky::renderSkyClouds(F32 camHeightLocal) const
cloud_shader->bind();
/// Render the skydome
- renderDome(camHeightLocal, cloud_shader);
+ renderDome(camPosLocal, camHeightLocal, cloud_shader);
cloud_shader->unbind();
}
@@ -362,7 +369,9 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
LLGLSquashToFarClip far_clip(glh_get_current_projection());
- renderSkyHaze(camHeightLocal);
+ LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
+
+ renderSkyHaze(origin, camHeightLocal);
if (!gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders())
{
@@ -387,7 +396,7 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
gGL.popMatrix();
}
- renderSkyClouds(camHeightLocal);
+ renderSkyClouds(origin, camHeightLocal);
gGL.setColorMask(true, true);
}
@@ -408,11 +417,12 @@ void LLDrawPoolWLSky::render(S32 pass)
LLGLSquashToFarClip far_clip(glh_get_current_projection());
- renderSkyHaze(camHeightLocal);
+ LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
+
+ renderSkyHaze(origin, camHeightLocal);
if (!gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders())
{
- LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
gGL.pushMatrix();
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
@@ -429,7 +439,7 @@ void LLDrawPoolWLSky::render(S32 pass)
gGL.popMatrix();
}
- renderSkyClouds(camHeightLocal);
+ renderSkyClouds(origin, camHeightLocal);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}