diff --git a/Components/Hlms/Pbs/include/OgreHlmsPbs.h b/Components/Hlms/Pbs/include/OgreHlmsPbs.h index 31e67aa7f16..0c6d466eb36 100644 --- a/Components/Hlms/Pbs/include/OgreHlmsPbs.h +++ b/Components/Hlms/Pbs/include/OgreHlmsPbs.h @@ -244,7 +244,8 @@ namespace Ogre void calculateHashFor( Renderable *renderable, uint32 &outHash, uint32 &outCasterHash ) override; void calculateHashForPreCreate( Renderable *renderable, PiecesMap *inOutPieces ) override; - void calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces ) override; + void calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces, + const PiecesMap *normalPassPieces ) override; void notifyPropertiesMergedPreGenerationStep() override; diff --git a/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp b/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp index 37e0d82eabb..81ca58ebbfb 100644 --- a/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp +++ b/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp @@ -1033,7 +1033,8 @@ namespace Ogre setProperty( PbsProperty::MaterialsPerBuffer, static_cast( mSlotsPerPool ) ); } //----------------------------------------------------------------------------------- - void HlmsPbs::calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces ) + void HlmsPbs::calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces, + const PiecesMap * ) { HlmsPbsDatablock *datablock = static_cast( renderable->getDatablock() ); const bool hasAlphaTest = datablock->getAlphaTest() != CMPF_ALWAYS_PASS; diff --git a/Components/Hlms/Unlit/include/OgreHlmsUnlit.h b/Components/Hlms/Unlit/include/OgreHlmsUnlit.h index 288dd19d824..1ddab3f6c61 100644 --- a/Components/Hlms/Unlit/include/OgreHlmsUnlit.h +++ b/Components/Hlms/Unlit/include/OgreHlmsUnlit.h @@ -105,7 +105,8 @@ namespace Ogre void calculateHashFor( Renderable *renderable, uint32 &outHash, uint32 &outCasterHash ) override; void calculateHashForPreCreate( Renderable *renderable, PiecesMap *inOutPieces ) override; - void calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces ) override; + void calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces, + const PiecesMap *normalPassPieces ) override; void notifyPropertiesMergedPreGenerationStep() override; diff --git a/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp b/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp index 3fb627afa7b..29ccda4b7c9 100644 --- a/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp +++ b/Components/Hlms/Unlit/src/OgreHlmsUnlit.cpp @@ -502,7 +502,8 @@ namespace Ogre setProperty( UnlitProperty::MaterialsPerBuffer, static_cast( mSlotsPerPool ) ); } //----------------------------------------------------------------------------------- - void HlmsUnlit::calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces ) + void HlmsUnlit::calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces, + const PiecesMap *normalPassPieces ) { // HlmsUnlitDatablock *datablock = static_cast( // renderable->getDatablock() ); @@ -535,6 +536,11 @@ namespace Ogre } } } + else + { + inOutPieces[VertexShader] = normalPassPieces[VertexShader]; + inOutPieces[PixelShader] = normalPassPieces[PixelShader]; + } if( mFastShaderBuildHack ) setProperty( UnlitProperty::MaterialsPerBuffer, static_cast( 2 ) ); @@ -1017,7 +1023,7 @@ namespace Ogre // ---- PIXEL SHADER ---- //--------------------------------------------------------------------------- - if( !casterPass ) + if( !casterPass || datablock->getAlphaTest() != CMPF_ALWAYS_PASS ) { if( datablock->mTexturesDescSet != mLastDescTexture ) { diff --git a/OgreMain/include/OgreHlms.h b/OgreMain/include/OgreHlms.h index 2713986cb9c..cebb71c81ec 100644 --- a/OgreMain/include/OgreHlms.h +++ b/OgreMain/include/OgreHlms.h @@ -466,7 +466,10 @@ namespace Ogre uint16 calculateHashForV2( Renderable *renderable ); virtual void calculateHashForPreCreate( Renderable *renderable, PiecesMap *inOutPieces ) {} - virtual void calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces ) {} + virtual void calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces, + const PiecesMap *normalPassPieces ) + { + } HlmsCache preparePassHashBase( const Ogre::CompositorShadowNode *shadowNode, bool casterPass, bool dualParaboloid, SceneManager *sceneManager ); diff --git a/OgreMain/src/OgreHlms.cpp b/OgreMain/src/OgreHlms.cpp index c221b932d90..2d7ca14f65b 100644 --- a/OgreMain/src/OgreHlms.cpp +++ b/OgreMain/src/OgreHlms.cpp @@ -2710,7 +2710,7 @@ namespace Ogre VertexArrayObject *vao = renderable->getVaos( VpShadow )[0]; setProperty( HlmsPsoProp::InputLayoutId, vao->getInputLayoutId() ); } - calculateHashForPreCaster( renderable, piecesCaster ); + calculateHashForPreCaster( renderable, piecesCaster, pieces ); setProperty( HlmsPsoProp::Macroblock, renderable->getDatablock()->getMacroblock( true )->mLifetimeId ); setProperty( HlmsPsoProp::Blendblock, diff --git a/Samples/2.0/Tutorials/Tutorial_Terrain/include/Terra/Hlms/OgreHlmsTerra.h b/Samples/2.0/Tutorials/Tutorial_Terrain/include/Terra/Hlms/OgreHlmsTerra.h index 999c5ea4f29..338e91bb76e 100644 --- a/Samples/2.0/Tutorials/Tutorial_Terrain/include/Terra/Hlms/OgreHlmsTerra.h +++ b/Samples/2.0/Tutorials/Tutorial_Terrain/include/Terra/Hlms/OgreHlmsTerra.h @@ -76,7 +76,8 @@ namespace Ogre void calculateHashFor( Renderable *renderable, uint32 &outHash, uint32 &outCasterHash ) override; void calculateHashForPreCreate( Renderable *renderable, PiecesMap *inOutPieces ) override; - void calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces ) override; + void calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces, + const PiecesMap *normalPassPieces ) override; void notifyPropertiesMergedPreGenerationStep() override; diff --git a/Samples/2.0/Tutorials/Tutorial_Terrain/src/Terra/Hlms/OgreHlmsTerra.cpp b/Samples/2.0/Tutorials/Tutorial_Terrain/src/Terra/Hlms/OgreHlmsTerra.cpp index c7f51a97e74..3270fb72d3e 100644 --- a/Samples/2.0/Tutorials/Tutorial_Terrain/src/Terra/Hlms/OgreHlmsTerra.cpp +++ b/Samples/2.0/Tutorials/Tutorial_Terrain/src/Terra/Hlms/OgreHlmsTerra.cpp @@ -405,7 +405,8 @@ namespace Ogre #endif } //----------------------------------------------------------------------------------- - void HlmsTerra::calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces ) + void HlmsTerra::calculateHashForPreCaster( Renderable *renderable, PiecesMap *inOutPieces, + const PiecesMap * ) { // Override, since shadow casting is very basic mSetProperties.clear(); diff --git a/Samples/Media/Hlms/Unlit/Any/500.StructsUnlit_piece_all.any b/Samples/Media/Hlms/Unlit/Any/500.StructsUnlit_piece_all.any index 05bca8a5847..40a8e54c38f 100644 --- a/Samples/Media/Hlms/Unlit/Any/500.StructsUnlit_piece_all.any +++ b/Samples/Media/Hlms/Unlit/Any/500.StructsUnlit_piece_all.any @@ -90,7 +90,7 @@ @pset( texcoord, 0 ) @piece( VStoPS_block ) - @property( !hlms_shadowcaster ) + @property( !hlms_shadowcaster || alpha_test ) @property( syntax != metal ) FLAT_INTERPOLANT( uint drawId, @counter(texcoord) ); @else @@ -103,7 +103,9 @@ @end @foreach( out_uv_half_count, n ) INTERPOLANT( float@value( out_uv_half_count@n ) uv@n, @counter(texcoord) );@end - @else + @end + + @property( hlms_shadowcaster ) @property( (!hlms_shadow_uses_depth_texture || exponential_shadow_maps) && !hlms_shadowcaster_point ) INTERPOLANT( float depth, @counter(texcoord) ); @end diff --git a/Samples/Media/Hlms/Unlit/GLSL/PixelShader_ps.glsl b/Samples/Media/Hlms/Unlit/GLSL/PixelShader_ps.glsl index 38f47c9525d..751035fd008 100644 --- a/Samples/Media/Hlms/Unlit/GLSL/PixelShader_ps.glsl +++ b/Samples/Media/Hlms/Unlit/GLSL/PixelShader_ps.glsl @@ -17,7 +17,7 @@ layout(location = FRAG_COLOR, index = 0) out midf outColour; // START UNIFORM DECLARATION @insertpiece( custom_ps_uniformDeclaration ) // END UNIFORM DECLARATION -@property( !hlms_shadowcaster || !hlms_shadow_uses_depth_texture || exponential_shadow_maps ) +@property( !hlms_shadowcaster || !hlms_shadow_uses_depth_texture || alpha_test || exponential_shadow_maps ) vulkan_layout( location = 0 ) in block { @insertpiece( VStoPS_block ) diff --git a/Samples/Media/Hlms/Unlit/GLSL/VertexShader_vs.glsl b/Samples/Media/Hlms/Unlit/GLSL/VertexShader_vs.glsl index 1978c8465de..fe5c7397e36 100644 --- a/Samples/Media/Hlms/Unlit/GLSL/VertexShader_vs.glsl +++ b/Samples/Media/Hlms/Unlit/GLSL/VertexShader_vs.glsl @@ -27,7 +27,7 @@ vulkan_layout( OGRE_POSITION ) in vec4 vertex; @insertpiece( custom_vs_attributes ) -@property( !hlms_shadowcaster || !hlms_shadow_uses_depth_texture || exponential_shadow_maps ) +@property( !hlms_shadowcaster || !hlms_shadow_uses_depth_texture || alpha_test || exponential_shadow_maps ) vulkan_layout( location = 0 ) out block { @insertpiece( VStoPS_block )