Fix lightmaps bake on D3D12

This commit is contained in:
Wojtek Figat
2021-06-08 15:21:37 +02:00
parent 4c6fd783e1
commit 39f50726a6
5 changed files with 22 additions and 9 deletions

View File

@@ -188,7 +188,12 @@ bool ShadowsOfMordor::Builder::doWorkInner(DateTime buildStart)
tempDesc.Format = HemispheresFormatToPixelFormat[CACHE_NORMALS_FORMAT];
_cacheNormals = RenderTargetPool::Get(tempDesc);
if (_cachePositions == nullptr || _cacheNormals == nullptr)
{
LOG(Warning, "Failed to get textures for cache.");
_wasBuildCalled = false;
_isActive = false;
return true;
}
generateHemispheres();
@@ -228,6 +233,8 @@ bool ShadowsOfMordor::Builder::doWorkInner(DateTime buildStart)
if (bounceCount <= 0 || hemispheresCount <= 0)
{
LOG(Warning, "No data to render");
_wasBuildCalled = false;
_isActive = false;
return true;
}
@@ -284,8 +291,8 @@ bool ShadowsOfMordor::Builder::doWorkInner(DateTime buildStart)
reportProgress(BuildProgressStep::RenderHemispheres, 1.0f);
#if DEBUG_EXPORT_HEMISPHERES_PREVIEW
for (int32 sceneIndex = 0; sceneIndex < _scenes.Count(); sceneIndex++)
downloadDebugHemisphereAtlases(_scenes[sceneIndex]);
for (int32 sceneIndex = 0; sceneIndex < _scenes.Count(); sceneIndex++)
downloadDebugHemisphereAtlases(_scenes[sceneIndex]);
#endif
// References:
@@ -391,6 +398,7 @@ int32 ShadowsOfMordor::Builder::doWork()
buildFailed = doWorkInner(buildStart);
if (buildFailed && !checkBuildCancelled())
{
IsBakingLightmaps = false;
OnBuildFinished(buildFailed);
return 0;
}

View File

@@ -78,6 +78,8 @@ void ShadowsOfMordor::Builder::generateHemispheres()
// Fill cache
if (runStage(RenderCache))
return;
if (waitForJobDataSync())
return;
// Post-process cache
if (runStage(PostprocessCache))

View File

@@ -521,7 +521,7 @@ void ShadowsOfMordor::Builder::releaseResources()
bool ShadowsOfMordor::Builder::waitForJobDataSync()
{
bool wasCancelled = false;
const int32 framesToSyncCount = 3;
const int32 framesToSyncCount = 4;
while (!wasCancelled)
{