Moving projection to viewport

This commit is contained in:
Dynamitos
2022-11-30 10:19:45 +01:00
parent 1e04da963d
commit 3c7346cf7b
18 changed files with 87 additions and 86 deletions
+24 -19
View File
@@ -1,6 +1,7 @@
#include "Scene.h"
#include "Material/MaterialAsset.h"
#include "Graphics/Graphics.h"
#include "Graphics/Mesh.h"
#include "Component/StaticMesh.h"
#include "Component/Transform.h"
@@ -82,25 +83,29 @@ Array<StaticMeshBatch> Scene::getStaticMeshes()
}
};
Gfx::PUniformBuffer transformBuf = graphics->createUniformBuffer(info);
auto& batch = result.add();
batch.material = mesh.material;
batch.isBackfaceCullingDisabled = false;
batch.isCastingShadow = true;
batch.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
batch.useReverseCulling = false;
batch.useWireframe = false;
batch.vertexInput = mesh.vertexBuffer;
MeshBatchElement batchElement;
batchElement.baseVertexIndex = 0;
batchElement.firstIndex = 0;
batchElement.indexBuffer = mesh.indexBuffer;
batchElement.indirectArgsBuffer = nullptr;
batchElement.instanceRuns = nullptr;
batchElement.isInstanced = false;
batchElement.numInstances = 1;
batchElement.uniformBuffer = transformBuf;
batchElement.numPrimitives = static_cast<uint32>(mesh.indexBuffer->getNumIndices() / 3); //TODO: hardcoded
batch.elements.add(batchElement);
// TODO
for(auto& m : mesh.mesh->meshes)
{
auto& batch = result.add();
batch.material = m->referencedMaterial;
batch.isBackfaceCullingDisabled = false;
batch.isCastingShadow = true;
batch.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
batch.useReverseCulling = false;
batch.useWireframe = false;
batch.vertexInput = m->vertexInput;
MeshBatchElement batchElement;
batchElement.baseVertexIndex = 0;
batchElement.firstIndex = 0;
batchElement.indexBuffer = m->indexBuffer;
batchElement.indirectArgsBuffer = nullptr;
batchElement.instanceRuns = nullptr;
batchElement.isInstanced = false;
batchElement.numInstances = 1;
batchElement.uniformBuffer = transformBuf;
batchElement.numPrimitives = static_cast<uint32>(m->indexBuffer->getNumIndices() / 3); //TODO: hardcoded
batch.elements.add(batchElement);
}
}
return result;
}