summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2010-11-05 14:30:09 -0400
committerLoren Shih <seraph@lindenlab.com>2010-11-05 14:30:09 -0400
commitab42f31608a2abc0982119d6aebdb0972d41427f (patch)
tree3fe2aa0824b3fbc621af8d0b6c3514e51d00d241 /indra/newview
parent94a40569aaa7dbf9a9474b465e818eed798bd3fd (diff)
SH-410 Opaque Water Project version 2.0
First implementation with UI changes.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/featuretable.txt5
-rw-r--r--indra/newview/featuretable_mac.txt5
-rw-r--r--indra/newview/featuretable_xp.txt5
-rw-r--r--indra/newview/lldrawpoolwater.cpp102
-rw-r--r--indra/newview/lldrawpoolwater.h4
-rw-r--r--indra/newview/llviewercontrol.cpp14
-rw-r--r--indra/newview/llvowater.cpp18
-rw-r--r--indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml18
9 files changed, 169 insertions, 13 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 3f23fee865..7b3f50e4e2 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -8318,6 +8318,17 @@
<key>Value</key>
<real>1.0</real>
</map>
+ <key>RenderTransparentWater</key>
+ <map>
+ <key>Comment</key>
+ <string>Render water as transparent. Setting to false renders water as opaque with a simple texture applied.</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>1</integer>
+ </map>
<key>RenderTreeLODFactor</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index d69842d5f1..a95abd7dd1 100644
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -42,6 +42,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 4
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVBOEnable 1 1
@@ -80,6 +81,7 @@ RenderObjectBump 1 0
RenderReflectionDetail 1 0
RenderTerrainDetail 1 0
RenderTerrainLODFactor 1 1
+RenderTransparentWater 1 0
RenderTreeLODFactor 1 0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 0.5
@@ -108,6 +110,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 0
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 1.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
@@ -135,6 +138,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 2
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
@@ -162,6 +166,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 4
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 2.0
diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt
index f030c9f8e5..6dabef53a8 100644
--- a/indra/newview/featuretable_mac.txt
+++ b/indra/newview/featuretable_mac.txt
@@ -43,6 +43,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 3
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVBOEnable 1 1
@@ -80,6 +81,7 @@ RenderObjectBump 1 0
RenderReflectionDetail 1 0
RenderTerrainDetail 1 0
RenderTerrainLODFactor 1 1
+RenderTransparentWater 1 0
RenderTreeLODFactor 1 0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 0.5
@@ -107,6 +109,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 0
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 1.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
@@ -133,6 +136,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 2
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
@@ -159,6 +163,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 3
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 2.0
diff --git a/indra/newview/featuretable_xp.txt b/indra/newview/featuretable_xp.txt
index dae7705971..a09ba17c62 100644
--- a/indra/newview/featuretable_xp.txt
+++ b/indra/newview/featuretable_xp.txt
@@ -42,6 +42,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 4
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVBOEnable 1 1
@@ -80,6 +81,7 @@ RenderObjectBump 1 0
RenderReflectionDetail 1 0
RenderTerrainDetail 1 0
RenderTerrainLODFactor 1 1
+RenderTransparentWater 1 0
RenderTreeLODFactor 1 0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 0.5
@@ -108,6 +110,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 0
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 1.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
@@ -135,6 +138,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 2
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 0.5
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 1.125
@@ -162,6 +166,7 @@ RenderObjectBump 1 1
RenderReflectionDetail 1 4
RenderTerrainDetail 1 1
RenderTerrainLODFactor 1 2.0
+RenderTransparentWater 1 1
RenderTreeLODFactor 1 1.0
RenderUseImpostors 1 1
RenderVolumeLODFactor 1 2.0
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 6126908231..f6b3ec7764 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;
diff --git a/indra/newview/lldrawpoolwater.h b/indra/newview/lldrawpoolwater.h
index 3ab4bc5e2c..dff1830129 100644
--- a/indra/newview/lldrawpoolwater.h
+++ b/indra/newview/lldrawpoolwater.h
@@ -39,6 +39,7 @@ class LLDrawPoolWater: public LLFacePool
protected:
LLPointer<LLViewerTexture> mHBTex[2];
LLPointer<LLViewerTexture> mWaterImagep;
+ LLPointer<LLViewerTexture> mOpaqueWaterImagep;
LLPointer<LLViewerTexture> mWaterNormp;
public:
@@ -81,6 +82,9 @@ public:
void renderReflection(LLFace* face);
void shade();
+
+protected:
+ void renderOpaqueLegacyWater();
};
void cgErrorCallback();
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index fbec2a7b9e..117e49d67f 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -117,10 +117,23 @@ static bool handleSetShaderChanged(const LLSD& newvalue)
gBumpImageList.destroyGL();
gBumpImageList.restoreGL();
+ // Changing shader also changes the terrain detail to high, reflect that change here
+ if (newvalue.asBoolean())
+ {
+ // shaders enabled, set terrain detail to high
+ gSavedSettings.setS32("RenderTerrainDetail", 1);
+ }
+ // else, leave terrain detail as is
LLViewerShaderMgr::instance()->setShaders();
return true;
}
+bool handleRenderTransparentWaterChanged(const LLSD& newvalue)
+{
+ LLWorld::getInstance()->updateWaterObjects();
+ return true;
+}
+
static bool handleReleaseGLBufferChanged(const LLSD& newvalue)
{
if (gPipeline.isInit())
@@ -637,6 +650,7 @@ void settings_setup_listeners()
gSavedSettings.getControl("ShowMiniLocationPanel")->getSignal()->connect(boost::bind(&toggle_show_mini_location_panel, _2));
gSavedSettings.getControl("ShowObjectRenderingCost")->getSignal()->connect(boost::bind(&toggle_show_object_render_cost, _2));
gSavedSettings.getControl("ForceShowGrid")->getSignal()->connect(boost::bind(&handleForceShowGrid, _2));
+ gSavedSettings.getControl("RenderTransparentWater")->getSignal()->connect(boost::bind(&handleRenderTransparentWaterChanged, _2));
}
#if TEST_CACHED_CONTROL
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp
index 9280eb8fa4..71f08ec36d 100644
--- a/indra/newview/llvowater.cpp
+++ b/indra/newview/llvowater.cpp
@@ -60,8 +60,10 @@ const U32 WIDTH = (N_RES * WAVE_STEP); //128.f //64 // width of wave tile, in
const F32 WAVE_STEP_INV = (1. / WAVE_STEP);
-LLVOWater::LLVOWater(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
-: LLStaticViewerObject(id, pcode, regionp),
+LLVOWater::LLVOWater(const LLUUID &id,
+ const LLPCode pcode,
+ LLViewerRegion *regionp) :
+ LLStaticViewerObject(id, pcode, regionp),
mRenderType(LLPipeline::RENDER_TYPE_WATER)
{
// Terrain must draw during selection passes so it can block objects behind it.
@@ -153,11 +155,17 @@ BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
LLStrider<U16> indicesp;
U16 index_offset;
- S32 size = 16;
- S32 num_quads = size*size;
- face->setSize(4*num_quads, 6*num_quads);
+ // A quad is 4 vertices and 6 indices (making 2 triangles)
+ static const unsigned int vertices_per_quad = 4;
+ static const unsigned int indices_per_quad = 6;
+ const S32 size = gSavedSettings.getBOOL("RenderTransparentWater") ? 16 : 1;
+
+ const S32 num_quads = size * size;
+ face->setSize(vertices_per_quad * num_quads,
+ indices_per_quad * num_quads);
+
if (face->mVertexBuffer.isNull())
{
face->mVertexBuffer = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_DYNAMIC_DRAW_ARB);
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index aae373ed33..3ceee60927 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -175,6 +175,16 @@
Shaders:
</text>
<check_box
+ control_name="RenderTransparentWater"
+ height="16"
+ initial_value="true"
+ label="Transparent Water"
+ layout="topleft"
+ left_delta="0"
+ name="BumpShiny"
+ top_pad="7"
+ width="256" />
+ <check_box
control_name="RenderObjectBump"
height="16"
initial_value="true"
@@ -182,7 +192,7 @@
layout="topleft"
left_delta="0"
name="BumpShiny"
- top_pad="7"
+ top_pad="1"
width="256" />
<check_box
control_name="VertexShaderEnable"
@@ -279,7 +289,7 @@
length="1"
top_pad="8"
follows="top|left"
- height="23"
+ height="12"
width="110"
word_wrap="true"
layout="topleft"
@@ -289,10 +299,10 @@
</text>
<combo_box
control_name="RenderReflectionDetail"
- height="23"
+ height="18"
layout="topleft"
left_delta="10"
- top_pad ="0"
+ top_pad ="3"
name="Reflections"
width="150">
<combo_box.item