Assimp Loading Issue - SlaggyWolfie/learn-opengl GitHub Wiki
Assimp Loading Issue (WIP)
I am going absolutely insane.
C++ Mesh Drawing code:
void Mesh::draw(const Shader& shader)
{
unsigned int diffuseNumber = 1;
unsigned int specularNumber = 1;
unsigned int normalNumber = 1;
unsigned int heightNumber = 1;
for (unsigned int i = 0; i < textures.size(); ++i)
{
glActiveTexture(GL_TEXTURE0 + i);
std::string number;
const std::string name = textures[i].type;
// TODO
// hard-coded but whatever for now
if (name == "texture_diffuse") number = std::to_string(diffuseNumber++);
else if (name == "texture_specular") number = std::to_string(specularNumber++);
else if (name == "texture_normal") number = std::to_string(normalNumber++);
else if (name == "texture_height") number = std::to_string(heightNumber++);
std::string address("material.");
address.append(name).append(number);
shader.set(address, i);
glBindTexture(GL_TEXTURE_2D, textures[i].id);
}
// Draw Mesh / Pipe-in bound information
glBindVertexArray(_vao);
glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
//glActiveTexture(GL_TEXTURE0);
}
Situation 1: Use everything as per default (pass in unsigned integer for texture ID)
GLSL Display diffuse:
fragmentColor = texture(material.texture_diffuse1, textureCoordinate);
GLSL Display specular (and basically everything else):
fragmentColor = texture(material.texture_specular1, textureCoordinate);
Situation 2: Pass in signed integer instead.
Changes to C++ code from above:
shader.set(address, (int)i);
Diffuse:
fragmentColor = texture(material.texture_diffuse1, textureCoordinate);
Cool, so that works.
Specular:
fragmentColor = texture(material.texture_specular1, textureCoordinate);