| 224 | } |
| 225 | |
| 226 | Tr2GpuResourcePool::Texture Tr2ShadowMap::PrepareShadowRendering( Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) |
| 227 | { |
| 228 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 229 | |
| 230 | auto cascadedShadowDepth = gpuResourcePool.GetTempTexture( "cascadedShadowDepth", m_size * m_width, m_size * m_height, PixelFormat::PIXEL_FORMAT_D32_FLOAT, Tr2GpuUsage::DEPTH_STENCIL | Tr2GpuUsage::SHADER_RESOURCE ); |
| 231 | |
| 232 | if( !cascadedShadowDepth.IsValid() ) |
| 233 | { |
| 234 | // This could happen if device is lost |
| 235 | return {}; |
| 236 | } |
| 237 | |
| 238 | // Using depth stencil as shadow map |
| 239 | renderContext.m_esm.PushViewport(); |
| 240 | renderContext.m_esm.PushRenderTarget( Tr2TextureAL() ); //empty texture |
| 241 | renderContext.m_esm.PushDepthStencilBuffer( cascadedShadowDepth ); |
| 242 | |
| 243 | renderContext.m_esm.UpdateRenderTargetViewport( cascadedShadowDepth->GetWidth(), cascadedShadowDepth->GetHeight() ); |
| 244 | |
| 245 | // we want a clean depth buffer for this |
| 246 | CR( renderContext.Clear( CLEARFLAGS_ZBUFFER, 0xffffffff, 1, 0 ) ); |
| 247 | |
| 248 | renderContext.SetReadOnlyDepth( false ); |
| 249 | |
| 250 | return cascadedShadowDepth; |
| 251 | } |
| 252 | |
| 253 | void Tr2ShadowMap::BeginShadowRendering( Tr2RenderContext& renderContext, int splitIndex ) |
| 254 | { |
no test coverage detected