mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
~ | Small fix emissive texture
This commit is contained in:
@ -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);
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -216,10 +216,11 @@ void Shader::set_textures(std::vector<GLuint> texture_ids, std::vector<GLuint> 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<GLuint> texture_ids, std::vector<GLuint> 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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user