~ | Small fix emissive texture

This commit is contained in:
TheRedShip
2025-02-09 16:57:51 +01:00
parent e791b8b27d
commit 515df55c1f
3 changed files with 12 additions and 10 deletions

View File

@ -348,18 +348,16 @@ void ObjParser::parseMtl(std::stringstream &input_line, Scene &scene)
std::vector<std::string>::iterator it = std::find(previous_textures.begin(), previous_textures.end(), path); std::vector<std::string>::iterator it = std::find(previous_textures.begin(), previous_textures.end(), path);
if (it != previous_textures.end()) 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 else
{ {
mat->texture_index = previous_textures.size();; mat->emission_texture_index = previous_textures.size();;
scene.addEmissionTexture(path); scene.addEmissionTexture(path);
} }
if (mat->emission == 0) if (mat->emission == 0)
mat->emission = 1; mat->emission = 1;
} }
// else
// std::cerr << "unsupported material setting : " << identifier << std::endl;
} }
if(mat) if(mat)
{ {

View File

@ -242,11 +242,12 @@ bool Scene::loadTextures()
return (false); return (false);
} }
std::cout << "Loaded texture: " << path << " (" << width << "x" << height << ")" << std::endl;
GLuint textureID; GLuint textureID;
glGenTextures(1, &textureID); glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, 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_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
@ -272,12 +273,13 @@ bool Scene::loadTextures()
return (false); return (false);
} }
std::cout << "Loaded emissive texture: " << path << " (" << width << "x" << height << ")" << std::endl;
GLuint textureID; GLuint textureID;
glGenTextures(1, &textureID); glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, 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_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

View File

@ -216,10 +216,11 @@ void Shader::set_textures(std::vector<GLuint> texture_ids, std::vector<GLuint> e
glBindTexture(GL_TEXTURE_2D, texture_ids[i]); glBindTexture(GL_TEXTURE_2D, texture_ids[i]);
std::string uniform_name = "textures[" + std::to_string(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); 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++) for (size_t i = 0; i < emissive_texture_ids.size(); i++)
{ {
@ -228,6 +229,7 @@ void Shader::set_textures(std::vector<GLuint> texture_ids, std::vector<GLuint> e
glActiveTexture(GL_TEXTURE0 + currentUnit); glActiveTexture(GL_TEXTURE0 + currentUnit);
glBindTexture(GL_TEXTURE_2D, emissive_texture_ids[i]); glBindTexture(GL_TEXTURE_2D, emissive_texture_ids[i]);
std::string uniform_name = "emissive_textures[" + std::to_string(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); glUniform1i(glGetUniformLocation(_program_compute, uniform_name.c_str()), currentUnit);
} }
} }