summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolwlsky.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolwlsky.cpp')
-rw-r--r--indra/newview/lldrawpoolwlsky.cpp157
1 files changed, 85 insertions, 72 deletions
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index a28041034b..e5a7398d4f 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,97 +126,104 @@ 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);
-
- static LLStaticHashedString sCamPosLocal("camPosLocal");
-
- LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
-
- 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]);
+ // Draw WL Sky w/ normal cam pos (where you are) for adv atmo sky
+ //gGL.syncMatrices();
+ sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]);
+ gSky.mVOWLSkyp->drawFsSky();
+}
-// 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::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const
{
- if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))
- {
- LLGLDisable blend(GL_BLEND);
-
+ if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere)
+ {
sky_shader->bind();
- if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere)
- {
- // bind precomputed textures necessary for calculating sun and sky luminance
- sky_shader->bindTexture(LLShaderMgr::TRANSMITTANCE_TEX, gAtmosphere->getTransmittance());
- sky_shader->bindTexture(LLShaderMgr::SCATTER_TEX, gAtmosphere->getScattering());
- sky_shader->bindTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, gAtmosphere->getMieScattering());
+ // bind precomputed textures necessary for calculating sun and sky luminance
+ sky_shader->bindTexture(LLShaderMgr::TRANSMITTANCE_TEX, gAtmosphere->getTransmittance());
+ sky_shader->bindTexture(LLShaderMgr::SCATTER_TEX, gAtmosphere->getScattering());
+ sky_shader->bindTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, gAtmosphere->getMieScattering());
+ sky_shader->bindTexture(LLShaderMgr::ILLUMINANCE_TEX, gAtmosphere->getIlluminance());
+
+ static float sunSize = (float)cos(0.0005);
- static float sunSize = (float)cos(0.0005);
+ sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize);
- sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize);
+ static LLVector3 solDir(-0.935f, 0.23f, 0.27f);
- static LLVector3 solDir(0.7f, 0.2f, 0.2f);
+ static bool fooA = false;
+ static bool fooB = false;
- //neither of these appear to track with the env settings, would the real sun please stand up.
- //sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, gPipeline.mTransformedSunDir.mV);
- //sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, gSky.mVOSkyp->getSun().getDirection().mV);
- solDir.normalize();
+ //neither of these appear to track with the env settings, would the real sun please stand up.
+ if (fooA) solDir = gPipeline.mTransformedSunDir;
+ if (fooB) solDir = gSky.mVOSkyp->getSun().getDirection();
- sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, solDir.mV);
+ solDir.normalize();
- // clouds are rendered along with sky in adv atmo
- if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && sCloudNoiseTexture.notNull())
- {
- sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, sCloudNoiseTexture);
- }
+ sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, solDir.mV);
+
+ // clouds are rendered along with sky in adv atmo
+ if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && sCloudNoiseTexture.notNull())
+ {
+ sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, sCloudNoiseTexture);
}
- /// Render the skydome
- renderDome(camHeightLocal, sky_shader);
+ renderFsSky(camPosLocal, camHeightLocal, sky_shader);
sky_shader->unbind();
}
}
+void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const
+{
+ LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
+
+ if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))
+ {
+ LLGLDisable blend(GL_BLEND);
+ sky_shader->bind();
+
+ /// Render the skydome
+ renderDome(origin, camHeightLocal, sky_shader);
+
+ sky_shader->unbind();
+ }
+}
+
void LLDrawPoolWLSky::renderStars(void) const
{
LLGLSPipelineSkyBox gls_sky;
@@ -274,7 +283,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 +295,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();
}
@@ -360,16 +369,19 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
gGL.setColorMask(true, false);
- LLGLSquashToFarClip far_clip(glh_get_current_projection());
+ LLGLSquashToFarClip far_clip(get_current_projection());
+
+ LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
+
+ //renderSkyHazeDeferred(origin, camHeightLocal);
- renderSkyHaze(camHeightLocal);
+ 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]);
gDeferredStarProgram.bind();
@@ -387,7 +399,7 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
gGL.popMatrix();
}
- renderSkyClouds(camHeightLocal);
+ renderSkyClouds(origin, camHeightLocal);
gGL.setColorMask(true, true);
}
@@ -406,13 +418,14 @@ void LLDrawPoolWLSky::render(S32 pass)
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
LLGLDisable clip(GL_CLIP_PLANE0);
- LLGLSquashToFarClip far_clip(glh_get_current_projection());
+ LLGLSquashToFarClip far_clip(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 +442,7 @@ void LLDrawPoolWLSky::render(S32 pass)
gGL.popMatrix();
}
- renderSkyClouds(camHeightLocal);
+ renderSkyClouds(origin, camHeightLocal);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}