summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolwater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolwater.cpp')
-rw-r--r--indra/newview/lldrawpoolwater.cpp335
1 files changed, 172 insertions, 163 deletions
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index ca2f5ebb86..ce1b899d55 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -2,30 +2,25 @@
* @file lldrawpoolwater.cpp
* @brief LLDrawPoolWater class implementation
*
- * $LicenseInfo:firstyear=2002&license=viewergpl$
- *
- * Copyright (c) 2002-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -37,45 +32,49 @@
#include "lldir.h"
#include "llerror.h"
#include "m3math.h"
+#include "llrender.h"
#include "llagent.h" // for gAgent for getRegion for getWaterHeight
#include "llcubemap.h"
#include "lldrawable.h"
#include "llface.h"
#include "llsky.h"
-#include "llviewercamera.h" // to get OGL_TO_CFR_ROTATION
-#include "llviewerimagelist.h"
+#include "llviewertexturelist.h"
#include "llviewerregion.h"
#include "llvosky.h"
#include "llvowater.h"
#include "llworld.h"
#include "pipeline.h"
-#include "llglslshader.h"
+#include "llviewershadermgr.h"
#include "llwaterparammanager.h"
const LLUUID WATER_TEST("2bfd3884-7e27-69b9-ba3a-3e673f680004");
static float sTime;
+BOOL deferred_render = FALSE;
+
BOOL LLDrawPoolWater::sSkipScreenCopy = FALSE;
BOOL LLDrawPoolWater::sNeedsReflectionUpdate = TRUE;
+BOOL LLDrawPoolWater::sNeedsDistortionUpdate = TRUE;
LLColor4 LLDrawPoolWater::sWaterFogColor = LLColor4(0.2f, 0.5f, 0.5f, 0.f);
LLVector3 LLDrawPoolWater::sLightDir;
LLDrawPoolWater::LLDrawPoolWater() :
LLFacePool(POOL_WATER)
{
- mHBTex[0] = gImageList.getImage(gSunTextureID, TRUE, TRUE);
- mHBTex[0]->bind();
- mHBTex[0]->setClamp(TRUE, TRUE);
+ mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, TRUE, LLViewerTexture::BOOST_UI);
+ gGL.getTexUnit(0)->bind(mHBTex[0]) ;
+ mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP);
- mHBTex[1] = gImageList.getImage(gMoonTextureID, TRUE, TRUE);
- mHBTex[1]->bind();
- mHBTex[1]->setClamp(TRUE, TRUE);
+ mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, TRUE, LLViewerTexture::BOOST_UI);
+ gGL.getTexUnit(0)->bind(mHBTex[1]);
+ mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
- mWaterImagep = gImageList.getImage(WATER_TEST);
- //mWaterNormp = gImageList.getImage(LLUUID(gViewerArt.getString("water_normal.tga")));
- mWaterNormp = gImageList.getImage(LLWaterParamManager::instance()->getNormalMapID());
+ mWaterImagep = LLViewerTextureManager::getFetchedTexture(WATER_TEST);
+ mWaterImagep->setNoDelete() ;
+ mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL);
+ mWaterNormp->setNoDelete() ;
restoreGL();
}
@@ -99,8 +98,8 @@ LLDrawPool *LLDrawPoolWater::instancePool()
void LLDrawPoolWater::prerender()
{
- mVertexShaderLevel = (gGLManager.mHasCubeMap && gFeatureManagerp->isFeatureAvailable("RenderCubeMap")) ?
- LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_WATER) : 0;
+ mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ?
+ LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0;
// got rid of modulation by light color since it got a little too
// green at sunset and sl-57047 (underwater turns black at 8:00)
@@ -111,7 +110,7 @@ void LLDrawPoolWater::prerender()
S32 LLDrawPoolWater::getNumPasses()
{
- if (gCamera->getOrigin().mV[2] < 1024.f)
+ if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f)
{
return 1;
}
@@ -119,9 +118,34 @@ S32 LLDrawPoolWater::getNumPasses()
return 0;
}
+void LLDrawPoolWater::beginPostDeferredPass(S32 pass)
+{
+ beginRenderPass(pass);
+ deferred_render = TRUE;
+}
+
+void LLDrawPoolWater::endPostDeferredPass(S32 pass)
+{
+ endRenderPass(pass);
+ deferred_render = FALSE;
+}
+
+//===============================
+//DEFERRED IMPLEMENTATION
+//===============================
+void LLDrawPoolWater::renderDeferred(S32 pass)
+{
+ LLFastTimer t(FTM_RENDER_WATER);
+ deferred_render = TRUE;
+ shade();
+ deferred_render = FALSE;
+}
+
+//=========================================
+
void LLDrawPoolWater::render(S32 pass)
{
- LLFastTimer ftm(LLFastTimer::FTM_RENDER_WATER);
+ LLFastTimer ftm(FTM_RENDER_WATER);
if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1)
{
return;
@@ -163,24 +187,17 @@ void LLDrawPoolWater::render(S32 pass)
LLGLDisable cullFace(GL_CULL_FACE);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
-
// Set up second pass first
- glActiveTextureARB(GL_TEXTURE1_ARB);
mWaterImagep->addTextureStats(1024.f*1024.f);
- mWaterImagep->bind(1);
-
- glClientActiveTextureARB(GL_TEXTURE1_ARB);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D); // Texture unit 1
+ gGL.getTexUnit(1)->activate();
+ gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(1)->bind(mWaterImagep) ;
- LLVector3 camera_up = gCamera->getUpAxis();
+ LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
F32 up_dot = camera_up * LLVector3::z_axis;
LLColor4 water_color;
- if (gCamera->cameraUnderWater())
+ if (LLViewerCamera::getInstance()->cameraUnderWater())
{
water_color.setVec(1.f, 1.f, 1.f, 0.4f);
}
@@ -204,19 +221,10 @@ void LLDrawPoolWater::render(S32 pass)
glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
+ gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
+ gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
-
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
- glActiveTextureARB(GL_TEXTURE0_ARB);
+ gGL.getTexUnit(0)->activate();
glClearStencil(1);
glClear(GL_STENCIL_BUFFER_BIT);
@@ -232,25 +240,21 @@ void LLDrawPoolWater::render(S32 pass)
{
continue;
}
- face->bindTexture();
+ gGL.getTexUnit(0)->bind(face->getTexture());
face->renderIndexed();
- mIndicesDrawn += face->getIndicesCount();
}
// Now, disable texture coord generation on texture state 1
- glClientActiveTextureARB(GL_TEXTURE1_ARB);
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glDisable(GL_TEXTURE_2D); // Texture unit 1
+ gGL.getTexUnit(1)->activate();
+ gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(1)->disable();
glDisable(GL_TEXTURE_GEN_S); //texture unit 1
glDisable(GL_TEXTURE_GEN_T); //texture unit 1
- LLImageGL::unbindTexture(1, GL_TEXTURE_2D);
// Disable texture coordinate and color arrays
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
- glActiveTextureARB(GL_TEXTURE0_ARB);
- LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
+ gGL.getTexUnit(0)->activate();
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
stop_glerror();
if (gSky.mVOSkyp->getCubeMap())
@@ -260,7 +264,7 @@ void LLDrawPoolWater::render(S32 pass)
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
- LLMatrix4 camera_mat = gCamera->getModelview();
+ LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview();
LLMatrix4 camera_rot(camera_mat.getMat3());
camera_rot.invert();
@@ -269,7 +273,7 @@ void LLDrawPoolWater::render(S32 pass)
glMatrixMode(GL_MODELVIEW);
LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f, 0.5f*up_dot);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
iter != mDrawFace.end(); iter++)
@@ -284,18 +288,15 @@ void LLDrawPoolWater::render(S32 pass)
if (face->getGeomCount() > 0)
{
face->renderIndexed();
- mIndicesDrawn += face->getIndicesCount();
}
}
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
- if (gSky.mVOSkyp->getCubeMap())
- {
- gSky.mVOSkyp->getCubeMap()->disable();
- }
- LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
- glEnable(GL_TEXTURE_2D);
+ gSky.mVOSkyp->getCubeMap()->disable();
+
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
@@ -310,10 +311,7 @@ void LLDrawPoolWater::render(S32 pass)
renderReflection(refl_face);
}
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
-
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
}
void LLDrawPoolWater::renderReflection(LLFace* face)
@@ -338,21 +336,18 @@ void LLDrawPoolWater::renderReflection(LLFace* face)
LLGLSNoFog noFog;
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-
- LLViewerImage::bindTexture(mHBTex[dr]);
+ gGL.getTexUnit(0)->bind(mHBTex[dr]);
LLOverrideFaceColor override(this, face->getFaceColor().mV);
face->renderIndexed();
- mIndicesDrawn += face->getIndicesCount();
-
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
void LLDrawPoolWater::shade()
{
- glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
+ if (!deferred_render)
+ {
+ gGL.setColorMask(true, true);
+ }
LLVOSky *voskyp = gSky.mVOSkyp;
@@ -361,10 +356,6 @@ void LLDrawPoolWater::shade()
return;
}
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
-
LLGLDisable blend(GL_BLEND);
LLColor3 light_diffuse(0,0,0);
@@ -372,7 +363,7 @@ void LLDrawPoolWater::shade()
LLVector3 light_dir;
LLColor3 light_color;
- if (gSky.getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS)
+ if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS)
{
light_dir = gSky.getSunDirection();
light_dir.normVec();
@@ -404,9 +395,13 @@ void LLDrawPoolWater::shade()
LLGLSLShader* shader;
- F32 eyedepth = gCamera->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight();
+ F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight();
- if (eyedepth < 0.f && LLPipeline::sWaterReflections)
+ if (deferred_render)
+ {
+ shader = &gDeferredWaterProgram;
+ }
+ else if (eyedepth < 0.f && LLPipeline::sWaterReflections)
{
shader = &gUnderWaterProgram;
}
@@ -415,57 +410,66 @@ void LLDrawPoolWater::shade()
shader = &gWaterProgram;
}
+ if (deferred_render)
+ {
+ gPipeline.bindDeferredShader(*shader);
+ }
+ else
+ {
+ shader->bind();
+ }
+
sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f;
- S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX);
+ S32 reftex = shader->enableTexture(LLViewerShaderMgr::WATER_REFTEX);
if (reftex > -1)
{
- glActiveTextureARB(GL_TEXTURE0_ARB+reftex);
- gPipeline.mWaterRef.bindTexture();
- glActiveTextureARB(GL_TEXTURE0_ARB);
+ gGL.getTexUnit(reftex)->activate();
+ gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef);
+ gGL.getTexUnit(0)->activate();
}
//bind normal map
- S32 bumpTex = shader->enableTexture(LLShaderMgr::BUMP_MAP);
+ S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP);
LLWaterParamManager * param_mgr = LLWaterParamManager::instance();
// change mWaterNormp if needed
if (mWaterNormp->getID() != param_mgr->getNormalMapID())
{
- mWaterNormp = gImageList.getImage(param_mgr->getNormalMapID());
+ mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID());
}
mWaterNormp->addTextureStats(1024.f*1024.f);
- mWaterNormp->bind(bumpTex);
- if (!gSavedSettings.getBOOL("RenderWaterMipNormal"))
+ gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ;
+ if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
{
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
}
- else
+ else
{
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT);
}
- S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);
- stop_glerror();
-
- shader->bind();
-
+ S32 screentex = shader->enableTexture(LLViewerShaderMgr::WATER_SCREENTEX);
+
if (screentex > -1)
{
- shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
- shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY,
+ shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
+ shader->uniform1f(LLViewerShaderMgr::WATER_FOGDENSITY,
param_mgr->getFogDensity());
+ gPipeline.mWaterDis.bindTexture(0, screentex);
}
- gPipeline.mWaterDis.bindTexture();
+ stop_glerror();
+
+ gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);
if (mVertexShaderLevel == 1)
{
sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue;
- shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
+ shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
}
F32 screenRes[] =
@@ -476,7 +480,7 @@ void LLDrawPoolWater::shade()
shader->uniform2fv("screenRes", 1, screenRes);
stop_glerror();
- S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
+ S32 diffTex = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
stop_glerror();
light_dir.normVec();
@@ -485,14 +489,14 @@ void LLDrawPoolWater::shade()
light_diffuse *= 6.f;
//shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix);
- shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth);
- shader->uniform1f(LLShaderMgr::WATER_TIME, sTime);
- shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, gCamera->getOrigin().mV);
- shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
- shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp);
- shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV);
- shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV);
- shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
+ shader->uniform1f(LLViewerShaderMgr::WATER_WATERHEIGHT, eyedepth);
+ shader->uniform1f(LLViewerShaderMgr::WATER_TIME, sTime);
+ shader->uniform3fv(LLViewerShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);
+ shader->uniform3fv(LLViewerShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
+ shader->uniform1f(LLViewerShaderMgr::WATER_SPECULAR_EXP, light_exp);
+ shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV);
+ shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV);
+ shader->uniform3fv(LLViewerShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
shader->uniform3fv("normScale", 1, param_mgr->getNormalScale().mV);
shader->uniform1f("fresnelScale", param_mgr->getFresnelScale());
@@ -507,17 +511,17 @@ void LLDrawPoolWater::shade()
shader->uniform1f("sunAngle2", 0.1f + 0.2f*sunAngle);
LLColor4 water_color;
- LLVector3 camera_up = gCamera->getUpAxis();
+ LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
F32 up_dot = camera_up * LLVector3::z_axis;
- if (gCamera->cameraUnderWater())
+ if (LLViewerCamera::getInstance()->cameraUnderWater())
{
water_color.setVec(1.f, 1.f, 1.f, 0.4f);
- shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow());
+ shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow());
}
else
{
water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
- shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove());
+ shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove());
}
if (water_color.mV[3] > 0.9f)
@@ -540,44 +544,60 @@ void LLDrawPoolWater::shade()
}
LLVOWater* water = (LLVOWater*) face->getViewerObject();
- face->bindTexture(diffTex);
+ gGL.getTexUnit(diffTex)->bind(face->getTexture());
sNeedsReflectionUpdate = TRUE;
if (water->getUseTexture())
{
+ sNeedsDistortionUpdate = TRUE;
face->renderIndexed();
}
else
{ //smash background faces to far clip plane
if (water->getIsEdgePatch())
{
- LLGLClampToFarClip far_clip(glh_get_current_projection());
- face->renderIndexed();
+ if (deferred_render)
+ {
+ face->renderIndexed();
+ }
+ else
+ {
+ LLGLClampToFarClip far_clip(glh_get_current_projection());
+ face->renderIndexed();
+ }
}
else
{
+ sNeedsDistortionUpdate = TRUE;
face->renderIndexed();
}
}
-
- mIndicesDrawn += face->getIndicesCount();
}
}
- shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, GL_TEXTURE_CUBE_MAP_ARB);
- shader->disableTexture(LLShaderMgr::WATER_SCREENTEX);
- shader->disableTexture(LLShaderMgr::BUMP_MAP);
- shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
- shader->disableTexture(LLShaderMgr::WATER_REFTEX);
- shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
- shader->unbind();
-
- glActiveTextureARB(GL_TEXTURE0_ARB);
- glClientActiveTextureARB(GL_TEXTURE0_ARB);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
- glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE);
+ shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
+ shader->disableTexture(LLViewerShaderMgr::WATER_SCREENTEX);
+ shader->disableTexture(LLViewerShaderMgr::BUMP_MAP);
+ shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
+ shader->disableTexture(LLViewerShaderMgr::WATER_REFTEX);
+ shader->disableTexture(LLViewerShaderMgr::WATER_SCREENDEPTH);
+
+ if (deferred_render)
+ {
+ gPipeline.unbindDeferredShader(*shader);
+ }
+ else
+ {
+ shader->unbind();
+ }
+
+ gGL.getTexUnit(0)->activate();
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+ if (!deferred_render)
+ {
+ gGL.setColorMask(true, false);
+ }
}
@@ -587,20 +607,9 @@ void LLDrawPoolWater::renderForSelect()
return;
}
-
-void LLDrawPoolWater::renderFaceSelected(LLFace *facep,
- LLImageGL *image,
- const LLColor4 &color,
- const S32 index_offset, const S32 index_count)
-{
- // Can't select water
- return;
-}
-
-
-LLViewerImage *LLDrawPoolWater::getDebugTexture()
+LLViewerTexture *LLDrawPoolWater::getDebugTexture()
{
- return LLViewerImage::sSmokeImagep;
+ return LLViewerFetchedTexture::sSmokeImagep;
}
LLColor3 LLDrawPoolWater::getDebugColor() const