summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolavatar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolavatar.cpp')
-rw-r--r--indra/newview/lldrawpoolavatar.cpp160
1 files changed, 121 insertions, 39 deletions
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 546b60f286..62226383a4 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -53,8 +53,9 @@
static U32 sDataMask = LLDrawPoolAvatar::VERTEX_DATA_MASK;
static U32 sBufferUsage = GL_STREAM_DRAW_ARB;
static U32 sShaderLevel = 0;
-static LLGLSLShader* sVertexProgram = NULL;
+
+LLGLSLShader* LLDrawPoolAvatar::sVertexProgram = NULL;
BOOL LLDrawPoolAvatar::sSkipOpaque = FALSE;
BOOL LLDrawPoolAvatar::sSkipTransparent = FALSE;
@@ -123,7 +124,7 @@ void LLDrawPoolAvatar::prerender()
if (sShaderLevel > 0)
{
- sBufferUsage = GL_STATIC_DRAW_ARB;
+ sBufferUsage = GL_DYNAMIC_DRAW_ARB;
}
else
{
@@ -157,6 +158,8 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
{
LLFastTimer t(FTM_RENDER_CHARACTERS);
+ sSkipTransparent = TRUE;
+
if (LLPipeline::sImpostorRender)
{
beginDeferredSkinned();
@@ -174,6 +177,9 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
case 2:
beginDeferredSkinned();
break;
+ case 3:
+ beginDeferredRigged();
+ break;
}
}
@@ -181,6 +187,8 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass)
{
LLFastTimer t(FTM_RENDER_CHARACTERS);
+ sSkipTransparent = FALSE;
+
if (LLPipeline::sImpostorRender)
{
endDeferredSkinned();
@@ -198,6 +206,8 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass)
case 2:
endDeferredSkinned();
break;
+ case 3:
+ endDeferredRigged();
}
}
@@ -244,43 +254,58 @@ void LLDrawPoolAvatar::renderPostDeferred(S32 pass)
S32 LLDrawPoolAvatar::getNumShadowPasses()
{
- return 1;
+ return 2;
}
void LLDrawPoolAvatar::beginShadowPass(S32 pass)
{
LLFastTimer t(FTM_SHADOW_AVATAR);
-
- sVertexProgram = &gDeferredAvatarShadowProgram;
- if (sShaderLevel > 0)
+
+ if (pass == 0)
{
- gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
- }
- gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f);
-
- glColor4f(1,1,1,1);
+ sVertexProgram = &gDeferredAvatarShadowProgram;
+ if (sShaderLevel > 0)
+ {
+ gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
+ }
+ gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f);
+
+ glColor4f(1,1,1,1);
- if ((sShaderLevel > 0)) // for hardware blending
+ if ((sShaderLevel > 0)) // for hardware blending
+ {
+ sRenderingSkinned = TRUE;
+ sVertexProgram->bind();
+ enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
+ }
+ }
+ else
{
- sRenderingSkinned = TRUE;
+ sVertexProgram = &gDeferredAttachmentShadowProgram;
sVertexProgram->bind();
- enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
+ LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
}
-
}
void LLDrawPoolAvatar::endShadowPass(S32 pass)
{
LLFastTimer t(FTM_SHADOW_AVATAR);
-
- if (sShaderLevel > 0)
+ if (pass == 0)
{
- sRenderingSkinned = FALSE;
+ if (sShaderLevel > 0)
+ {
+ sRenderingSkinned = FALSE;
+ sVertexProgram->unbind();
+ disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
+ }
+ }
+ else
+ {
+ LLVertexBuffer::unbind();
sVertexProgram->unbind();
- disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
+ LLVertexBuffer::sWeight4Loc = -1;
+ sVertexProgram = NULL;
}
-
- gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
}
void LLDrawPoolAvatar::renderShadow(S32 pass)
@@ -310,13 +335,35 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
return;
}
- avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
+ if (pass == 0)
+ {
+ if (sShaderLevel > 0)
+ {
+ gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX];
+ }
+ avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
+ }
+ else
+ {
+ avatarp->renderSkinnedAttachments();
+ }
}
S32 LLDrawPoolAvatar::getNumPasses()
{
- return LLPipeline::sImpostorRender ? 1 : 3;
+ if (LLPipeline::sImpostorRender)
+ {
+ return 1;
+ }
+ else if (getVertexShaderLevel() > 0)
+ {
+ return 4;
+ }
+ else
+ {
+ return 3;
+ }
}
void LLDrawPoolAvatar::render(S32 pass)
@@ -346,7 +393,7 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
switch (pass)
{
case 0:
- beginFootShadow();
+ beginImpostor();
break;
case 1:
beginRigid();
@@ -354,6 +401,9 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
case 2:
beginSkinned();
break;
+ case 3:
+ beginRigged();
+ break;
}
}
@@ -370,17 +420,21 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass)
switch (pass)
{
case 0:
- endFootShadow();
+ endImpostor();
break;
case 1:
endRigid();
break;
case 2:
endSkinned();
+ break;
+ case 3:
+ endRigged();
+ break;
}
}
-void LLDrawPoolAvatar::beginFootShadow()
+void LLDrawPoolAvatar::beginImpostor()
{
if (!LLPipeline::sReflectionRender)
{
@@ -392,7 +446,7 @@ void LLDrawPoolAvatar::beginFootShadow()
diffuse_channel = 0;
}
-void LLDrawPoolAvatar::endFootShadow()
+void LLDrawPoolAvatar::endImpostor()
{
gPipeline.enableLightsDynamic();
}
@@ -562,9 +616,38 @@ void LLDrawPoolAvatar::endSkinned()
gGL.getTexUnit(0)->activate();
}
+void LLDrawPoolAvatar::beginRigged()
+{
+ sVertexProgram = &gSkinnedObjectSimpleProgram;
+ gSkinnedObjectSimpleProgram.bind();
+ LLVertexBuffer::sWeight4Loc = gSkinnedObjectSimpleProgram.getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endRigged()
+{
+ sVertexProgram = NULL;
+ LLVertexBuffer::unbind();
+ gSkinnedObjectSimpleProgram.unbind();
+ LLVertexBuffer::sWeight4Loc = -1;
+}
+
+void LLDrawPoolAvatar::beginDeferredRigged()
+{
+ sVertexProgram = &gDeferredSkinnedDiffuseProgram;
+ sVertexProgram->bind();
+ LLVertexBuffer::sWeight4Loc = sVertexProgram->getAttribLocation(LLViewerShaderMgr::OBJECT_WEIGHT);
+}
+
+void LLDrawPoolAvatar::endDeferredRigged()
+{
+ LLVertexBuffer::unbind();
+ sVertexProgram->unbind();
+ LLVertexBuffer::sWeight4Loc = -1;
+ sVertexProgram = NULL;
+}
+
void LLDrawPoolAvatar::beginDeferredSkinned()
{
- sSkipTransparent = TRUE;
sShaderLevel = mVertexShaderLevel;
sVertexProgram = &gDeferredAvatarProgram;
@@ -579,7 +662,6 @@ void LLDrawPoolAvatar::beginDeferredSkinned()
void LLDrawPoolAvatar::endDeferredSkinned()
{
- sSkipTransparent = FALSE;
// if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done
sRenderingSkinned = FALSE;
disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
@@ -691,10 +773,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
}
avatarp->renderImpostor(LLColor4U(255,255,255,255), diffuse_channel);
}
- else if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS) && !LLPipeline::sRenderDeferred)
- {
- avatarp->renderFootShadows();
- }
return;
}
@@ -709,6 +787,12 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
avatarp->renderRigid();
return;
}
+
+ if (pass == 3)
+ {
+ avatarp->renderSkinnedAttachments();
+ return;
+ }
if (sShaderLevel > 0)
{
@@ -848,9 +932,7 @@ LLColor3 LLDrawPoolAvatar::getDebugColor() const
LLVertexBufferAvatar::LLVertexBufferAvatar()
: LLVertexBuffer(sDataMask,
- LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_AVATAR) > 0 ?
- GL_DYNAMIC_DRAW_ARB :
- GL_STREAM_DRAW_ARB)
+ GL_STREAM_DRAW_ARB) //avatars are always stream draw due to morph targets
{
}
@@ -866,16 +948,16 @@ void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
glNormalPointer(GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_NORMAL]));
glTexCoordPointer(2,GL_FLOAT, mStride, (void*)(base + mOffsets[TYPE_TEXCOORD0]));
- set_vertex_weights(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT]));
+ set_vertex_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT], mStride, (F32*)(base + mOffsets[TYPE_WEIGHT]));
if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_BUMP)
{
- set_binormals(sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL]));
+ set_binormals(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL], mStride, (LLVector3*)(base + mOffsets[TYPE_BINORMAL]));
}
if (sShaderLevel >= LLDrawPoolAvatar::SHADER_LEVEL_CLOTH)
{
- set_vertex_clothing_weights(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
+ set_vertex_clothing_weights(LLDrawPoolAvatar::sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING], mStride, (LLVector4*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
}
}
else