Improving Material shader code generation

This commit is contained in:
Dynamitos
2020-09-19 14:36:50 +02:00
parent 6814587b54
commit facbfed79c
72 changed files with 1049 additions and 329 deletions
@@ -12,6 +12,29 @@ PrimitiveComponent::PrimitiveComponent()
PrimitiveComponent::PrimitiveComponent(PMeshAsset asset)
{
auto assetMeshes = asset->getMeshes();
staticMeshes.resize(assetMeshes.size());
for (uint32 i = 0; i < assetMeshes.size(); i++)
{
auto& batch = staticMeshes[i];
batch.material = assetMeshes[i]->referencedMaterial->getRenderMaterial();
batch.isBackfaceCullingDisabled = false;
batch.isCastingShadow = true;
batch.primitiveComponent = this;
batch.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
batch.useReverseCulling = false;
batch.useWireframe = false;
batch.vertexInput = assetMeshes[i]->vertexInput;
auto& batchElement = batch.elements.add();
batchElement.baseVertexIndex = 0;
batchElement.firstIndex = 0;
batchElement.indexBuffer = assetMeshes[i]->indexBuffer;
batchElement.indirectArgsBuffer = nullptr;
batchElement.instanceRuns = nullptr;
batchElement.isInstanced = false;
batchElement.numInstances = 1;
batchElement.numPrimitives = assetMeshes[i]->indexBuffer->getNumIndices() / 3; //TODO: hardcoded
}
}
PrimitiveComponent::~PrimitiveComponent()
@@ -6,7 +6,7 @@ namespace Seele
struct PrimitiveUniformBuffer
{
Matrix4 localToWorld;
Vector4 worldToLocal;
Matrix4 worldToLocal;
Vector4 actorWorldPosition;
};
} // namespace Seele