diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index c61618c056acc252a2155395f720c1946472cb7c..2eb277fc4efa24840f7453c623f82d51fc60d93f 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -452,21 +452,26 @@ void LLRenderPass::pushGLTFBatches(U32 type) LLDrawInfo& params = **i; LLCullResult::increment_iterator(i, end); - auto& mat = params.mGLTFMaterial; + pushGLTFBatch(params); + } +} - mat->bind(params.mTexture); +void LLRenderPass::pushGLTFBatch(LLDrawInfo& params) +{ + auto& mat = params.mGLTFMaterial; - LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); + mat->bind(params.mTexture); - setup_texture_matrix(params); - - applyModelMatrix(params); + LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); - params.mVertexBuffer->setBuffer(); - params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + setup_texture_matrix(params); + + applyModelMatrix(params); - teardown_texture_matrix(params); - } + params.mVertexBuffer->setBuffer(); + params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + + teardown_texture_matrix(params); } void LLRenderPass::pushRiggedGLTFBatches(U32 type) @@ -483,28 +488,20 @@ void LLRenderPass::pushRiggedGLTFBatches(U32 type) LLDrawInfo& params = **i; LLCullResult::increment_iterator(i, end); - auto& mat = params.mGLTFMaterial; - - mat->bind(params.mTexture); - - LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); - - setup_texture_matrix(params); - - applyModelMatrix(params); - - if (params.mAvatar.notNull() && (lastAvatar != params.mAvatar || lastMeshId != params.mSkinInfo->mHash)) - { - uploadMatrixPalette(params); - lastAvatar = params.mAvatar; - lastMeshId = params.mSkinInfo->mHash; - } - - params.mVertexBuffer->setBuffer(); - params.mVertexBuffer->drawRange(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + pushRiggedGLTFBatch(params, lastAvatar, lastMeshId); + } +} - teardown_texture_matrix(params); +void LLRenderPass::pushRiggedGLTFBatch(LLDrawInfo& params, LLVOAvatar*& lastAvatar, U64& lastMeshId) +{ + if (params.mAvatar.notNull() && (lastAvatar != params.mAvatar || lastMeshId != params.mSkinInfo->mHash)) + { + uploadMatrixPalette(params); + lastAvatar = params.mAvatar; + lastMeshId = params.mSkinInfo->mHash; } + + pushGLTFBatch(params); } void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 5e741b2b952322ac8cc9f3c1655eaa7b695ed4fa..09c95a1705c4e5612509721637734f07e6568542 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -329,6 +329,10 @@ class LLRenderPass : public LLDrawPool return "PASS_GLTF_PBR"; case PASS_GLTF_PBR_RIGGED: return "PASS_GLTF_PBR_RIGGED"; + case PASS_GLTF_PBR_ALPHA_MASK: + return "PASS_GLTF_PBR_ALPHA_MASK"; + case PASS_GLTF_PBR_ALPHA_MASK_RIGGED: + return "PASS_GLTF_PBR_ALPHA_MASK_RIGGED"; default: return "Unknown pass"; } @@ -348,7 +352,9 @@ class LLRenderPass : public LLDrawPool virtual void pushBatches(U32 type, bool texture = true, bool batch_textures = false); virtual void pushRiggedBatches(U32 type, bool texture = true, bool batch_textures = false); void pushGLTFBatches(U32 type); + void pushGLTFBatch(LLDrawInfo& params); void pushRiggedGLTFBatches(U32 type); + void pushRiggedGLTFBatch(LLDrawInfo& params, LLVOAvatar*& lastAvatar, U64& lastMeshId); virtual void pushMaskBatches(U32 type, bool texture = true, bool batch_textures = false); virtual void pushRiggedMaskBatches(U32 type, bool texture = true, bool batch_textures = false); virtual void pushBatch(LLDrawInfo& params, bool texture, bool batch_textures = false); diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 4efe1ad189c76d332a95872ccfc68250bf9a06f3..1f7d672062a708ab571b848bcc8f0c36dd133c92 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -70,13 +70,16 @@ void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) LLViewerTexture* baseColorTex = media_tex ? media_tex : mBaseColorTexture; LLViewerTexture* emissiveTex = media_tex ? media_tex : mEmissiveTexture; - if (mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) + if (!LLPipeline::sShadowRender || (mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK)) { - // dividing the alpha cutoff by transparency here allows the shader to compare against - // the alpha value of the texture without needing the transparency value - min_alpha = mAlphaCutoff/mBaseColor.mV[3]; + if (mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) + { + // dividing the alpha cutoff by transparency here allows the shader to compare against + // the alpha value of the texture without needing the transparency value + min_alpha = mAlphaCutoff/mBaseColor.mV[3]; + } + shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha); } - shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha); if (baseColorTex != nullptr) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c42bb4592660976e90d9c4432eacc3bfa90b4fc7..dc500465e2d9b35b0016b9a8c12e1bd661682ce7 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6751,7 +6751,8 @@ void LLPipeline::renderShadowSimple(U32 type) gGLLastMatrix = NULL; } -void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigged) +// Currently only used for shadows -Cosmic,2023-04-19 +void LLPipeline::renderAlphaObjects(bool rigged) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; assertInitialized(); @@ -6768,9 +6769,20 @@ void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigge LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); + if (rigged != (pparams->mAvatar != nullptr)) + { + // Pool contains both rigged and non-rigged DrawInfos. Only draw + // the objects we're interested in in this pass. + continue; + } + if (rigged) { - if (pparams->mAvatar != nullptr) + if (pparams->mGLTFMaterial) + { + mSimplePool->pushRiggedGLTFBatch(*pparams, lastAvatar, lastMeshId); + } + else { if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) { @@ -6779,12 +6791,19 @@ void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigge lastMeshId = pparams->mSkinInfo->mHash; } - mSimplePool->pushBatch(*pparams, texture, batch_texture); + mSimplePool->pushBatch(*pparams, true, true); } } - else if (pparams->mAvatar == nullptr) + else { - mSimplePool->pushBatch(*pparams, texture, batch_texture); + if (pparams->mGLTFMaterial) + { + mSimplePool->pushGLTFBatch(*pparams); + } + else + { + mSimplePool->pushBatch(*pparams, true, true); + } } } @@ -6792,6 +6811,7 @@ void LLPipeline::renderAlphaObjects(bool texture, bool batch_texture, bool rigge gGLLastMatrix = NULL; } +// Currently only used for shadows -Cosmic,2023-04-19 void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); @@ -6809,6 +6829,7 @@ void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, gGLLastMatrix = NULL; } +// Currently only used for shadows -Cosmic,2023-04-19 void LLPipeline::renderFullbrightMaskedObjects(U32 type, bool texture, bool batch_texture, bool rigged) { assertInitialized(); @@ -8885,7 +8906,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("shadow alpha blend"); LL_PROFILE_GPU_ZONE("shadow alpha blend"); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(0.598f); - renderAlphaObjects(true, true, rigged); + renderAlphaObjects(rigged); } { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index d9decaa1c5fe311db346cc4e349238cdf7d2a053..b8f8cf49df6846783e77a38250871d194fd79724 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -273,7 +273,7 @@ class LLPipeline void renderObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false); void renderShadowSimple(U32 type); - void renderAlphaObjects(bool texture = true, bool batch_texture = false, bool rigged = false); + void renderAlphaObjects(bool rigged = false); void renderMaskedObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false); void renderFullbrightMaskedObjects(U32 type, bool texture = true, bool batch_texture = false, bool rigged = false);