Full v2.6 renderer.

This commit is contained in:
Shyotl
2011-05-10 03:30:59 -05:00
parent 50310ba263
commit d1d6994419
117 changed files with 8031 additions and 1234 deletions

View File

@@ -55,7 +55,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;
@@ -79,9 +80,11 @@ LLDrawPoolWater::LLDrawPoolWater() :
mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
mWaterImagep = LLViewerTextureManager::getFetchedTexture(WATER_TEST);
mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE);
llassert(mWaterImagep);
mWaterImagep->setNoDelete() ;
mWaterImagep->setNoDelete();
mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE);
llassert(mOpaqueWaterImagep);
mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL);
mWaterNormp->setNoDelete();
@@ -169,6 +172,13 @@ void LLDrawPoolWater::render(S32 pass)
}
std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater());
static const LLCachedControl<bool> render_transparent_water("RenderTransparentWater",false);
if(!render_transparent_water)
{
// render water for low end hardware
renderOpaqueLegacyWater();
return;
}
LLGLEnable blend(GL_BLEND);
@@ -323,6 +333,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;
@@ -603,23 +694,6 @@ void LLDrawPoolWater::shade()
}
void LLDrawPoolWater::renderForSelect()
{
// Can't select water!
return;
}
void LLDrawPoolWater::renderFaceSelected(LLFace *facep,
LLViewerTexture *image,
const LLColor4 &color,
const S32 index_offset, const S32 index_count)
{
// Can't select water
return;
}
LLViewerTexture *LLDrawPoolWater::getDebugTexture()
{
return LLViewerFetchedTexture::sSmokeImagep;