diff --git a/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp b/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp index e440614ded..398dc0ca13 100644 --- a/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp +++ b/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp @@ -709,7 +709,7 @@ namespace Ogre mListener->preparePassHash( shadowNode, casterPass, dualParaboloid, sceneManager, this ); PassCache passCache; - passCache.passPso = getPassPsoForScene( sceneManager ); + passCache.passPso = getPassPsoForScene( sceneManager, false ); passCache.properties = mT[kNoTid].setProperties; assert( mPassCache.size() <= (size_t)HlmsBits::PassMask && diff --git a/OgreMain/include/OgreHlms.h b/OgreMain/include/OgreHlms.h index ebbba3ea84..4c15ad6b2f 100644 --- a/OgreMain/include/OgreHlms.h +++ b/OgreMain/include/OgreHlms.h @@ -547,7 +547,7 @@ namespace Ogre HlmsCache preparePassHashBase( const Ogre::CompositorShadowNode *shadowNode, bool casterPass, bool dualParaboloid, SceneManager *sceneManager ); - HlmsPassPso getPassPsoForScene( SceneManager *sceneManager ); + HlmsPassPso getPassPsoForScene( SceneManager *sceneManager, const bool bForceCullNone ); /// OpenGL sets texture binding slots from C++ /// All other APIs set the slots from shader. diff --git a/OgreMain/include/OgreHlmsPso.h b/OgreMain/include/OgreHlmsPso.h index e29259ebb0..29361a6063 100644 --- a/OgreMain/include/OgreHlmsPso.h +++ b/OgreMain/include/OgreHlmsPso.h @@ -111,6 +111,7 @@ namespace Ogre InvertVertexWinding = 1u << 1u, NoDepthBuffer = 1u << 2u, ForceDepthClamp = 1u << 3u, + ForceCullNone = 1u << 4u, // clang-format on }; }; diff --git a/OgreMain/src/OgreHlms.cpp b/OgreMain/src/OgreHlms.cpp index 347cc47560..8616551ce8 100644 --- a/OgreMain/src/OgreHlms.cpp +++ b/OgreMain/src/OgreHlms.cpp @@ -2230,6 +2230,9 @@ namespace Ogre prepassMacroblock.mCullMode = prepassMacroblock.mCullMode == CULL_CLOCKWISE ? CULL_ANTICLOCKWISE : CULL_CLOCKWISE; } + // We need to disable culling. + if( pso.pass.strongMacroblockBits & HlmsPassPso::ForceCullNone ) + prepassMacroblock.mCullMode = CULL_NONE; // Force depth clamp. Probably a directional shadow caster pass if( pso.pass.strongMacroblockBits & HlmsPassPso::ForceDepthClamp ) prepassMacroblock.mDepthClamp = true; @@ -2923,6 +2926,8 @@ namespace Ogre const CompositorPass *pass = sceneManager->getCurrentCompositorPass(); + bool bForceCullNone = false; + if( !casterPass ) { size_t numShadowMapLights = 0u; @@ -3165,6 +3170,7 @@ namespace Ogre static_cast( pass->getDefinition() ); if( passSceneDef->mUvBakingSet != 0xFF ) { + bForceCullNone = true; setProperty( kNoTid, HlmsBaseProp::UseUvBaking, 1 ); setProperty( kNoTid, HlmsBaseProp::UvBaking, passSceneDef->mUvBakingSet ); if( passSceneDef->mBakeLightingOnly ) @@ -3495,7 +3501,7 @@ namespace Ogre mListener->preparePassHash( shadowNode, casterPass, dualParaboloid, sceneManager, this ); PassCache passCache; - passCache.passPso = getPassPsoForScene( sceneManager ); + passCache.passPso = getPassPsoForScene( sceneManager, bForceCullNone ); passCache.properties = mT[kNoTid].setProperties; assert( mPassCache.size() <= HlmsBits::PassMask && @@ -3516,7 +3522,7 @@ namespace Ogre return retVal; } //----------------------------------------------------------------------------------- - HlmsPassPso Hlms::getPassPsoForScene( SceneManager *sceneManager ) + HlmsPassPso Hlms::getPassPsoForScene( SceneManager *sceneManager, const bool bForceCullNone ) { const RenderPassDescriptor *renderPassDesc = mRenderSystem->getCurrentPassDescriptor(); @@ -3564,6 +3570,9 @@ namespace Ogre if( sceneManager->getCamerasInProgress().renderingCamera->getNeedsDepthClamp() ) passPso.strongMacroblockBits |= HlmsPassPso::ForceDepthClamp; + if( bForceCullNone ) + passPso.strongMacroblockBits |= HlmsPassPso::ForceCullNone; + const bool invertVertexWinding = mRenderSystem->getInvertVertexWinding(); if( ( renderPassDesc->requiresTextureFlipping() && !invertVertexWinding ) ||