normal compression makes shading look terrible
This commit is contained in:
@@ -36,16 +36,16 @@ void StaticMeshVertexData::loadNormals(uint64 offset, const Array<NormalType>& d
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
//void StaticMeshVertexData::loadTangents(uint64 offset, const Array<TangentType>& data) {
|
||||
// assert(offset + data.size() <= head);
|
||||
// std::memcpy(tanData.data() + offset, data.data(), data.size() * sizeof(TangentType));
|
||||
// dirty = true;
|
||||
//}
|
||||
//void StaticMeshVertexData::loadBitangents(uint64 offset, const Array<BiTangentType>& data) {
|
||||
// assert(offset + data.size() <= head);
|
||||
// std::memcpy(bitData.data() + offset, data.data(), data.size() * sizeof(BiTangentType));
|
||||
// dirty = true;
|
||||
//}
|
||||
void StaticMeshVertexData::loadTangents(uint64 offset, const Array<TangentType>& data) {
|
||||
assert(offset + data.size() <= head);
|
||||
std::memcpy(tanData.data() + offset, data.data(), data.size() * sizeof(TangentType));
|
||||
dirty = true;
|
||||
}
|
||||
void StaticMeshVertexData::loadBitangents(uint64 offset, const Array<BiTangentType>& data) {
|
||||
assert(offset + data.size() <= head);
|
||||
std::memcpy(bitData.data() + offset, data.data(), data.size() * sizeof(BiTangentType));
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
void StaticMeshVertexData::loadColors(uint64 offset, const Array<ColorType>& data) {
|
||||
assert(offset + data.size() <= head);
|
||||
@@ -68,18 +68,18 @@ void StaticMeshVertexData::serializeMesh(MeshId id, uint64 numVertices, ArchiveB
|
||||
}
|
||||
Array<PositionType> pos(numVertices);
|
||||
Array<NormalType> nor(numVertices);
|
||||
//Array<TangentType> tan(numVertices);
|
||||
//Array<BiTangentType> bit(numVertices);
|
||||
Array<TangentType> tan(numVertices);
|
||||
Array<BiTangentType> bit(numVertices);
|
||||
Array<ColorType> col(numVertices);
|
||||
std::memcpy(pos.data(), posData.data() + offset, numVertices * sizeof(PositionType));
|
||||
std::memcpy(nor.data(), norData.data() + offset, numVertices * sizeof(NormalType));
|
||||
//std::memcpy(tan.data(), tanData.data() + offset, numVertices * sizeof(TangentType));
|
||||
//std::memcpy(bit.data(), bitData.data() + offset, numVertices * sizeof(BiTangentType));
|
||||
std::memcpy(tan.data(), tanData.data() + offset, numVertices * sizeof(TangentType));
|
||||
std::memcpy(bit.data(), bitData.data() + offset, numVertices * sizeof(BiTangentType));
|
||||
std::memcpy(col.data(), colData.data() + offset, numVertices * sizeof(ColorType));
|
||||
Serialization::save(buffer, pos);
|
||||
Serialization::save(buffer, nor);
|
||||
//Serialization::save(buffer, tan);
|
||||
//Serialization::save(buffer, bit);
|
||||
Serialization::save(buffer, tan);
|
||||
Serialization::save(buffer, bit);
|
||||
Serialization::save(buffer, col);
|
||||
}
|
||||
|
||||
@@ -98,23 +98,23 @@ uint64 StaticMeshVertexData::deserializeMesh(MeshId id, ArchiveBuffer& buffer) {
|
||||
}
|
||||
Array<PositionType> pos;
|
||||
Array<NormalType> nor;
|
||||
//Array<TangentType> tan;
|
||||
//Array<BiTangentType> bit;
|
||||
Array<TangentType> tan;
|
||||
Array<BiTangentType> bit;
|
||||
Array<ColorType> col;
|
||||
Serialization::load(buffer, pos);
|
||||
Serialization::load(buffer, nor);
|
||||
//Serialization::load(buffer, tan);
|
||||
//Serialization::load(buffer, bit);
|
||||
Serialization::load(buffer, tan);
|
||||
Serialization::load(buffer, bit);
|
||||
Serialization::load(buffer, col);
|
||||
loadPositions(offset, pos);
|
||||
loadNormals(offset, nor);
|
||||
//loadTangents(offset, tan);
|
||||
//loadBitangents(offset, bit);
|
||||
loadTangents(offset, tan);
|
||||
loadBitangents(offset, bit);
|
||||
loadColors(offset, col);
|
||||
result += pos.size() * sizeof(PositionType);
|
||||
result += nor.size() * sizeof(NormalType);
|
||||
//result += tan.size() * sizeof(TangentType);
|
||||
//result += bit.size() * sizeof(BiTangentType);
|
||||
result += tan.size() * sizeof(TangentType);
|
||||
result += bit.size() * sizeof(BiTangentType);
|
||||
result += col.size() * sizeof(ColorType);
|
||||
return result;
|
||||
}
|
||||
@@ -134,17 +134,17 @@ void StaticMeshVertexData::init(Gfx::PGraphics _graphics) {
|
||||
.binding = 2,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
});
|
||||
//descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
// .binding = 3,
|
||||
// .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
//});
|
||||
//descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
// .binding = 4,
|
||||
// .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
//});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 3,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 4,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 5,
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
.descriptorCount = MAX_TEXCOORDS,
|
||||
});
|
||||
descriptorLayout->create();
|
||||
@@ -176,8 +176,8 @@ Gfx::PDescriptorSet StaticMeshVertexData::getVertexDataSet() { return descriptor
|
||||
void StaticMeshVertexData::resizeBuffers() {
|
||||
posData.resize(verticesAllocated);
|
||||
norData.resize(verticesAllocated);
|
||||
// tanData.resize(verticesAllocated);
|
||||
// bitData.resize(verticesAllocated);
|
||||
tanData.resize(verticesAllocated);
|
||||
bitData.resize(verticesAllocated);
|
||||
colData.resize(verticesAllocated);
|
||||
for (size_t i = 0; i < MAX_TEXCOORDS; ++i) {
|
||||
texData[i].resize(verticesAllocated);
|
||||
@@ -202,22 +202,22 @@ void StaticMeshVertexData::updateBuffers() {
|
||||
},
|
||||
.name = "Normals",
|
||||
});
|
||||
//tangents = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
// .sourceData =
|
||||
// {
|
||||
// .size = verticesAllocated * sizeof(TangentType),
|
||||
// .data = (uint8*)tanData.data(),
|
||||
// },
|
||||
// .name = "Tangents",
|
||||
//});
|
||||
//biTangents = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
// .sourceData =
|
||||
// {
|
||||
// .size = verticesAllocated * sizeof(BiTangentType),
|
||||
// .data = (uint8*)bitData.data(),
|
||||
// },
|
||||
// .name = "BiTangents",
|
||||
//});
|
||||
tangents = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData =
|
||||
{
|
||||
.size = verticesAllocated * sizeof(TangentType),
|
||||
.data = (uint8*)tanData.data(),
|
||||
},
|
||||
.name = "Tangents",
|
||||
});
|
||||
biTangents = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData =
|
||||
{
|
||||
.size = verticesAllocated * sizeof(BiTangentType),
|
||||
.data = (uint8*)bitData.data(),
|
||||
},
|
||||
.name = "BiTangents",
|
||||
});
|
||||
colors = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData =
|
||||
{
|
||||
@@ -240,11 +240,11 @@ void StaticMeshVertexData::updateBuffers() {
|
||||
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
||||
descriptorSet->updateBuffer(0, 0, positions);
|
||||
descriptorSet->updateBuffer(1, 0, normals);
|
||||
// descriptorSet->updateBuffer(2, 0, tangents);
|
||||
// descriptorSet->updateBuffer(3, 0, biTangents);
|
||||
descriptorSet->updateBuffer(2, 0, colors);
|
||||
descriptorSet->updateBuffer(2, 0, tangents);
|
||||
descriptorSet->updateBuffer(3, 0, biTangents);
|
||||
descriptorSet->updateBuffer(4, 0, colors);
|
||||
for (size_t i = 0; i < MAX_TEXCOORDS; ++i) {
|
||||
descriptorSet->updateBuffer(3, i, texCoords[i]);
|
||||
descriptorSet->updateBuffer(5, i, texCoords[i]);
|
||||
}
|
||||
descriptorSet->writeChanges();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user