diff options
author | Dave Parks <davep@lindenlab.com> | 2022-12-16 11:12:06 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-12-16 11:12:06 -0600 |
commit | d27d23ab269f6d22483c4b4dc1db1664cf3e441e (patch) | |
tree | 10c19add38f5796a2ecd6df3bbc1e1d6ff928e87 /indra/newview/lldrawpool.cpp | |
parent | 57c54ec4b75aac8ba2a4235f88760bd8534f2c7a (diff) |
SL-18852 Refactor GLTF material rendering to not be special compared to other types. Hook GLTF alpha masking up to highlight transparent.
Diffstat (limited to 'indra/newview/lldrawpool.cpp')
-rw-r--r-- | indra/newview/lldrawpool.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index b3ae673aed..dd6b914783 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -425,6 +425,85 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, U32 mask, } } +void setup_texture_matrix(LLDrawInfo& params) +{ + if (params.mTextureMatrix) + { //special case implementation of texture animation here because of special handling of textures for PBR batches + gGL.getTexUnit(0)->activate(); + gGL.matrixMode(LLRender::MM_TEXTURE); + gGL.loadMatrix((GLfloat*)params.mTextureMatrix->mMatrix); + gPipeline.mTextureMatrixOps++; + } +} + +void teardown_texture_matrix(LLDrawInfo& params) +{ + if (params.mTextureMatrix) + { + gGL.matrixMode(LLRender::MM_TEXTURE0); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + } +} + +void LLRenderPass::pushGLTFBatches(U32 type, U32 mask) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; + for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushGLTFBatch"); + LLDrawInfo& params = **i; + auto& mat = params.mGLTFMaterial; + + mat->bind(); + + LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); + + setup_texture_matrix(params); + + applyModelMatrix(params); + + params.mVertexBuffer->setBufferFast(mask); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + + teardown_texture_matrix(params); + } +} + +void LLRenderPass::pushRiggedGLTFBatches(U32 type, U32 mask) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; + LLVOAvatar* lastAvatar = nullptr; + U64 lastMeshId = 0; + mask |= LLVertexBuffer::MAP_WEIGHT4; + for (LLCullResult::drawinfo_iterator i = gPipeline.beginRenderMap(type); i != gPipeline.endRenderMap(type); ++i) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("pushRiggedGLTFBatch"); + LLDrawInfo& params = **i; + auto& mat = params.mGLTFMaterial; + + mat->bind(); + + 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->setBufferFast(mask); + params.mVertexBuffer->drawRangeFast(LLRender::TRIANGLES, params.mStart, params.mEnd, params.mCount, params.mOffset); + + teardown_texture_matrix(params); + } +} + void LLRenderPass::pushBatches(U32 type, U32 mask, BOOL texture, BOOL batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; |