From cc141fc992a6f4980608ede71b767f98d408c860 Mon Sep 17 00:00:00 2001 From: vlj Date: Tue, 9 Sep 2014 17:27:10 +0200 Subject: [PATCH] Factorize matrix block uniform assignment --- src/graphics/shaders.cpp | 153 ------------ src/graphics/shaders.hpp | 425 +-------------------------------- src/graphics/shaders_util.hpp | 435 ++++++++++++++++++++++++++++++++++ 3 files changed, 436 insertions(+), 577 deletions(-) create mode 100644 src/graphics/shaders_util.hpp diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 0b1391a8e..3eb4a0157 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -479,10 +479,6 @@ namespace UtilShader glEnableVertexAttribArray(attrib_position); glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0); uniform_color = glGetUniformLocation(Program, "color"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - } void ColoredLine::setUniforms(const irr::video::SColor &col) @@ -779,10 +775,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str()); AssignUniforms("ModelMatrix", "InverseModelMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "tex"); } @@ -793,10 +785,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str()); AssignUniforms("ModelMatrix", "InverseModelMatrix", "TextureMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "tex"); } @@ -807,7 +795,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str()); AssignUniforms("ModelMatrix", "InverseModelMatrix", "windDir"); - AssignSamplerNames(Program, 0, "tex"); } @@ -818,10 +805,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str()); AssignUniforms("ModelMatrix", "InverseModelMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 1, "normalMap", 0, "DiffuseForAlpha"); } @@ -835,9 +818,6 @@ namespace MeshShader AssignUniforms(); AssignSamplerNames(Program, 0, "tex"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } InstancedObjectRefPass1Shader::InstancedObjectRefPass1Shader() @@ -850,9 +830,6 @@ namespace MeshShader AssignUniforms(); AssignSamplerNames(Program, 0, "tex"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } InstancedGrassPass1Shader::InstancedGrassPass1Shader() @@ -863,11 +840,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_objectref_pass1.frag").c_str()); AssignUniforms("windDir"); - AssignSamplerNames(Program, 0, "tex"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } InstancedNormalMapShader::InstancedNormalMapShader() @@ -878,10 +851,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_normalmap.frag").c_str()); AssignUniforms(); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "normalMap", 1, "DiffuseForAlpha"); } @@ -893,10 +862,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); } @@ -908,12 +873,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_object_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - } InstancedObjectRefPass2Shader::InstancedObjectRefPass2Shader() @@ -924,11 +884,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_objectref_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } DetailledObjectPass2Shader::DetailledObjectPass2Shader() @@ -938,9 +894,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str()); AssignUniforms("ModelMatrix"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail"); } @@ -952,11 +905,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_detailledobject_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } ObjectUnlitShader::ObjectUnlitShader() @@ -965,10 +914,6 @@ namespace MeshShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex"); } @@ -979,10 +924,6 @@ namespace MeshShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_object_unlit.frag").c_str()); AssignUniforms(); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex"); } @@ -993,10 +934,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); } @@ -1007,7 +944,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "windDir"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); } @@ -1019,11 +955,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_grass_pass2.frag").c_str()); AssignUniforms("windDir", "SunDir"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } SphereMapShader::SphereMapShader() @@ -1034,10 +966,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str()); AssignUniforms("ModelMatrix", "InverseModelMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex"); } @@ -1050,10 +978,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_objectpass_spheremap.frag").c_str()); AssignUniforms(); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex"); } @@ -1106,10 +1030,6 @@ namespace MeshShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "tex"); } @@ -1119,10 +1039,6 @@ namespace MeshShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparentfog.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix", "fogmax", "startH", "endH", "start", "end", "col"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "tex"); } @@ -1132,10 +1048,7 @@ namespace MeshShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/billboard.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/billboard.frag").c_str()); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); AssignUniforms("ModelViewMatrix", "ProjectionMatrix", "Position", "Size"); - AssignSamplerNames(Program, 0, "tex"); } @@ -1145,9 +1058,6 @@ namespace MeshShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/colorize.frag").c_str()); AssignUniforms("ModelMatrix", "col"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } InstancedColorizeShader::InstancedColorizeShader() @@ -1157,9 +1067,6 @@ namespace MeshShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/glow_object.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/glow_object.frag").c_str()); AssignUniforms(); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } ShadowShader::ShadowShader() @@ -1181,8 +1088,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str()); } AssignUniforms("layer", "ModelMatrix"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } RSMShader::RSMShader() @@ -1193,9 +1098,6 @@ namespace MeshShader AssignUniforms("RSMMatrix", "ModelMatrix", "TextureMatrix"); AssignSamplerNames(Program, 0, "tex"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } InstancedRSMShader::InstancedRSMShader() @@ -1207,9 +1109,6 @@ namespace MeshShader AssignUniforms("RSMMatrix"); AssignSamplerNames(Program, 0, "tex"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } SplattingRSMShader::SplattingRSMShader() @@ -1220,9 +1119,6 @@ namespace MeshShader AssignUniforms("RSMMatrix", "ModelMatrix"); AssignSamplerNames(Program, 0, "tex_layout", 1, "tex_detail0", 2, "tex_detail1", 3, "tex_detail2", 4, "tex_detail3"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } InstancedShadowShader::InstancedShadowShader() @@ -1246,8 +1142,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str()); } AssignUniforms("layer"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } RefShadowShader::RefShadowShader() @@ -1269,9 +1163,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str()); } AssignUniforms("layer", "ModelMatrix"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "tex"); } @@ -1297,8 +1188,6 @@ namespace MeshShader } AssignUniforms("layer"); AssignSamplerNames(Program, 0, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } GrassShadowShader::GrassShadowShader() @@ -1320,9 +1209,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str()); } AssignUniforms("layer", "ModelMatrix", "windDir"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - AssignSamplerNames(Program, 0, "tex"); } @@ -1348,10 +1234,7 @@ namespace MeshShader } AssignSamplerNames(Program, 0, "tex"); - AssignUniforms("layer", "windDir"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } DisplaceMaskShader::DisplaceMaskShader() @@ -1360,9 +1243,6 @@ namespace MeshShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str()); AssignUniforms("ModelMatrix"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } @@ -1378,8 +1258,6 @@ namespace MeshShader 1, "color_tex", 2, "mask_tex", 3, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } SkyboxShader::SkyboxShader() @@ -1390,9 +1268,6 @@ namespace MeshShader AssignUniforms("ModelMatrix"); AssignSamplerNames(Program, 0, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - glGenVertexArrays(1, &cubevao); glBindVertexArray(cubevao); glBindBuffer(GL_ARRAY_BUFFER, SharedObject::cubevbo); @@ -1409,9 +1284,6 @@ namespace MeshShader GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/normal_visualizer.geom").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str()); AssignUniforms("ModelMatrix", "InverseModelMatrix", "color"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } GLuint ViewFrustrumShader::Program; @@ -1427,9 +1299,6 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/coloredquad.frag").c_str()); attrib_position = glGetAttribLocation(Program, "Position"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); - uniform_color = glGetUniformLocation(Program, "color"); uniform_idx = glGetUniformLocation(Program, "idx"); @@ -1602,9 +1471,6 @@ namespace FullScreenShader AssignUniforms(); AssignSamplerNames(Program, 0, "tex", 1, "dtex"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } SunLightShader::SunLightShader() @@ -1618,9 +1484,6 @@ namespace FullScreenShader AssignSamplerNames(Program, 0, "ntex", 1, "dtex"); AssignUniforms("direction", "col"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } DiffuseEnvMapShader::DiffuseEnvMapShader() @@ -1645,9 +1508,6 @@ namespace FullScreenShader // Use 8 to circumvent a catalyst bug when binding sampler AssignSamplerNames(Program, 0, "ntex", 1, "dtex", 8, "shadowtex"); AssignUniforms("direction", "col"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } RadianceHintsConstructionShader::RadianceHintsConstructionShader() @@ -1696,8 +1556,6 @@ namespace FullScreenShader TU_SHG = 1; TU_SHB = 2; AssignTextureUnit(Program, TexUnit(TU_SHR, "SHR"), TexUnit(TU_SHG, "SHG"), TexUnit(TU_SHB, "SHB")); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } GlobalIlluminationReconstructionShader::GlobalIlluminationReconstructionShader() @@ -1709,10 +1567,7 @@ namespace FullScreenShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gi.frag").c_str()); AssignUniforms("RHMatrix", "InvRHMatrix", "extents"); - AssignSamplerNames(Program, 0, "ntex", 1, "dtex", 2, "SHR", 3, "SHG", 4, "SHB"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } Gaussian17TapHShader::Gaussian17TapHShader() @@ -1721,7 +1576,6 @@ namespace FullScreenShader GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bilateralH.frag").c_str()); AssignUniforms("pixel"); - AssignSamplerNames(Program, 0, "tex", 1, "depth"); } @@ -1854,9 +1708,6 @@ namespace FullScreenShader AssignSamplerNames(Program, 0, "dtex"); AssignUniforms("radius", "k", "sigma"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } FogShader::FogShader() @@ -1868,9 +1719,6 @@ namespace FullScreenShader AssignUniforms("fogmax", "startH", "endH", "start", "end", "col"); AssignSamplerNames(Program, 0, "tex"); - - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); } MotionBlurShader::MotionBlurShader() @@ -1880,7 +1728,6 @@ namespace FullScreenShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/motion_blur.frag").c_str()); AssignUniforms("previous_viewproj", "center", "boost_amount", "mask_radius"); - AssignSamplerNames(Program, 0, "color_buffer", 1, "dtex"); } diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 7f7c9bb5a..c3d6f4f53 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -19,11 +19,9 @@ #include #include -#include #include "config/user_config.hpp" -#include "utils/singleton.hpp" -#include "gl_headers.hpp" +#include "shaders_util.hpp" using namespace irr; class ParticleSystemProxy; @@ -52,427 +50,6 @@ public: }; } -bool needsUBO(); - -unsigned getGLSLVersion(); - -struct UniformHelper -{ - template - static void setUniformsHelper(const std::vector &uniforms) - { - } - - template - static void setUniformsHelper(const std::vector &uniforms, const core::matrix4 &mat, Args... arg) - { - glUniformMatrix4fv(uniforms[N], 1, GL_FALSE, mat.pointer()); - setUniformsHelper(uniforms, arg...); - } - - template - static void setUniformsHelper(const std::vector &uniforms, const video::SColorf &col, Args... arg) - { - glUniform3f(uniforms[N], col.r, col.g, col.b); - setUniformsHelper(uniforms, arg...); - } - - template - static void setUniformsHelper(const std::vector &uniforms, const video::SColor &col, Args... arg) - { - glUniform4i(uniforms[N], col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha()); - setUniformsHelper(uniforms, arg...); - } - - template - static void setUniformsHelper(const std::vector &uniforms, const core::vector3df &v, Args... arg) - { - glUniform3f(uniforms[N], v.X, v.Y, v.Z); - setUniformsHelper(uniforms, arg...); - } - - - template - static void setUniformsHelper(const std::vector &uniforms, const core::vector2df &v, Args... arg) - { - glUniform2f(uniforms[N], v.X, v.Y); - setUniformsHelper(uniforms, arg...); - } - - template - static void setUniformsHelper(const std::vector &uniforms, const core::dimension2df &v, Args... arg) - { - glUniform2f(uniforms[N], v.Width, v.Height); - setUniformsHelper(uniforms, arg...); - } - - template - static void setUniformsHelper(const std::vector &uniforms, float f, Args... arg) - { - glUniform1f(uniforms[N], f); - setUniformsHelper(uniforms, arg...); - } - - template - static void setUniformsHelper(const std::vector &uniforms, int f, Args... arg) - { - glUniform1i(uniforms[N], f); - setUniformsHelper(uniforms, arg...); - } - - template - static void setUniformsHelper(const std::vector &uniforms, const std::vector &v, Args... arg) - { - glUniform1fv(uniforms[N], v.size(), v.data()); - setUniformsHelper(uniforms, arg...); - } - -}; - -void bypassUBO(GLuint Program); - -extern std::vector CleanTable; - -template -class ShaderHelperSingleton : public Singleton -{ -protected: - std::vector uniforms; - - void AssignUniforms_impl() - { - } - - template - void AssignUniforms_impl(const char* name, U... rest) - { - uniforms.push_back(glGetUniformLocation(Program, name)); - AssignUniforms_impl(rest...); - } - - template - void AssignUniforms(U... rest) - { - static_assert(sizeof...(rest) == sizeof...(Args), "Count of Uniform's name mismatch"); - AssignUniforms_impl(rest...); - } - -public: - GLuint Program; - - ShaderHelperSingleton() - { - CleanTable.push_back(this->kill); - } - - ~ShaderHelperSingleton() - { - glDeleteProgram(Program); - } - - void setUniforms(const Args & ... args) const - { - if (needsUBO()) - bypassUBO(Program); - UniformHelper::setUniformsHelper(uniforms, args...); - } -}; - -enum SamplerType { - Trilinear_Anisotropic_Filtered, - Semi_trilinear, - Bilinear_Filtered, - Bilinear_Clamped_Filtered, - Nearest_Filtered, - Shadow_Sampler, - Volume_Linear_Filtered, - Trilinear_cubemap, -}; - -void setTextureSampler(GLenum, GLuint, GLuint, GLuint); - -template -struct CreateSamplers; - -template -struct BindTexture; - -template<> -struct CreateSamplers<> -{ - static void exec(std::vector &, std::vector &e) - {} -}; - -template<> -struct BindTexture<> -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - {} -}; - -GLuint createNearestSampler(); - -template -struct CreateSamplers -{ - static void exec(std::vector &v, std::vector &e) - { - v.push_back(createNearestSampler()); - e.push_back(GL_TEXTURE_2D); - CreateSamplers::exec(v, e); - } -}; - -void BindTextureNearest(unsigned TU, unsigned tid); - -template -struct BindTexture -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - { - BindTextureNearest(TU[N], TexId[N]); - BindTexture::exec(TU, TexId, N + 1); - } -}; - -GLuint createBilinearSampler(); - -template -struct CreateSamplers -{ - static void exec(std::vector &v, std::vector &e) - { - v.push_back(createBilinearSampler()); - e.push_back(GL_TEXTURE_2D); - CreateSamplers::exec(v, e); - } -}; - -void BindTextureBilinear(unsigned TU, unsigned tex); - -template -struct BindTexture -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - { - BindTextureBilinear(TU[N], TexId[N]); - BindTexture::exec(TU, TexId, N + 1); - } -}; - -GLuint createBilinearClampedSampler(); - -template -struct CreateSamplers -{ - static void exec(std::vector &v, std::vector &e) - { - v.push_back(createBilinearClampedSampler()); - e.push_back(GL_TEXTURE_2D); - CreateSamplers::exec(v, e); - } -}; - -void BindTextureBilinearClamped(unsigned TU, unsigned tex); - -template -struct BindTexture -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - { - BindTextureBilinearClamped(TU[N], TexId[N]); - BindTexture::exec(TU, TexId, N + 1); - } -}; - -GLuint createSemiTrilinearSampler(); - -template -struct CreateSamplers -{ - static void exec(std::vector &v, std::vector &e) - { - v.push_back(createSemiTrilinearSampler()); - e.push_back(GL_TEXTURE_2D); - CreateSamplers::exec(v, e); - } -}; - -void BindTextureSemiTrilinear(unsigned TU, unsigned tex); - -template -struct BindTexture -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - { - BindTextureSemiTrilinear(TU[N], TexId[N]); - BindTexture::exec(TU, TexId, N + 1); - } -}; - -GLuint createTrilinearSampler(); - -template -struct CreateSamplers -{ - static void exec(std::vector &v, std::vector &e) - { - v.push_back(createTrilinearSampler()); - e.push_back(GL_TEXTURE_2D); - CreateSamplers::exec(v, e); - } -}; - -void BindTextureTrilinearAnisotropic(unsigned TU, unsigned tex); - -template -struct CreateSamplers -{ - static void exec(std::vector &v, std::vector &e) - { - v.push_back(createTrilinearSampler()); - e.push_back(GL_TEXTURE_CUBE_MAP); - CreateSamplers::exec(v, e); - } -}; - -void BindCubemapTrilinear(unsigned TU, unsigned tex); - -template -struct BindTexture -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - { - BindCubemapTrilinear(TU[N], TexId[N]); - BindTexture::exec(TU, TexId, N + 1); - } -}; - -template -struct BindTexture -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - { - BindTextureTrilinearAnisotropic(TU[N], TexId[N]); - BindTexture::exec(TU, TexId, N + 1); - } -}; - -template -struct CreateSamplers -{ - static void exec(std::vector &v, std::vector &e) - { - v.push_back(createBilinearSampler()); - e.push_back(GL_TEXTURE_3D); - CreateSamplers::exec(v, e); - } -}; - -void BindTextureVolume(unsigned TU, unsigned tex); - -template -struct BindTexture -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - { - BindTextureVolume(TU[N], TexId[N]); - BindTexture::exec(TU, TexId, N + 1); - } -}; - -GLuint createShadowSampler(); - -template -struct CreateSamplers -{ - static void exec(std::vector &v, std::vector &e) - { - v.push_back(createShadowSampler()); - e.push_back(GL_TEXTURE_2D_ARRAY); - CreateSamplers::exec(v, e); - } -}; - -void BindTextureShadow(unsigned TU, unsigned tex); - -template -struct BindTexture -{ - static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) - { - BindTextureShadow(TU[N], TexId[N]); - BindTexture::exec(TU, TexId, N + 1); - } -}; - -template -class TextureRead -{ -private: - template - void AssignTextureNames_impl(GLuint) - { - static_assert(N == sizeof...(tp), "Wrong number of texture name"); - } - - template - void AssignTextureNames_impl(GLuint Program, GLuint TexUnit, const char *name, Args...args) - { - GLuint location = glGetUniformLocation(Program, name); - TextureLocation.push_back(location); - glUniform1i(location, TexUnit); - TextureUnits.push_back(TexUnit); - AssignTextureNames_impl(Program, args...); - } - -protected: - std::vector TextureUnits; - std::vector TextureType; - std::vector TextureLocation; - template - void AssignSamplerNames(GLuint Program, Args...args) - { - CreateSamplers::exec(SamplersId, TextureType); - - glUseProgram(Program); - AssignTextureNames_impl<0>(Program, args...); - glUseProgram(0); - } - -public: - std::vector SamplersId; - void SetTextureUnits(const std::vector &args) - { - assert(args.size() == sizeof...(tp) && "Too much texture unit provided"); - if (getGLSLVersion() >= 330) - { - for (unsigned i = 0; i < args.size(); i++) - { - setTextureSampler(TextureType[i], TextureUnits[i], args[i], SamplersId[i]); - } - } - else - BindTexture::exec(TextureUnits, args, 0); - } - - ~TextureRead() - { - for (unsigned i = 0; i < SamplersId.size(); i++) - glDeleteSamplers(1, &SamplersId[i]); - } - - void SetTextureHandles(const std::vector &args) - { - assert(args.size() == TextureLocation.size() && "Wrong Handle count"); - for (unsigned i = 0; i < args.size(); i++) - { - if (args[i]) - glUniformHandleui64ARB(TextureLocation[i], args[i]); - } - } -}; namespace MeshShader { diff --git a/src/graphics/shaders_util.hpp b/src/graphics/shaders_util.hpp new file mode 100644 index 000000000..378163a8e --- /dev/null +++ b/src/graphics/shaders_util.hpp @@ -0,0 +1,435 @@ +#ifndef SHADERS_UTIL_HPP +#define SHADERS_UTIL_HPP + +#include "utils/singleton.hpp" +#include +#include +#include +#include +#include "gl_headers.hpp" + +bool needsUBO(); + +unsigned getGLSLVersion(); + +struct UniformHelper +{ + template + static void setUniformsHelper(const std::vector &uniforms) + { + } + + template + static void setUniformsHelper(const std::vector &uniforms, const irr::core::matrix4 &mat, Args... arg) + { + glUniformMatrix4fv(uniforms[N], 1, GL_FALSE, mat.pointer()); + setUniformsHelper(uniforms, arg...); + } + + template + static void setUniformsHelper(const std::vector &uniforms, const irr::video::SColorf &col, Args... arg) + { + glUniform3f(uniforms[N], col.r, col.g, col.b); + setUniformsHelper(uniforms, arg...); + } + + template + static void setUniformsHelper(const std::vector &uniforms, const irr::video::SColor &col, Args... arg) + { + glUniform4i(uniforms[N], col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha()); + setUniformsHelper(uniforms, arg...); + } + + template + static void setUniformsHelper(const std::vector &uniforms, const irr::core::vector3df &v, Args... arg) + { + glUniform3f(uniforms[N], v.X, v.Y, v.Z); + setUniformsHelper(uniforms, arg...); + } + + + template + static void setUniformsHelper(const std::vector &uniforms, const irr::core::vector2df &v, Args... arg) + { + glUniform2f(uniforms[N], v.X, v.Y); + setUniformsHelper(uniforms, arg...); + } + + template + static void setUniformsHelper(const std::vector &uniforms, const irr::core::dimension2df &v, Args... arg) + { + glUniform2f(uniforms[N], v.Width, v.Height); + setUniformsHelper(uniforms, arg...); + } + + template + static void setUniformsHelper(const std::vector &uniforms, float f, Args... arg) + { + glUniform1f(uniforms[N], f); + setUniformsHelper(uniforms, arg...); + } + + template + static void setUniformsHelper(const std::vector &uniforms, int f, Args... arg) + { + glUniform1i(uniforms[N], f); + setUniformsHelper(uniforms, arg...); + } + + template + static void setUniformsHelper(const std::vector &uniforms, const std::vector &v, Args... arg) + { + glUniform1fv(uniforms[N], v.size(), v.data()); + setUniformsHelper(uniforms, arg...); + } + +}; + +void bypassUBO(GLuint Program); + +extern std::vector CleanTable; + +template +class ShaderHelperSingleton : public Singleton +{ +protected: + std::vector uniforms; + + void AssignUniforms_impl() + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + if (uniform_ViewProjectionMatrixesUBO != GL_INVALID_INDEX) + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } + + template + void AssignUniforms_impl(const char* name, U... rest) + { + uniforms.push_back(glGetUniformLocation(Program, name)); + AssignUniforms_impl(rest...); + } + + template + void AssignUniforms(U... rest) + { + static_assert(sizeof...(rest) == sizeof...(Args), "Count of Uniform's name mismatch"); + AssignUniforms_impl(rest...); + } + +public: + GLuint Program; + + ShaderHelperSingleton() + { + CleanTable.push_back(this->kill); + } + + ~ShaderHelperSingleton() + { + glDeleteProgram(Program); + } + + void setUniforms(const Args & ... args) const + { + if (needsUBO()) + bypassUBO(Program); + UniformHelper::setUniformsHelper(uniforms, args...); + } +}; + +enum SamplerType { + Trilinear_Anisotropic_Filtered, + Semi_trilinear, + Bilinear_Filtered, + Bilinear_Clamped_Filtered, + Nearest_Filtered, + Shadow_Sampler, + Volume_Linear_Filtered, + Trilinear_cubemap, +}; + +void setTextureSampler(GLenum, GLuint, GLuint, GLuint); + +template +struct CreateSamplers; + +template +struct BindTexture; + +template<> +struct CreateSamplers<> +{ + static void exec(std::vector &, std::vector &e) + {} +}; + +template<> +struct BindTexture<> +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + {} +}; + +GLuint createNearestSampler(); + +template +struct CreateSamplers +{ + static void exec(std::vector &v, std::vector &e) + { + v.push_back(createNearestSampler()); + e.push_back(GL_TEXTURE_2D); + CreateSamplers::exec(v, e); + } +}; + +void BindTextureNearest(unsigned TU, unsigned tid); + +template +struct BindTexture +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + { + BindTextureNearest(TU[N], TexId[N]); + BindTexture::exec(TU, TexId, N + 1); + } +}; + +GLuint createBilinearSampler(); + +template +struct CreateSamplers +{ + static void exec(std::vector &v, std::vector &e) + { + v.push_back(createBilinearSampler()); + e.push_back(GL_TEXTURE_2D); + CreateSamplers::exec(v, e); + } +}; + +void BindTextureBilinear(unsigned TU, unsigned tex); + +template +struct BindTexture +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + { + BindTextureBilinear(TU[N], TexId[N]); + BindTexture::exec(TU, TexId, N + 1); + } +}; + +GLuint createBilinearClampedSampler(); + +template +struct CreateSamplers +{ + static void exec(std::vector &v, std::vector &e) + { + v.push_back(createBilinearClampedSampler()); + e.push_back(GL_TEXTURE_2D); + CreateSamplers::exec(v, e); + } +}; + +void BindTextureBilinearClamped(unsigned TU, unsigned tex); + +template +struct BindTexture +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + { + BindTextureBilinearClamped(TU[N], TexId[N]); + BindTexture::exec(TU, TexId, N + 1); + } +}; + +GLuint createSemiTrilinearSampler(); + +template +struct CreateSamplers +{ + static void exec(std::vector &v, std::vector &e) + { + v.push_back(createSemiTrilinearSampler()); + e.push_back(GL_TEXTURE_2D); + CreateSamplers::exec(v, e); + } +}; + +void BindTextureSemiTrilinear(unsigned TU, unsigned tex); + +template +struct BindTexture +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + { + BindTextureSemiTrilinear(TU[N], TexId[N]); + BindTexture::exec(TU, TexId, N + 1); + } +}; + +GLuint createTrilinearSampler(); + +template +struct CreateSamplers +{ + static void exec(std::vector &v, std::vector &e) + { + v.push_back(createTrilinearSampler()); + e.push_back(GL_TEXTURE_2D); + CreateSamplers::exec(v, e); + } +}; + +void BindTextureTrilinearAnisotropic(unsigned TU, unsigned tex); + +template +struct CreateSamplers +{ + static void exec(std::vector &v, std::vector &e) + { + v.push_back(createTrilinearSampler()); + e.push_back(GL_TEXTURE_CUBE_MAP); + CreateSamplers::exec(v, e); + } +}; + +void BindCubemapTrilinear(unsigned TU, unsigned tex); + +template +struct BindTexture +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + { + BindCubemapTrilinear(TU[N], TexId[N]); + BindTexture::exec(TU, TexId, N + 1); + } +}; + +template +struct BindTexture +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + { + BindTextureTrilinearAnisotropic(TU[N], TexId[N]); + BindTexture::exec(TU, TexId, N + 1); + } +}; + +template +struct CreateSamplers +{ + static void exec(std::vector &v, std::vector &e) + { + v.push_back(createBilinearSampler()); + e.push_back(GL_TEXTURE_3D); + CreateSamplers::exec(v, e); + } +}; + +void BindTextureVolume(unsigned TU, unsigned tex); + +template +struct BindTexture +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + { + BindTextureVolume(TU[N], TexId[N]); + BindTexture::exec(TU, TexId, N + 1); + } +}; + +GLuint createShadowSampler(); + +template +struct CreateSamplers +{ + static void exec(std::vector &v, std::vector &e) + { + v.push_back(createShadowSampler()); + e.push_back(GL_TEXTURE_2D_ARRAY); + CreateSamplers::exec(v, e); + } +}; + +void BindTextureShadow(unsigned TU, unsigned tex); + +template +struct BindTexture +{ + static void exec(const std::vector &TU, const std::vector &TexId, unsigned N) + { + BindTextureShadow(TU[N], TexId[N]); + BindTexture::exec(TU, TexId, N + 1); + } +}; + +template +class TextureRead +{ +private: + template + void AssignTextureNames_impl(GLuint) + { + static_assert(N == sizeof...(tp), "Wrong number of texture name"); + } + + template + void AssignTextureNames_impl(GLuint Program, GLuint TexUnit, const char *name, Args...args) + { + GLuint location = glGetUniformLocation(Program, name); + TextureLocation.push_back(location); + glUniform1i(location, TexUnit); + TextureUnits.push_back(TexUnit); + AssignTextureNames_impl(Program, args...); + } + +protected: + std::vector TextureUnits; + std::vector TextureType; + std::vector TextureLocation; + template + void AssignSamplerNames(GLuint Program, Args...args) + { + CreateSamplers::exec(SamplersId, TextureType); + + glUseProgram(Program); + AssignTextureNames_impl<0>(Program, args...); + glUseProgram(0); + } + +public: + std::vector SamplersId; + void SetTextureUnits(const std::vector &args) + { + assert(args.size() == sizeof...(tp) && "Too much texture unit provided"); + if (getGLSLVersion() >= 330) + { + for (unsigned i = 0; i < args.size(); i++) + { + setTextureSampler(TextureType[i], TextureUnits[i], args[i], SamplersId[i]); + } + } + else + BindTexture::exec(TextureUnits, args, 0); + } + + ~TextureRead() + { + for (unsigned i = 0; i < SamplersId.size(); i++) + glDeleteSamplers(1, &SamplersId[i]); + } + + void SetTextureHandles(const std::vector &args) + { + assert(args.size() == TextureLocation.size() && "Wrong Handle count"); + for (unsigned i = 0; i < args.size(); i++) + { + if (args[i]) + glUniformHandleui64ARB(TextureLocation[i], args[i]); + } + } +}; +#endif \ No newline at end of file