-------------------------------------------------------------------------------------- Description: Render opaque objects to populate a readable depth stencil. --------------------------------------------------------------------------------------
| 2192 | // Render opaque objects to populate a readable depth stencil. |
| 2193 | // -------------------------------------------------------------------------------------- |
| 2194 | void EveSpaceScene::RenderDepthPass( const Tr2TextureAL& depthMap, const Tr2TextureAL& normalMap, const Tr2TextureAL& customStencil, Tr2RenderContext& renderContext, const BlueSharedString& techniqueName ) |
| 2195 | { |
| 2196 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 2197 | |
| 2198 | if( !m_display ) |
| 2199 | { |
| 2200 | return; |
| 2201 | } |
| 2202 | |
| 2203 | renderContext.m_esm.BeginManagedRendering(); |
| 2204 | |
| 2205 | { // Update mesh morphs |
| 2206 | auto& meshMorphs = m_componentRegistry->GetComponents<ITr2MeshMorph>(); |
| 2207 | if( meshMorphs.size() > 0 ) |
| 2208 | { |
| 2209 | bool cleanUpMorphTasks = true; |
| 2210 | for( auto& meshMorph : meshMorphs ) |
| 2211 | { |
| 2212 | if( !meshMorph->UpdateMeshMorphs( renderContext ) ) |
| 2213 | { |
| 2214 | cleanUpMorphTasks = false; |
| 2215 | } |
| 2216 | } |
| 2217 | if( cleanUpMorphTasks ) |
| 2218 | { |
| 2219 | m_componentRegistry->Clear<ITr2MeshMorph>(); |
| 2220 | } |
| 2221 | } |
| 2222 | } |
| 2223 | |
| 2224 | // Render to depth map |
| 2225 | { |
| 2226 | renderContext.AddGpuMarker( __FUNCTION__ ); |
| 2227 | GPU_REGION( renderContext, "Depth Pass" ); |
| 2228 | |
| 2229 | renderContext.m_esm.SetRenderTarget( 1, customStencil ); |
| 2230 | |
| 2231 | Tr2EffectStateManager::RenderingMode renderingMode; |
| 2232 | if( normalMap.IsValid() ) |
| 2233 | { |
| 2234 | renderContext.m_esm.PushRenderTarget(); |
| 2235 | renderContext.m_esm.SetRenderTarget( 0, normalMap ); |
| 2236 | if( customStencil.IsValid() ) |
| 2237 | { |
| 2238 | renderContext.RenderPassHint( { Tr2LoadAction::CLEAR, Tr2StoreAction::STORE }, { Tr2LoadAction::CLEAR, Tr2StoreAction::STORE }, { Tr2LoadAction::CLEAR, Tr2StoreAction::STORE } ); |
| 2239 | renderContext.Clear( CLEARFLAGS_TARGET, 0, 0, 0, 1 ); |
| 2240 | } |
| 2241 | else |
| 2242 | { |
| 2243 | renderContext.RenderPassHint( { Tr2LoadAction::CLEAR, Tr2StoreAction::STORE }, { Tr2LoadAction::CLEAR, Tr2StoreAction::STORE } ); |
| 2244 | } |
| 2245 | renderContext.Clear( CLEARFLAGS_TARGET | CLEARFLAGS_ZBUFFER, 0, 0, 0 ); |
| 2246 | renderingMode = Tr2EffectStateManager::RM_OPAQUE; |
| 2247 | } |
| 2248 | else |
| 2249 | { |
| 2250 | #if TRINITY_PLATFORM == TRINITY_METAL |
| 2251 | renderContext.m_esm.PushRenderTarget(); |
no test coverage detected