AEResult GameLightsUpdate::ShadowDirLightRenderGameObject() { LightManager* lightManager = m_GameApp->GetLightManager(); GameObjectManager* gameObjectManager = m_GameApp->GetGameObjectManager(); if (lightManager->GetNumDirLightsWithShadows() == 0) { return AEResult::Ok; } Texture2DArray* shadowTextureArray = lightManager->GetDirLightShadowTextureArray(); AETODO("Check return"); RenderTarget* rtsDS[1] = { nullptr }; m_GraphicDevice->SetRenderTargetsAndDepthStencil(1, rtsDS, m_DirLightShadowTexturesDS); for (auto lightIt : *lightManager) { Light* light = lightIt.second; if (light->GetLightType() == LightType::Directional && light->IsShadowEnabled()) { DirectionalLight* dirLight = reinterpret_cast<DirectionalLight*>(light); uint32_t idxs[1] = { light->GetShadowTextureIndex() }; AETODO("Check return"); m_GraphicDevice->SetRenderTargets(1, idxs, shadowTextureArray); m_GraphicDevice->Clear(true, 0, true, true, AEColors::Transparent); for (uint32_t i = 0; i < AE_LIGHT_NUM_CASCADE_MAPS; i++) { AETODO("Check return"); m_GraphicDevice->SetViewport(m_DirLightShadowViewports[i]); const LightCascadeInfo& lightCascadeInfo = dirLight->GetLightCascadeInfo(); for (auto goIt : *gameObjectManager) { AETODO("Check return"); ShadowLightRenderGameObject(goIt.second, lightCascadeInfo.m_CascadeViewMatrix[i], lightCascadeInfo.m_CascadeProjectionMatrix[i]); } } } } AETODO("Check return"); m_GraphicDevice->ResetViewport(); AETODO("Check return"); m_GraphicDevice->ResetRenderTargetAndSetDepthStencil(); return AEResult::Ok; }
AEResult GameLightsUpdate::ShadowSpotLightRenderGameObject() { LightManager* lightManager = m_GameApp->GetLightManager(); GameObjectManager* gameObjectManager = m_GameApp->GetGameObjectManager(); if (lightManager->GetNumSpotLightsWithShadows() == 0) { return AEResult::Ok; } Texture2DArray* shadowTextureArray = lightManager->GetSpotLightShadowTextureArray(); AETODO("Check return"); RenderTarget* rtsDS[1] = { nullptr }; m_GraphicDevice->SetRenderTargetsAndDepthStencil(1, rtsDS, m_SpotLightShadowTexturesDS); AETODO("Check return"); m_GraphicDevice->SetViewport(m_SpotLightShadowViewport); for (auto lightIt : *lightManager) { Light* light = lightIt.second; if (light->GetLightType() == LightType::Spot && light->IsShadowEnabled()) { uint32_t idxs[1] = { light->GetShadowTextureIndex() }; AETODO("Check return"); m_GraphicDevice->SetRenderTargets(1, idxs, shadowTextureArray); m_GraphicDevice->Clear(true, 0, true, true, AEColors::Transparent); for (auto goIt : *gameObjectManager) { AETODO("Check return"); ShadowLightRenderGameObject(goIt.second, light->GetViewMatrix(), light->GetProjectionMatrix()); } } } AETODO("Check return"); m_GraphicDevice->ResetViewport(); AETODO("Check return"); m_GraphicDevice->ResetRenderTargetAndSetDepthStencil(); return AEResult::Ok; }