V2 spatial partition, and all the pipeline changes that go with it.
Note: Deferred mode is not finished, and thus broken. Don't use!
This commit is contained in:
@@ -61,7 +61,9 @@ static BOOL deferred_render = FALSE;
|
||||
|
||||
LLDrawPoolAlpha::LLDrawPoolAlpha(U32 type) :
|
||||
LLRenderPass(type), current_shader(NULL), target_shader(NULL),
|
||||
simple_shader(NULL), fullbright_shader(NULL)
|
||||
simple_shader(NULL), fullbright_shader(NULL),
|
||||
mColorSFactor(LLRender::BF_UNDEF), mColorDFactor(LLRender::BF_UNDEF),
|
||||
mAlphaSFactor(LLRender::BF_UNDEF), mAlphaDFactor(LLRender::BF_UNDEF)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -178,8 +180,15 @@ void LLDrawPoolAlpha::render(S32 pass)
|
||||
|
||||
LLGLSPipelineAlpha gls_pipeline_alpha;
|
||||
|
||||
gGL.setColorMask(true, true);
|
||||
if (LLPipeline::sFastAlpha && !deferred_render)
|
||||
{
|
||||
mColorSFactor = LLRender::BF_ONE; // }
|
||||
mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow
|
||||
mAlphaSFactor = LLRender::BF_ZERO;
|
||||
mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds
|
||||
gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
|
||||
|
||||
gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f);
|
||||
if (mVertexShaderLevel > 0)
|
||||
{
|
||||
@@ -203,8 +212,17 @@ void LLDrawPoolAlpha::render(S32 pass)
|
||||
}
|
||||
|
||||
LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE);
|
||||
|
||||
mColorSFactor = LLRender::BF_SOURCE_ALPHA; // } regular alpha blend
|
||||
mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // }
|
||||
mAlphaSFactor = LLRender::BF_ZERO; // } glow suppression
|
||||
mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // }
|
||||
gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
|
||||
|
||||
renderAlpha(getVertexDataMask());
|
||||
|
||||
gGL.setColorMask(true, false);
|
||||
|
||||
if (deferred_render && current_shader != NULL)
|
||||
{
|
||||
gPipeline.unbindDeferredShader(*current_shader);
|
||||
@@ -283,6 +301,12 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
|
||||
if (group->mSpatialPartition->mRenderByGroup &&
|
||||
!group->isDead())
|
||||
{
|
||||
bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow.
|
||||
// All particle systems seem to come off the wire with texture entries which claim that they glow. This is probably a bug in the data. Suppress.
|
||||
group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_PARTICLE &&
|
||||
group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_CLOUD &&
|
||||
group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD_PARTICLE;
|
||||
|
||||
LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA];
|
||||
|
||||
for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k)
|
||||
@@ -291,22 +315,10 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
|
||||
|
||||
LLRenderPass::applyModelMatrix(params);
|
||||
|
||||
if (params.mTexture.notNull())
|
||||
{
|
||||
gGL.getTexUnit(0)->activate();
|
||||
gGL.getTexUnit(0)->bind(params.mTexture.get());
|
||||
|
||||
if (params.mTextureMatrix)
|
||||
if (params.mFullbright)
|
||||
{
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
|
||||
gPipeline.mTextureMatrixOps++;
|
||||
}
|
||||
}
|
||||
|
||||
if (params.mFullbright)
|
||||
{
|
||||
// Turn off lighting if it hasn't already been so.
|
||||
// Turn off lighting if it hasn't already been so.
|
||||
if (light_enabled || !initialized_lighting)
|
||||
{
|
||||
initialized_lighting = TRUE;
|
||||
@@ -357,22 +369,61 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
|
||||
}
|
||||
else if (!use_shaders && current_shader != NULL)
|
||||
{
|
||||
LLGLSLShader::bindNoShader();
|
||||
|
||||
if (deferred_render)
|
||||
{
|
||||
gPipeline.unbindDeferredShader(*current_shader);
|
||||
}
|
||||
LLGLSLShader::bindNoShader();
|
||||
current_shader = NULL;
|
||||
}
|
||||
|
||||
if (params.mGroup)
|
||||
{
|
||||
params.mGroup->rebuildMesh();
|
||||
{
|
||||
params.mGroup->rebuildMesh();
|
||||
}
|
||||
|
||||
|
||||
if (params.mTexture.notNull())
|
||||
{
|
||||
gGL.getTexUnit(0)->bind(params.mTexture.get());
|
||||
if(params.mTexture.notNull())
|
||||
{
|
||||
params.mTexture->addTextureStats(params.mVSize);
|
||||
}
|
||||
if (params.mTextureMatrix)
|
||||
{
|
||||
gGL.getTexUnit(0)->activate();
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
|
||||
gPipeline.mTextureMatrixOps++;
|
||||
}
|
||||
}
|
||||
}
|
||||
params.mVertexBuffer->setBuffer(mask);
|
||||
params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
|
||||
gPipeline.addTrianglesDrawn(params.mCount/3);
|
||||
|
||||
// If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha.
|
||||
if (draw_glow_for_this_partition &&
|
||||
params.mGlowColor.mV[3] > 0)
|
||||
{
|
||||
// install glow-accumulating blend mode
|
||||
gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE, // don't touch color
|
||||
LLRender::BF_ONE, LLRender::BF_ONE); // add to alpha (glow)
|
||||
|
||||
// glow doesn't use vertex colors from the mesh data
|
||||
params.mVertexBuffer->setBuffer(mask & ~LLVertexBuffer::MAP_COLOR);
|
||||
glColor4ubv(params.mGlowColor.mV);
|
||||
|
||||
// do the actual drawing, again
|
||||
params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset);
|
||||
gPipeline.addTrianglesDrawn(params.mCount/3);
|
||||
|
||||
// restore our alpha blend mode
|
||||
gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
|
||||
}
|
||||
|
||||
if (params.mTextureMatrix && params.mTexture.notNull())
|
||||
{
|
||||
gGL.getTexUnit(0)->activate();
|
||||
@@ -383,6 +434,15 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
|
||||
}
|
||||
}
|
||||
|
||||
if (deferred_render && current_shader != NULL)
|
||||
{
|
||||
gPipeline.unbindDeferredShader(*current_shader);
|
||||
LLVertexBuffer::unbind();
|
||||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
LLGLState::checkClientArrays();
|
||||
}
|
||||
|
||||
if (!light_enabled)
|
||||
{
|
||||
gPipeline.enableLightsDynamic();
|
||||
|
||||
Reference in New Issue
Block a user