mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 10:48:34 +02:00
+ | Fixing texture limit on old gpu
This commit is contained in:
@ -40,7 +40,7 @@ class ShaderProgram
|
|||||||
|
|
||||||
void set_textures(std::map<std::string, std::vector<GLuint>> texture_ids);
|
void set_textures(std::map<std::string, std::vector<GLuint>> texture_ids);
|
||||||
|
|
||||||
void set_define(const std::string &name, const std::string &value);
|
void setDefine(const std::string &name, const std::string &value);
|
||||||
|
|
||||||
GLuint getProgram(void) const;
|
GLuint getProgram(void) const;
|
||||||
|
|
||||||
|
@ -93,8 +93,13 @@ vec2 getSphereUV(vec3 surfacePoint)
|
|||||||
return vec2(u, v);
|
return vec2(u, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
uniform sampler2D textures[64];
|
#if SHADER_TEXTURE_MAX
|
||||||
uniform sampler2D emissive_textures[64];
|
uniform sampler2D textures[SHADER_TEXTURE_MAX];
|
||||||
|
uniform sampler2D emissive_textures[SHADER_TEXTURE_MAX];
|
||||||
|
#else
|
||||||
|
uniform sampler2D textures[64];
|
||||||
|
uniform sampler2D emissive_textures[64];
|
||||||
|
#endif
|
||||||
|
|
||||||
vec2 getTextureColor(hitInfo hit)
|
vec2 getTextureColor(hitInfo hit)
|
||||||
{
|
{
|
||||||
|
@ -47,8 +47,13 @@ int main(int argc, char **argv)
|
|||||||
//6 light_accum
|
//6 light_accum
|
||||||
//7 color
|
//7 color
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ShaderProgram raytracing_program;
|
ShaderProgram raytracing_program;
|
||||||
Shader compute = Shader(GL_COMPUTE_SHADER, "shaders/compute.glsl");
|
Shader compute = Shader(GL_COMPUTE_SHADER, "shaders/compute.glsl");
|
||||||
|
int maxTextureUnits; glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
||||||
|
compute.setDefine("TEXTURE_MAX", std::to_string(maxTextureUnits / 2));
|
||||||
|
compute.reload();
|
||||||
raytracing_program.attachShader(&compute);
|
raytracing_program.attachShader(&compute);
|
||||||
raytracing_program.link();
|
raytracing_program.link();
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ void ShaderProgram::set_textures(std::map<std::string, std::vector<GLuint>> text
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderProgram::set_define(const std::string &name, const std::string &value)
|
void ShaderProgram::setDefine(const std::string &name, const std::string &value)
|
||||||
{
|
{
|
||||||
for (Shader *shader : _shaders)
|
for (Shader *shader : _shaders)
|
||||||
shader->setDefine(name, value);
|
shader->setDefine(name, value);
|
||||||
|
@ -262,7 +262,7 @@ void Window::imGuiRender(ShaderProgram &raytracing_program)
|
|||||||
{
|
{
|
||||||
if (ImGui::Checkbox("Enable##0", (bool *)(&_scene->getVolume().enabled)))
|
if (ImGui::Checkbox("Enable##0", (bool *)(&_scene->getVolume().enabled)))
|
||||||
{
|
{
|
||||||
raytracing_program.set_define("FOG", std::to_string(_scene->getVolume().enabled));
|
raytracing_program.setDefine("FOG", std::to_string(_scene->getVolume().enabled));
|
||||||
raytracing_program.reloadShaders();
|
raytracing_program.reloadShaders();
|
||||||
has_changed = true;
|
has_changed = true;
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ void Window::imGuiRender(ShaderProgram &raytracing_program)
|
|||||||
{
|
{
|
||||||
if (ImGui::Checkbox("Enable##2", (bool *)(&_scene->getDebug().enabled)))
|
if (ImGui::Checkbox("Enable##2", (bool *)(&_scene->getDebug().enabled)))
|
||||||
{
|
{
|
||||||
raytracing_program.set_define("DEBUG", std::to_string(_scene->getDebug().enabled));
|
raytracing_program.setDefine("DEBUG", std::to_string(_scene->getDebug().enabled));
|
||||||
raytracing_program.reloadShaders();
|
raytracing_program.reloadShaders();
|
||||||
has_changed = true;
|
has_changed = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user