Improve directional shadow integration GT framing
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -93,36 +93,45 @@ Mesh* CreateGroundMesh() {
|
|||||||
params.guid = ResourceGUID::Generate(params.path);
|
params.guid = ResourceGUID::Generate(params.path);
|
||||||
mesh->Initialize(params);
|
mesh->Initialize(params);
|
||||||
|
|
||||||
StaticMeshVertex vertices[4] = {};
|
std::vector<StaticMeshVertex> vertices;
|
||||||
vertices[0].position = Vector3(-4.5f, 0.0f, 1.5f);
|
std::vector<uint32_t> indices;
|
||||||
vertices[0].normal = Vector3::Up();
|
vertices.reserve(8);
|
||||||
vertices[0].uv0 = Vector2(0.0f, 1.0f);
|
indices.reserve(12);
|
||||||
vertices[1].position = Vector3(-4.5f, 0.0f, 9.5f);
|
|
||||||
vertices[1].normal = Vector3::Up();
|
AppendQuadFace(
|
||||||
vertices[1].uv0 = Vector2(0.0f, 0.0f);
|
vertices, indices,
|
||||||
vertices[2].position = Vector3(4.5f, 0.0f, 1.5f);
|
Vector3(-8.0f, 0.0f, 0.5f),
|
||||||
vertices[2].normal = Vector3::Up();
|
Vector3(-8.0f, 0.0f, 12.0f),
|
||||||
vertices[2].uv0 = Vector2(1.0f, 1.0f);
|
Vector3(8.0f, 0.0f, 0.5f),
|
||||||
vertices[3].position = Vector3(4.5f, 0.0f, 9.5f);
|
Vector3(8.0f, 0.0f, 12.0f),
|
||||||
vertices[3].normal = Vector3::Up();
|
Vector3::Up());
|
||||||
vertices[3].uv0 = Vector2(1.0f, 0.0f);
|
AppendQuadFace(
|
||||||
|
vertices, indices,
|
||||||
|
Vector3(-8.0f, 0.0f, 12.0f),
|
||||||
|
Vector3(8.0f, 0.0f, 12.0f),
|
||||||
|
Vector3(-8.0f, 6.0f, 12.0f),
|
||||||
|
Vector3(8.0f, 6.0f, 12.0f),
|
||||||
|
Vector3::Back());
|
||||||
|
|
||||||
const uint32_t indices[6] = { 0, 1, 2, 2, 1, 3 };
|
|
||||||
mesh->SetVertexData(
|
mesh->SetVertexData(
|
||||||
vertices,
|
vertices.data(),
|
||||||
sizeof(vertices),
|
vertices.size() * sizeof(StaticMeshVertex),
|
||||||
4,
|
static_cast<uint32_t>(vertices.size()),
|
||||||
sizeof(StaticMeshVertex),
|
sizeof(StaticMeshVertex),
|
||||||
VertexAttribute::Position | VertexAttribute::Normal | VertexAttribute::UV0);
|
VertexAttribute::Position | VertexAttribute::Normal | VertexAttribute::UV0);
|
||||||
mesh->SetIndexData(indices, sizeof(indices), 6, true);
|
mesh->SetIndexData(
|
||||||
const Bounds bounds(Vector3(0.0f, 0.0f, 5.5f), Vector3(9.0f, 0.1f, 8.0f));
|
indices.data(),
|
||||||
|
indices.size() * sizeof(uint32_t),
|
||||||
|
static_cast<uint32_t>(indices.size()),
|
||||||
|
true);
|
||||||
|
const Bounds bounds(Vector3(0.0f, 3.0f, 6.25f), Vector3(16.0f, 6.0f, 11.5f));
|
||||||
mesh->SetBounds(bounds);
|
mesh->SetBounds(bounds);
|
||||||
|
|
||||||
MeshSection section = {};
|
MeshSection section = {};
|
||||||
section.baseVertex = 0;
|
section.baseVertex = 0;
|
||||||
section.vertexCount = 4;
|
section.vertexCount = static_cast<uint32_t>(vertices.size());
|
||||||
section.startIndex = 0;
|
section.startIndex = 0;
|
||||||
section.indexCount = 6;
|
section.indexCount = static_cast<uint32_t>(indices.size());
|
||||||
section.materialID = 0;
|
section.materialID = 0;
|
||||||
section.bounds = bounds;
|
section.bounds = bounds;
|
||||||
mesh->AddSection(section);
|
mesh->AddSection(section);
|
||||||
@@ -279,11 +288,11 @@ void DirectionalShadowSceneTest::SetUp() {
|
|||||||
mGroundMaterial = CreateForwardLitMaterial(
|
mGroundMaterial = CreateForwardLitMaterial(
|
||||||
"DirectionalShadowGround",
|
"DirectionalShadowGround",
|
||||||
"Tests/Rendering/DirectionalShadowGround.material",
|
"Tests/Rendering/DirectionalShadowGround.material",
|
||||||
Vector4(0.82f, 0.83f, 0.86f, 1.0f));
|
Vector4(0.92f, 0.93f, 0.96f, 1.0f));
|
||||||
mCasterMaterial = CreateForwardLitMaterial(
|
mCasterMaterial = CreateForwardLitMaterial(
|
||||||
"DirectionalShadowCaster",
|
"DirectionalShadowCaster",
|
||||||
"Tests/Rendering/DirectionalShadowCaster.material",
|
"Tests/Rendering/DirectionalShadowCaster.material",
|
||||||
Vector4(0.82f, 0.34f, 0.24f, 1.0f));
|
Vector4(0.72f, 0.22f, 0.16f, 1.0f));
|
||||||
|
|
||||||
BuildScene();
|
BuildScene();
|
||||||
|
|
||||||
@@ -363,18 +372,18 @@ void DirectionalShadowSceneTest::BuildScene() {
|
|||||||
camera->SetNearClipPlane(0.1f);
|
camera->SetNearClipPlane(0.1f);
|
||||||
camera->SetFarClipPlane(100.0f);
|
camera->SetFarClipPlane(100.0f);
|
||||||
camera->SetClearColor(XCEngine::Math::Color(0.03f, 0.03f, 0.05f, 1.0f));
|
camera->SetClearColor(XCEngine::Math::Color(0.03f, 0.03f, 0.05f, 1.0f));
|
||||||
cameraObject->GetTransform()->SetLocalPosition(Vector3(0.0f, 2.2f, -1.8f));
|
cameraObject->GetTransform()->SetLocalPosition(Vector3(0.0f, 2.6f, -4.6f));
|
||||||
cameraObject->GetTransform()->SetLocalRotation(
|
cameraObject->GetTransform()->SetLocalRotation(
|
||||||
Quaternion::LookRotation(Vector3(0.0f, -0.22f, 1.0f).Normalized()));
|
Quaternion::LookRotation(Vector3(0.0f, -0.10f, 1.0f).Normalized()));
|
||||||
|
|
||||||
GameObject* lightObject = mScene->CreateGameObject("MainDirectionalLight");
|
GameObject* lightObject = mScene->CreateGameObject("MainDirectionalLight");
|
||||||
auto* light = lightObject->AddComponent<LightComponent>();
|
auto* light = lightObject->AddComponent<LightComponent>();
|
||||||
light->SetLightType(LightType::Directional);
|
light->SetLightType(LightType::Directional);
|
||||||
light->SetColor(XCEngine::Math::Color(1.0f, 1.0f, 0.97f, 1.0f));
|
light->SetColor(XCEngine::Math::Color(1.0f, 1.0f, 0.97f, 1.0f));
|
||||||
light->SetIntensity(1.8f);
|
light->SetIntensity(2.1f);
|
||||||
light->SetCastsShadows(true);
|
light->SetCastsShadows(true);
|
||||||
lightObject->GetTransform()->SetLocalRotation(
|
lightObject->GetTransform()->SetLocalRotation(
|
||||||
Quaternion::LookRotation(Vector3(-0.32f, -0.78f, -0.54f).Normalized()));
|
Quaternion::LookRotation(Vector3(0.55f, -0.35f, 0.76f).Normalized()));
|
||||||
|
|
||||||
GameObject* groundObject = mScene->CreateGameObject("Ground");
|
GameObject* groundObject = mScene->CreateGameObject("Ground");
|
||||||
auto* groundMeshFilter = groundObject->AddComponent<MeshFilterComponent>();
|
auto* groundMeshFilter = groundObject->AddComponent<MeshFilterComponent>();
|
||||||
@@ -385,8 +394,8 @@ void DirectionalShadowSceneTest::BuildScene() {
|
|||||||
groundMeshRenderer->SetReceiveShadows(true);
|
groundMeshRenderer->SetReceiveShadows(true);
|
||||||
|
|
||||||
GameObject* casterObject = mScene->CreateGameObject("CasterCube");
|
GameObject* casterObject = mScene->CreateGameObject("CasterCube");
|
||||||
casterObject->GetTransform()->SetLocalPosition(Vector3(0.0f, 0.8f, 4.5f));
|
casterObject->GetTransform()->SetLocalPosition(Vector3(-3.2f, 1.4f, 7.4f));
|
||||||
casterObject->GetTransform()->SetLocalScale(Vector3(1.2f, 1.6f, 1.2f));
|
casterObject->GetTransform()->SetLocalScale(Vector3(1.4f, 2.8f, 1.4f));
|
||||||
auto* casterMeshFilter = casterObject->AddComponent<MeshFilterComponent>();
|
auto* casterMeshFilter = casterObject->AddComponent<MeshFilterComponent>();
|
||||||
auto* casterMeshRenderer = casterObject->AddComponent<MeshRendererComponent>();
|
auto* casterMeshRenderer = casterObject->AddComponent<MeshRendererComponent>();
|
||||||
casterMeshFilter->SetMesh(ResourceHandle<Mesh>(mCubeMesh));
|
casterMeshFilter->SetMesh(ResourceHandle<Mesh>(mCubeMesh));
|
||||||
|
|||||||
Reference in New Issue
Block a user