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.cpp136
1 files changed, 107 insertions, 29 deletions
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index ce1b899d55..dc94924da4 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -48,7 +48,8 @@
#include "llviewershadermgr.h"
#include "llwaterparammanager.h"
-const LLUUID WATER_TEST("2bfd3884-7e27-69b9-ba3a-3e673f680004");
+const LLUUID TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004");
+const LLUUID OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055");
static float sTime;
@@ -71,10 +72,14 @@ LLDrawPoolWater::LLDrawPoolWater() :
gGL.getTexUnit(0)->bind(mHBTex[1]);
mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
- mWaterImagep = LLViewerTextureManager::getFetchedTexture(WATER_TEST);
- mWaterImagep->setNoDelete() ;
+
+ mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE);
+ llassert(mWaterImagep);
+ mWaterImagep->setNoDelete();
+ mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE);
+ llassert(mOpaqueWaterImagep);
mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL);
- mWaterNormp->setNoDelete() ;
+ mWaterNormp->setNoDelete();
restoreGL();
}
@@ -161,6 +166,14 @@ void LLDrawPoolWater::render(S32 pass)
std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater());
+ // See if we are rendering water as opaque or not
+ if (!gSavedSettings.getBOOL("RenderTransparentWater"))
+ {
+ // render water for low end hardware
+ renderOpaqueLegacyWater();
+ return;
+ }
+
LLGLEnable blend(GL_BLEND);
if ((mVertexShaderLevel > 0) && !sSkipScreenCopy)
@@ -314,6 +327,87 @@ void LLDrawPoolWater::render(S32 pass)
gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
}
+// for low end hardware
+void LLDrawPoolWater::renderOpaqueLegacyWater()
+{
+ LLVOSky *voskyp = gSky.mVOSkyp;
+
+ stop_glerror();
+
+ // Depth sorting and write to depth buffer
+ // since this is opaque, we should see nothing
+ // behind the water. No blending because
+ // of no transparency. And no face culling so
+ // that the underside of the water is also opaque.
+ LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE);
+ LLGLDisable no_cull(GL_CULL_FACE);
+ LLGLDisable no_blend(GL_BLEND);
+
+ gPipeline.disableLights();
+
+ mOpaqueWaterImagep->addTextureStats(1024.f*1024.f);
+
+ // Activate the texture binding and bind one
+ // texture since all images will have the same texture
+ gGL.getTexUnit(0)->activate();
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(0)->bind(mOpaqueWaterImagep);
+
+ // Automatically generate texture coords for water texture
+ glEnable(GL_TEXTURE_GEN_S); //texture unit 0
+ glEnable(GL_TEXTURE_GEN_T); //texture unit 0
+ glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+ glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+
+ // Use the fact that we know all water faces are the same size
+ // to save some computation
+
+ // Slowly move texture coordinates over time so the watter appears
+ // to be moving.
+ F32 movement_period_secs = 50.f;
+
+ F32 offset = fmod(gFrameTimeSeconds, movement_period_secs);
+
+ if (movement_period_secs != 0)
+ {
+ offset /= movement_period_secs;
+ }
+ else
+ {
+ offset = 0;
+ }
+
+ F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset };
+ F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset };
+
+ glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
+ glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
+
+ glColor3f(1.f, 1.f, 1.f);
+
+ for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+ iter != mDrawFace.end(); iter++)
+ {
+ LLFace *face = *iter;
+ if (voskyp->isReflFace(face))
+ {
+ continue;
+ }
+
+ face->renderIndexed();
+ }
+
+ stop_glerror();
+
+ // Reset the settings back to expected values
+ glDisable(GL_TEXTURE_GEN_S); //texture unit 0
+ glDisable(GL_TEXTURE_GEN_T); //texture unit 0
+
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+}
+
+
void LLDrawPoolWater::renderReflection(LLFace* face)
{
LLVOSky *voskyp = gSky.mVOSkyp;
@@ -532,6 +626,7 @@ void LLDrawPoolWater::shade()
glColor4fv(water_color.mV);
{
+ LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0);
LLGLDisable cullface(GL_CULL_FACE);
for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
iter != mDrawFace.end(); iter++)
@@ -548,30 +643,19 @@ void LLDrawPoolWater::shade()
sNeedsReflectionUpdate = TRUE;
- if (water->getUseTexture())
+ if (water->getUseTexture() || !water->getIsEdgePatch())
{
sNeedsDistortionUpdate = TRUE;
face->renderIndexed();
}
+ else if (gGLManager.mHasDepthClamp || deferred_render)
+ {
+ face->renderIndexed();
+ }
else
- { //smash background faces to far clip plane
- if (water->getIsEdgePatch())
- {
- if (deferred_render)
- {
- face->renderIndexed();
- }
- else
- {
- LLGLClampToFarClip far_clip(glh_get_current_projection());
- face->renderIndexed();
- }
- }
- else
- {
- sNeedsDistortionUpdate = TRUE;
- face->renderIndexed();
- }
+ {
+ LLGLSquashToFarClip far_clip(glh_get_current_projection());
+ face->renderIndexed();
}
}
}
@@ -601,12 +685,6 @@ void LLDrawPoolWater::shade()
}
-void LLDrawPoolWater::renderForSelect()
-{
- // Can't select water!
- return;
-}
-
LLViewerTexture *LLDrawPoolWater::getDebugTexture()
{
return LLViewerFetchedTexture::sSmokeImagep;