basic sponza import

This commit is contained in:
Dynamitos
2025-03-31 11:39:17 +02:00
parent 7a3aa482c7
commit 4a34220cd7
10 changed files with 51 additions and 44 deletions
+10 -5
View File
@@ -536,7 +536,7 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
}
Array<StaticMeshVertexData::NormalType> normals(mesh->mNumVertices);
Array<StaticMeshVertexData::TangentType> tangents(mesh->mNumVertices);
Array<StaticMeshVertexData::BiTangentType> biTangents(mesh->mNumVertices);
//Array<StaticMeshVertexData::BiTangentType> biTangents(mesh->mNumVertices);
Array<StaticMeshVertexData::ColorType> colors(mesh->mNumVertices);
for (uint32 i = 0; i < mesh->mNumVertices; ++i) {
@@ -555,10 +555,15 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
tangent = Vector(mesh->mTangents[i].x, mesh->mTangents[i].y, mesh->mTangents[i].z);
biTangent = Vector(mesh->mBitangents[i].x, mesh->mBitangents[i].y, mesh->mBitangents[i].z);
}
normals[i] = normal; // encodeQTangent(Matrix3(tangent, biTangent, normal));
tangents[i] = tangent;
biTangents[i] = biTangent;
normals[i] = normal; // encodeQTangent(Matrix3(tangent, biTangent, normal));
// the fourth component encodes the sign of the bitangent.
// in the shader we calc n x t, and b = (n x t) * sign
// so we try to cross the two, and see what is the result, and if it is
// the same as b, the dot product is 1, and if they are inverse, the dot product is
// -1, which is the sign we need
tangents[i] = Vector4(tangent, dot(glm::cross(normal, tangent), biTangent));
if (mesh->HasVertexColors(0)) {
colors[i] = StaticMeshVertexData::ColorType(mesh->mColors[0][i].r * 65535, mesh->mColors[0][i].g * 65535, mesh->mColors[0][i].b * 65535);
} else {
@@ -572,7 +577,7 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
}
vertexData->loadNormals(offset, normals);
vertexData->loadTangents(offset, tangents);
vertexData->loadBitangents(offset, biTangents);
//vertexData->loadBitangents(offset, biTangents);
vertexData->loadColors(offset, colors);
Array<uint32> indices(mesh->mNumFaces * 3);
+5 -5
View File
@@ -42,7 +42,7 @@ void TextureLoader::importAsset(TextureImportArgs args) {
PTextureAsset ref = asset;
asset->setStatus(Asset::Status::Loading);
AssetRegistry::get().registerTexture(std::move(asset));
import(args, ref);
getThreadPool().runAsync([=]() { import(args, ref); });
}
PTextureAsset TextureLoader::getPlaceholderTexture() { return placeholderAsset; }
@@ -111,13 +111,13 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) {
ktxBasisParams basisParams = {
.structSize = sizeof(ktxBasisParams),
.uastc = true,
.threadCount = 14,
.compressionLevel = 3,
.uastcFlags = KTX_PACK_UASTC_LEVEL_FASTEST,
.threadCount = 1,
.compressionLevel = 2,
.uastcFlags = KTX_PACK_UASTC_LEVEL_FASTER,
.uastcRDO = true,
};
KTX_ASSERT(ktxTexture2_CompressBasisEx(kTexture, &basisParams));
KTX_ASSERT(ktxTexture2_DeflateZstd(kTexture, 20));
KTX_ASSERT(ktxTexture2_DeflateZstd(kTexture, 10));
char writer[100];
snprintf(writer, sizeof(writer), "%s version %s", "SeeleEngine", "0.0.1");
+4 -4
View File
@@ -124,10 +124,10 @@ int main() {
.filePath = sourcePath / "import/models/rttest.glb",
.importPath = "",
});
//AssetImporter::importMesh(MeshImportArgs{
// .filePath = sourcePath / "import/models/main1_sponza/sponza.gltf",
// .importPath = "sponza",
//});
AssetImporter::importMesh(MeshImportArgs{
.filePath = sourcePath / "import/models/main1_sponza/sponza.gltf",
.importPath = "sponza",
});
// AssetImporter::importMesh(MeshImportArgs{
// .filePath = sourcePath / "import/models/town_hall.glb",
// .importPath = "",