Trying to fix wrong tex coord imports

This commit is contained in:
Dynamitos
2025-05-04 21:30:01 +02:00
parent 91c31bc219
commit ee412201e6
13 changed files with 78 additions and 83 deletions
+12 -9
View File
@@ -152,9 +152,10 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>&
aiTextureMapMode mapMode = aiTextureMapMode_Clamp;
float blend = std::numeric_limits<float>::max();
aiTextureOp op = aiTextureOp_Add;
if (material->GetTexture(type, index, &texPath, &mapping, &uvIndex, nullptr, nullptr, nullptr) != AI_SUCCESS) {
if (material->GetTexture(type, index, &texPath, &mapping, &uvIndex, &blend, &op, &mapMode) != AI_SUCCESS) {
std::cout << "fuck" << std::endl;
}
uvIndex = 1;
std::string textureKey = fmt::format("{0}Texture{1}", paramKey, index);
auto texFilename = std::filesystem::path(texPath.C_Str());
PTextureAsset texture;
@@ -357,7 +358,7 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>&
}
// Emissive
//addScalarParameter(KEY_EMISSIVE_INTENSITY, AI_MATKEY_EMISSIVE_INTENSITY);
// addScalarParameter(KEY_EMISSIVE_INTENSITY, AI_MATKEY_EMISSIVE_INTENSITY);
addVectorParameter(KEY_EMISSIVE_COLOR, AI_MATKEY_COLOR_EMISSIVE);
std::string outputEmissive = KEY_EMISSIVE_COLOR;
uint32 numEmissive = material->GetTextureCount(aiTextureType_EMISSION_COLOR);
@@ -536,7 +537,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) {
@@ -559,13 +560,15 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
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
// 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));
tangents[i] = tangent;
biTangents[i] = 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);
colors[i] = StaticMeshVertexData::ColorType(mesh->mColors[0][i].r * 65535, mesh->mColors[0][i].g * 65535,
mesh->mColors[0][i].b * 65535);
} else {
colors[i] = StaticMeshVertexData::ColorType(1, 1, 1);
}
@@ -577,7 +580,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);