Trying to fix wrong tex coord imports
This commit is contained in:
@@ -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);
|
||||
|
||||
+8
-4
@@ -25,7 +25,7 @@ using namespace Seele::Editor;
|
||||
static Gfx::OGraphics graphics;
|
||||
|
||||
int main() {
|
||||
std::string gameName = "MinecraftClone";
|
||||
std::string gameName = "MeshShadingDemo";
|
||||
std::filesystem::path outputPath = fmt::format("../../{0}Game", gameName);
|
||||
std::filesystem::path sourcePath = fmt::format("../../{0}", gameName);
|
||||
#ifdef WIN32
|
||||
@@ -57,9 +57,13 @@ int main() {
|
||||
AssetImporter::importEnvironmentMap(EnvironmentImportArgs{
|
||||
.filePath = sourcePath / "import" / "textures" / "newport_loft.hdr",
|
||||
});
|
||||
AssetImporter::importTexture(TextureImportArgs{
|
||||
.filePath = sourcePath / "import" / "textures" / "grass_block_side.png",
|
||||
.importPath = "",
|
||||
//AssetImporter::importTexture(TextureImportArgs{
|
||||
// .filePath = sourcePath / "import" / "textures" / "grass_block_side.png",
|
||||
// .importPath = "",
|
||||
//});
|
||||
AssetImporter::importMesh(MeshImportArgs{
|
||||
.filePath = sourcePath / "import" / "models" / "main1_sponza" / "floor.glb",
|
||||
.importPath = "sponza",
|
||||
});
|
||||
|
||||
getThreadPool().waitIdle();
|
||||
|
||||
Reference in New Issue
Block a user