Add relative-to-camera rendering for large worlds

This commit is contained in:
Wojtek Figat
2022-06-21 20:03:13 +02:00
parent f3bd0e469c
commit 134c8b99aa
35 changed files with 331 additions and 195 deletions

View File

@@ -5,7 +5,6 @@
#include "Engine/Core/Math/Math.h"
#include "Engine/Level/Actors/BoxBrush.h"
#include "Engine/Level/Actors/StaticModel.h"
#include "Engine/ContentImporters/ImportTexture.h"
#include "Engine/Level/Scene/Scene.h"
#include "Engine/Level/Level.h"
#include "Engine/Terrain/Terrain.h"
@@ -40,10 +39,6 @@ bool cacheStaticGeometryTree(Actor* actor, ShadowsOfMordor::Builder::SceneBuildC
entry.AsStaticModel.Actor = staticModel;
entry.Scale = Math::Clamp(staticModel->GetScaleInLightmap(), 0.0f, LIGHTMAP_SCALE_MAX);
// Spawn entry for each mesh
Matrix world;
staticModel->GetWorld(&world);
// Use the first LOD
const int32 lodIndex = 0;
auto& lod = model->LODs[lodIndex];
@@ -61,18 +56,16 @@ bool cacheStaticGeometryTree(Actor* actor, ShadowsOfMordor::Builder::SceneBuildC
}
else
{
LOG(Warning, "Model \'{0}\' mesh index {1} (lod: {2}) has missing lightmap UVs (at actor: {3})",
model->GetPath(),
meshIndex,
lodIndex,
staticModel->GetNamePath());
LOG(Warning, "Model \'{0}\' mesh index {1} (lod: {2}) has missing lightmap UVs (at actor: {3})", model->GetPath(), meshIndex, lodIndex, staticModel->GetNamePath());
}
}
}
if (useLightmap && anyValid && entry.Scale > ZeroTolerance)
{
entry.Box = model->GetBox(world);
Matrix worldMatrix;
staticModel->GetTransform().GetWorld(worldMatrix);
entry.Box = model->GetBox(worldMatrix);
results.Add(entry);
}
else

View File

@@ -124,7 +124,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context)
auto& lod = staticModel->Model->LODs[0];
Matrix worldMatrix;
staticModel->GetWorld(&worldMatrix);
staticModel->GetTransform().GetWorld(worldMatrix);
Matrix::Transpose(worldMatrix, shaderData.WorldMatrix);
shaderData.LightmapArea = staticModel->Lightmap.UVsArea;