diff --git a/srcs/class/ObjParser.cpp b/srcs/class/ObjParser.cpp index 924595a..42a87d1 100644 --- a/srcs/class/ObjParser.cpp +++ b/srcs/class/ObjParser.cpp @@ -348,18 +348,16 @@ void ObjParser::parseMtl(std::stringstream &input_line, Scene &scene) std::vector::iterator it = std::find(previous_textures.begin(), previous_textures.end(), path); if (it != previous_textures.end()) - mat->texture_index = std::distance(previous_textures.begin(), it); + mat->emission_texture_index = std::distance(previous_textures.begin(), it); else { - mat->texture_index = previous_textures.size();; + mat->emission_texture_index = previous_textures.size();; scene.addEmissionTexture(path); } if (mat->emission == 0) mat->emission = 1; } - // else - // std::cerr << "unsupported material setting : " << identifier << std::endl; } if(mat) { diff --git a/srcs/class/Scene.cpp b/srcs/class/Scene.cpp index 0abd4cb..5bf8a61 100644 --- a/srcs/class/Scene.cpp +++ b/srcs/class/Scene.cpp @@ -242,11 +242,12 @@ bool Scene::loadTextures() return (false); } - std::cout << "Loaded texture: " << path << " (" << width << "x" << height << ")" << std::endl; - + GLuint textureID; glGenTextures(1, &textureID); glBindTexture(GL_TEXTURE_2D, textureID); + + std::cout << "Loaded texture: (" << textureID << "): " << path << " (" << width << "x" << height << ")" << std::endl; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); @@ -272,12 +273,13 @@ bool Scene::loadTextures() return (false); } - std::cout << "Loaded emissive texture: " << path << " (" << width << "x" << height << ")" << std::endl; - + GLuint textureID; glGenTextures(1, &textureID); glBindTexture(GL_TEXTURE_2D, textureID); - + + std::cout << "Loaded emissive texture (" << textureID << "): " << path << " (" << width << "x" << height << ")" << std::endl; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); diff --git a/srcs/class/Shader.cpp b/srcs/class/Shader.cpp index 4e29930..c752a1f 100644 --- a/srcs/class/Shader.cpp +++ b/srcs/class/Shader.cpp @@ -216,10 +216,11 @@ void Shader::set_textures(std::vector texture_ids, std::vector e glBindTexture(GL_TEXTURE_2D, texture_ids[i]); std::string uniform_name = "textures[" + std::to_string(i) + "]"; + // std::cout << "Loading texture " << uniform_name << " at unit " << i << std::endl; glUniform1i(glGetUniformLocation(_program_compute, uniform_name.c_str()), i); } - size_t start_texture = texture_ids.size() + 1; + size_t start_texture = texture_ids.size(); for (size_t i = 0; i < emissive_texture_ids.size(); i++) { @@ -228,6 +229,7 @@ void Shader::set_textures(std::vector texture_ids, std::vector e glActiveTexture(GL_TEXTURE0 + currentUnit); glBindTexture(GL_TEXTURE_2D, emissive_texture_ids[i]); std::string uniform_name = "emissive_textures[" + std::to_string(i) + "]"; + // std::cout << "Loading emissive texture " << uniform_name << " (" << emissive_texture_ids[i] << ") at unit " << currentUnit << std::endl; glUniform1i(glGetUniformLocation(_program_compute, uniform_name.c_str()), currentUnit); } }