diff options
Diffstat (limited to 'indra/newview/lldrawpoolwlsky.cpp')
-rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 198 |
1 files changed, 104 insertions, 94 deletions
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index a28041034b..def81e46fc 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,95 +126,92 @@ 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()); + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLVector4 light_dir = LLEnvironment::instance().getClampedLightNorm(); - static float sunSize = (float)cos(0.0005); + F32 sunSize = (float)cosf(psky->getSunArcRadians()); + sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); + sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, light_dir.mV); - sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); + // 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); + } - static LLVector3 solDir(0.7f, 0.2f, 0.2f); + renderFsSky(camPosLocal, camHeightLocal, sky_shader); - //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(); + sky_shader->unbind(); + } +} - sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, solDir.mV); +void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const +{ + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - // 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); - } - } + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) + { + LLGLDisable blend(GL_BLEND); + sky_shader->bind(); - /// Render the skydome - renderDome(camHeightLocal, sky_shader); + /// Render the skydome + renderDome(origin, camHeightLocal, sky_shader); sky_shader->unbind(); - } + } } void LLDrawPoolWLSky::renderStars(void) const @@ -274,7 +273,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 +285,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(); } @@ -319,17 +318,18 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() // since LLImageGL::bind detects that it's a noop, and optimizes it out. gGL.getTexUnit(0)->bind(face->getTexture()); LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor()); - F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2]; + + /*F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2]; if (a > 0.f) { a = a*a*4.f; - } - - color.mV[3] = llclamp(a, 0.f, 1.f); + } + color.mV[3] = llclamp(a, 0.f, 1.f);*/ if (gPipeline.canUseVertexShaders()) { gHighlightProgram.bind(); + gHighlightProgram.uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); } LLFacePool::LLOverrideFaceColor color_override(this, color); @@ -360,35 +360,42 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) gGL.setColorMask(true, false); - LLGLSquashToFarClip far_clip(glh_get_current_projection()); + LLGLSquashToFarClip far_clip(get_current_projection()); - renderSkyHaze(camHeightLocal); + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - if (!gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders()) + if (gPipeline.canUseWindLightShaders()) { - LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - gGL.pushMatrix(); + if (gPipeline.useAdvancedAtmospherics()) + { + renderSkyHazeDeferred(origin, camHeightLocal); + } + else + { + renderSkyHaze(origin, camHeightLocal); + + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + gGL.pushMatrix(); - - gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); + gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); - gDeferredStarProgram.bind(); - // *NOTE: have to bind a texture here since register combiners blending in - // renderStars() requires something to be bound and we might as well only - // bind the moon's texture once. - gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture()); + gDeferredStarProgram.bind(); + // *NOTE: have to bind a texture here since register combiners blending in + // renderStars() requires something to be bound and we might as well only + // bind the moon's texture once. + gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture()); - renderHeavenlyBodies(); + renderHeavenlyBodies(); - renderStars(); + renderStars(); - gDeferredStarProgram.unbind(); + gDeferredStarProgram.unbind(); - gGL.popMatrix(); - } + gGL.popMatrix(); - renderSkyClouds(camHeightLocal); - + renderSkyClouds(origin, camHeightLocal); + } + } gGL.setColorMask(true, true); } @@ -406,13 +413,16 @@ 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()); + + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - renderSkyHaze(camHeightLocal); + renderSkyHaze(origin, camHeightLocal); - if (!gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders()) + bool use_advanced = gPipeline.useAdvancedAtmospherics(); + + if (!use_advanced) { - 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); } |