MCPcopy Create free account
hub / github.com/carbonengine/trinity / RenderShadows

Method RenderShadows

trinity/Interior/Tr2InteriorScene.cpp:683–809  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description This function renders shadow maps for each shadow casting light source. --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

681// This function renders shadow maps for each shadow casting light source.
682// --------------------------------------------------------------------------------------
683void Tr2InteriorScene::RenderShadows( Tr2RenderContext& renderContext )
684{
685 CCP_STATS_ZONE( __FUNCTION__ );
686
687 if( !m_renderShadows )
688 {
689 return;
690 }
691
692 if( !m_lightDepthStencil )
693 {
694 SetupShadowMaps();
695 }
696
697 m_noiseTextureHandle = GlobalStore().RegisterVariable( "NoiseMap", m_noiseTexture );
698
699 Tr2Renderer::PushProjection();
700 ON_BLOCK_EXIT( Tr2Renderer::PopProjection );
701 Tr2Renderer::PushViewTransform();
702 ON_BLOCK_EXIT( Tr2Renderer::PopViewTransform );
703
704 renderContext.m_esm.PushViewport();
705 ON_BLOCK_EXIT( [&] { renderContext.m_esm.PopViewport(); } );
706 renderContext.m_esm.PushRenderTarget();
707 ON_BLOCK_EXIT( [&] { renderContext.m_esm.PopRenderTarget(); } );
708 renderContext.m_esm.PushDepthStencilBuffer( Tr2TextureAL() );
709 ON_BLOCK_EXIT( [&] { renderContext.m_esm.PopDepthStencilBuffer(); } );
710
711 TriViewPtr lightView = CreateInstance<TriView>();
712 TriProjectionPtr lightProjection = CreateInstance<TriProjection>();
713
714 // This is the camera's frustum, used for calculating tight bounds for shadow maps
715 TriFrustum cameraFrustum;
716 cameraFrustum.DeriveFrustum(
717 &Tr2Renderer::GetViewTransform(),
718 &Tr2Renderer::GetViewPosition(),
719 &Tr2Renderer::GetProjectionTransform(),
720 renderContext.m_esm.GetViewport() );
721
722 // Reset the testures to white
723 m_shadowMap0Var = m_whiteTexture;
724 m_shadowMap1Var = m_whiteTexture;
725 m_shadowMap2Var = m_whiteTexture;
726 m_shadowMap3Var = m_whiteTexture;
727
728 for( int i = 0; i < (int)( m_lights.size() ) && i < m_shadowCount; ++i )
729 {
730 if( i >= (int)( m_lightRenderTargets.size() ) )
731 {
732 // render target might not be created yet.
733 return;
734 }
735
736 Tr2InteriorLightSource* light = dynamic_cast<Tr2InteriorLightSource*>( m_lights[i] );
737
738 if( light->m_coneAlphaOuter >= 90 )
739 {
740 continue;

Callers

nothing calls this directly

Calls 15

GetViewTransformFunction · 0.85
GetViewPositionFunction · 0.85
GetProjectionTransformFunction · 0.85
SetViewTransformFunction · 0.85
PopulatePerFramePSDataFunction · 0.85
PopulatePerFrameVSDataFunction · 0.85
TransposeFunction · 0.85
RegisterVariableMethod · 0.80
PushViewportMethod · 0.80
PopViewportMethod · 0.80
PopDepthStencilBufferMethod · 0.80

Tested by

no test coverage detected