Fix for GL 3.1 context

This commit is contained in:
vlj 2014-06-27 18:14:24 +02:00
parent 9e44c5980a
commit bde17a28d5
10 changed files with 67 additions and 86 deletions

View File

@ -17,9 +17,15 @@ layout (std140) uniform MatrixesData
uniform mat4 ModelMatrix; uniform mat4 ModelMatrix;
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position; layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord; layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord; layout(location = 4) in vec2 SecondTexcoord;
#else
in vec3 Position;
in vec2 Texcoord;
in vec2 SecondTexcoord;
#endif
out vec2 uv; out vec2 uv;
out vec2 uv_bis; out vec2 uv_bis;

View File

@ -3,11 +3,17 @@ uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView; uniform mat4 TransposeInverseModelView;
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position; layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal; layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color; layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord; layout(location = 3) in vec2 Texcoord;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
#endif
out vec3 nor; out vec3 nor;
out vec2 uv; out vec2 uv;

View File

@ -15,10 +15,17 @@ in vec3 Origin;
in vec3 Orientation; in vec3 Orientation;
in vec3 Scale; in vec3 Scale;
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position; layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal; layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color; layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord; layout(location = 3) in vec2 Texcoord;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
#endif
out vec3 nor; out vec3 nor;
out vec2 uv; out vec2 uv;

View File

@ -19,9 +19,15 @@ in vec3 Origin;
in vec3 Orientation; in vec3 Orientation;
in vec3 Scale; in vec3 Scale;
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position; layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal; layout(location = 1) in vec3 Normal;
layout(location = 3) in vec2 Texcoord; layout(location = 3) in vec2 Texcoord;
#else
in vec3 Position;
in vec3 Normal;
in vec2 Texcoord;
#endif
out vec3 nor; out vec3 nor;
out vec2 uv; out vec2 uv;

View File

@ -10,11 +10,17 @@ layout (std140) uniform MatrixesData
uniform mat4 ModelMatrix; uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix; uniform mat4 InverseModelMatrix;
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position; layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord; layout(location = 3) in vec2 Texcoord;
layout(location = 5) in vec3 Tangent; layout(location = 5) in vec3 Tangent;
layout(location = 6) in vec3 Bitangent; layout(location = 6) in vec3 Bitangent;
#else
in vec3 Position;
in vec2 Texcoord;
in vec3 Tangent;
in vec3 Bitangent;
#endif
out vec3 tangent; out vec3 tangent;
out vec3 bitangent; out vec3 bitangent;

View File

@ -24,12 +24,19 @@ uniform mat4 TextureMatrix =
0., 0., 1., 0., 0., 0., 1., 0.,
0., 0., 0., 1.); 0., 0., 0., 1.);
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position; layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal; layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color; layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord; layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord; layout(location = 4) in vec2 SecondTexcoord;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
in vec2 SecondTexcoord;
#endif
out vec3 nor; out vec3 nor;
out vec2 uv; out vec2 uv;

View File

@ -44,6 +44,7 @@ PFNGLUNIFORM4FVPROC glUniform4fv;
PFNGLGETPROGRAMIVPROC glGetProgramiv; PFNGLGETPROGRAMIVPROC glGetProgramiv;
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
PFNGLBLENDEQUATIONPROC glBlendEquation; PFNGLBLENDEQUATIONPROC glBlendEquation;
PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
@ -197,6 +198,7 @@ void initGL()
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog"); glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog");
glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings"); glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings");
glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation"); glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation");
glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glBindAttribLocation");
glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation"); glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation");
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor"); glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor");
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced"); glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced");

View File

@ -68,6 +68,7 @@ extern PFNGLUNIFORM4IPROC glUniform4i;
extern PFNGLGETPROGRAMIVPROC glGetProgramiv; extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
extern PFNGLBLENDEQUATIONPROC glBlendEquation; extern PFNGLBLENDEQUATIONPROC glBlendEquation;
extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
@ -143,6 +144,16 @@ GLint LoadProgram(Types ... args)
{ {
GLint ProgramID = glCreateProgram(); GLint ProgramID = glCreateProgram();
loadAndAttach(ProgramID, args...); loadAndAttach(ProgramID, args...);
if (irr_driver->getGLSLVersion() < 330)
{
glBindAttribLocation(ProgramID, 0, "Position");
glBindAttribLocation(ProgramID, 1, "Normal");
glBindAttribLocation(ProgramID, 2, "Color");
glBindAttribLocation(ProgramID, 3, "Texcoord");
glBindAttribLocation(ProgramID, 4, "SecondTexcoord");
glBindAttribLocation(ProgramID, 5, "Tangent");
glBindAttribLocation(ProgramID, 6, "Bitangent");
}
glLinkProgram(ProgramID); glLinkProgram(ProgramID);
GLint Result = GL_FALSE; GLint Result = GL_FALSE;

View File

@ -450,9 +450,6 @@ namespace MeshShader
// Solid Normal and depth pass shaders // Solid Normal and depth pass shaders
GLuint ObjectPass1Shader::Program; GLuint ObjectPass1Shader::Program;
GLuint ObjectPass1Shader::attrib_position;
GLuint ObjectPass1Shader::attrib_normal;
GLuint ObjectPass1Shader::attrib_texcoord;
GLuint ObjectPass1Shader::uniform_MM; GLuint ObjectPass1Shader::uniform_MM;
GLuint ObjectPass1Shader::uniform_IMM; GLuint ObjectPass1Shader::uniform_IMM;
GLuint ObjectPass1Shader::uniform_tex; GLuint ObjectPass1Shader::uniform_tex;
@ -463,9 +460,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), 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()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_normal = glGetAttribLocation(Program, "Normal");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_tex = glGetUniformLocation(Program, "tex"); uniform_tex = glGetUniformLocation(Program, "tex");
@ -486,9 +480,6 @@ namespace MeshShader
} }
GLuint ObjectRefPass1Shader::Program; GLuint ObjectRefPass1Shader::Program;
GLuint ObjectRefPass1Shader::attrib_position;
GLuint ObjectRefPass1Shader::attrib_normal;
GLuint ObjectRefPass1Shader::attrib_texcoord;
GLuint ObjectRefPass1Shader::uniform_MM; GLuint ObjectRefPass1Shader::uniform_MM;
GLuint ObjectRefPass1Shader::uniform_IMM; GLuint ObjectRefPass1Shader::uniform_IMM;
GLuint ObjectRefPass1Shader::uniform_TM; GLuint ObjectRefPass1Shader::uniform_TM;
@ -500,9 +491,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), 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()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_normal = glGetAttribLocation(Program, "Normal");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
@ -525,10 +513,6 @@ namespace MeshShader
} }
GLuint GrassPass1Shader::Program; GLuint GrassPass1Shader::Program;
GLuint GrassPass1Shader::attrib_position;
GLuint GrassPass1Shader::attrib_texcoord;
GLuint GrassPass1Shader::attrib_normal;
GLuint GrassPass1Shader::attrib_color;
GLuint GrassPass1Shader::uniform_MVP; GLuint GrassPass1Shader::uniform_MVP;
GLuint GrassPass1Shader::uniform_TIMV; GLuint GrassPass1Shader::uniform_TIMV;
GLuint GrassPass1Shader::uniform_tex; GLuint GrassPass1Shader::uniform_tex;
@ -540,10 +524,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), 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()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_normal = glGetAttribLocation(Program, "Normal");
attrib_color = glGetAttribLocation(Program, "Color");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView"); uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
uniform_tex = glGetUniformLocation(Program, "tex"); uniform_tex = glGetUniformLocation(Program, "tex");
@ -559,10 +539,6 @@ namespace MeshShader
} }
GLuint NormalMapShader::Program; GLuint NormalMapShader::Program;
GLuint NormalMapShader::attrib_position;
GLuint NormalMapShader::attrib_texcoord;
GLuint NormalMapShader::attrib_tangent;
GLuint NormalMapShader::attrib_bitangent;
GLuint NormalMapShader::uniform_MM; GLuint NormalMapShader::uniform_MM;
GLuint NormalMapShader::uniform_IMM; GLuint NormalMapShader::uniform_IMM;
GLuint NormalMapShader::uniform_normalMap; GLuint NormalMapShader::uniform_normalMap;
@ -574,10 +550,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/normalmap.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/normalmap.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_tangent = glGetAttribLocation(Program, "Tangent");
attrib_bitangent = glGetAttribLocation(Program, "Bitangent");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_normalMap = glGetUniformLocation(Program, "normalMap"); uniform_normalMap = glGetUniformLocation(Program, "normalMap");
@ -718,8 +690,6 @@ namespace MeshShader
// Solid Lit pass shaders // Solid Lit pass shaders
GLuint ObjectPass2Shader::Program; GLuint ObjectPass2Shader::Program;
GLuint ObjectPass2Shader::attrib_position;
GLuint ObjectPass2Shader::attrib_texcoord;
GLuint ObjectPass2Shader::uniform_MM; GLuint ObjectPass2Shader::uniform_MM;
GLuint ObjectPass2Shader::uniform_TM; GLuint ObjectPass2Shader::uniform_TM;
GLuint ObjectPass2Shader::uniform_ambient; GLuint ObjectPass2Shader::uniform_ambient;
@ -731,8 +701,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
@ -875,9 +843,6 @@ namespace MeshShader
} }
GLuint DetailledObjectPass2Shader::Program; GLuint DetailledObjectPass2Shader::Program;
GLuint DetailledObjectPass2Shader::attrib_position;
GLuint DetailledObjectPass2Shader::attrib_texcoord;
GLuint DetailledObjectPass2Shader::attrib_second_texcoord;
GLuint DetailledObjectPass2Shader::uniform_MM; GLuint DetailledObjectPass2Shader::uniform_MM;
GLuint DetailledObjectPass2Shader::uniform_ambient; GLuint DetailledObjectPass2Shader::uniform_ambient;
GLuint DetailledObjectPass2Shader::TU_Albedo; GLuint DetailledObjectPass2Shader::TU_Albedo;
@ -889,9 +854,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
GLuint uniform_Detail = glGetUniformLocation(Program, "Detail"); GLuint uniform_Detail = glGetUniformLocation(Program, "Detail");
@ -923,8 +885,6 @@ namespace MeshShader
} }
GLuint ObjectUnlitShader::Program; GLuint ObjectUnlitShader::Program;
GLuint ObjectUnlitShader::attrib_position;
GLuint ObjectUnlitShader::attrib_texcoord;
GLuint ObjectUnlitShader::uniform_MM; GLuint ObjectUnlitShader::uniform_MM;
GLuint ObjectUnlitShader::TU_tex; GLuint ObjectUnlitShader::TU_tex;
@ -933,8 +893,6 @@ namespace MeshShader
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_tex = glGetUniformLocation(Program, "tex"); GLuint uniform_tex = glGetUniformLocation(Program, "tex");
if (!UserConfigParams::m_ubo_disabled) if (!UserConfigParams::m_ubo_disabled)
@ -957,9 +915,6 @@ namespace MeshShader
} }
GLuint ObjectRimLimitShader::Program; GLuint ObjectRimLimitShader::Program;
GLuint ObjectRimLimitShader::attrib_position;
GLuint ObjectRimLimitShader::attrib_texcoord;
GLuint ObjectRimLimitShader::attrib_normal;
GLuint ObjectRimLimitShader::uniform_MM; GLuint ObjectRimLimitShader::uniform_MM;
GLuint ObjectRimLimitShader::uniform_IMM; GLuint ObjectRimLimitShader::uniform_IMM;
GLuint ObjectRimLimitShader::uniform_TM; GLuint ObjectRimLimitShader::uniform_TM;
@ -971,9 +926,6 @@ namespace MeshShader
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_rimlit.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_rimlit.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_normal = glGetAttribLocation(Program, "Normal");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
@ -1012,8 +964,6 @@ namespace MeshShader
} }
GLuint UntexturedObjectShader::Program; GLuint UntexturedObjectShader::Program;
GLuint UntexturedObjectShader::attrib_position;
GLuint UntexturedObjectShader::attrib_color;
GLuint UntexturedObjectShader::uniform_MM; GLuint UntexturedObjectShader::uniform_MM;
GLuint UntexturedObjectShader::uniform_ambient; GLuint UntexturedObjectShader::uniform_ambient;
@ -1023,8 +973,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/untextured_object.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/untextured_object.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_color = glGetAttribLocation(Program, "Color");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
@ -1054,8 +1002,6 @@ namespace MeshShader
GLuint ObjectRefPass2Shader::Program; GLuint ObjectRefPass2Shader::Program;
GLuint ObjectRefPass2Shader::attrib_position;
GLuint ObjectRefPass2Shader::attrib_texcoord;
GLuint ObjectRefPass2Shader::uniform_MM; GLuint ObjectRefPass2Shader::uniform_MM;
GLuint ObjectRefPass2Shader::uniform_TM; GLuint ObjectRefPass2Shader::uniform_TM;
GLuint ObjectRefPass2Shader::uniform_ambient; GLuint ObjectRefPass2Shader::uniform_ambient;
@ -1068,8 +1014,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
@ -1104,9 +1048,6 @@ namespace MeshShader
} }
GLuint GrassPass2Shader::Program; GLuint GrassPass2Shader::Program;
GLuint GrassPass2Shader::attrib_position;
GLuint GrassPass2Shader::attrib_texcoord;
GLuint GrassPass2Shader::attrib_color;
GLuint GrassPass2Shader::uniform_MVP; GLuint GrassPass2Shader::uniform_MVP;
GLuint GrassPass2Shader::uniform_ambient; GLuint GrassPass2Shader::uniform_ambient;
GLuint GrassPass2Shader::uniform_windDir; GLuint GrassPass2Shader::uniform_windDir;
@ -1118,9 +1059,6 @@ namespace MeshShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_color = glGetAttribLocation(Program, "Color");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo");
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
@ -1218,8 +1156,6 @@ namespace MeshShader
} }
GLuint SphereMapShader::Program; GLuint SphereMapShader::Program;
GLuint SphereMapShader::attrib_position;
GLuint SphereMapShader::attrib_normal;
GLuint SphereMapShader::uniform_MM; GLuint SphereMapShader::uniform_MM;
GLuint SphereMapShader::uniform_IMM; GLuint SphereMapShader::uniform_IMM;
GLuint SphereMapShader::uniform_ambient; GLuint SphereMapShader::uniform_ambient;
@ -1232,8 +1168,6 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_normal = glGetAttribLocation(Program, "Normal");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
uniform_ambient = glGetUniformLocation(Program, "ambient"); uniform_ambient = glGetUniformLocation(Program, "ambient");
@ -1283,9 +1217,6 @@ namespace MeshShader
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_second_texcoord = glGetAttribLocation(Program, "SecondTexcoord");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
GLuint uniform_tex_layout = glGetUniformLocation(Program, "tex_layout"); GLuint uniform_tex_layout = glGetUniformLocation(Program, "tex_layout");
GLuint uniform_tex_detail0 = glGetUniformLocation(Program, "tex_detail0"); GLuint uniform_tex_detail0 = glGetUniformLocation(Program, "tex_detail0");
@ -1544,6 +1475,8 @@ namespace MeshShader
void RSMShader::init() void RSMShader::init()
{ {
if (irr_driver->getGLSLVersion() < 150)
return;
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/rsm.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/rsm.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rsm.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rsm.frag").c_str());
@ -1734,9 +1667,12 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position"); attrib_position = glGetAttribLocation(Program, "Position");
uniform_MVP = glGetUniformLocation(Program, "ModelMatrix"); uniform_MVP = glGetUniformLocation(Program, "ModelMatrix");
if (!UserConfigParams::m_ubo_disabled)
{
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
} }
}
void DisplaceMaskShader::setUniforms(const core::matrix4 &ModelMatrix) void DisplaceMaskShader::setUniforms(const core::matrix4 &ModelMatrix)
{ {
@ -2391,6 +2327,8 @@ namespace FullScreenShader
void RadianceHintsConstructionShader::init() void RadianceHintsConstructionShader::init()
{ {
if (irr_driver->getGLSLVersion() < 150)
return;
if (irr_driver->hasVSLayerExtension()) if (irr_driver->hasVSLayerExtension())
{ {
Program = LoadProgram( Program = LoadProgram(
@ -2520,6 +2458,8 @@ namespace FullScreenShader
void ComputeGaussian17TapHShader::init() void ComputeGaussian17TapHShader::init()
{ {
#if WIN32 #if WIN32
if (irr_driver->getGLSLVersion() < 420)
return;
Program = LoadProgram( Program = LoadProgram(
GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralH.comp").c_str()); GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralH.comp").c_str());
uniform_source = glGetUniformLocation(Program, "source"); uniform_source = glGetUniformLocation(Program, "source");
@ -2579,6 +2519,8 @@ namespace FullScreenShader
void ComputeGaussian17TapVShader::init() void ComputeGaussian17TapVShader::init()
{ {
#if WIN32 #if WIN32
if (irr_driver->getGLSLVersion() < 420)
return;
Program = LoadProgram( Program = LoadProgram(
GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralV.comp").c_str()); GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralV.comp").c_str());
uniform_source = glGetUniformLocation(Program, "source"); uniform_source = glGetUniformLocation(Program, "source");

View File

@ -53,7 +53,6 @@ class ObjectPass1Shader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_normal;
static GLuint uniform_MM, uniform_IMM, uniform_tex; static GLuint uniform_MM, uniform_IMM, uniform_tex;
static void init(); static void init();
@ -64,7 +63,6 @@ class ObjectRefPass1Shader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_normal, attrib_texcoord;
static GLuint uniform_MM, uniform_TM, uniform_IMM, uniform_tex; static GLuint uniform_MM, uniform_TM, uniform_IMM, uniform_tex;
static void init(); static void init();
@ -75,7 +73,6 @@ class GrassPass1Shader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_normal, attrib_color;
static GLuint uniform_MVP, uniform_TIMV, uniform_tex, uniform_windDir; static GLuint uniform_MVP, uniform_TIMV, uniform_tex, uniform_windDir;
static void init(); static void init();
@ -86,7 +83,6 @@ class NormalMapShader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_tangent, attrib_bitangent;
static GLuint uniform_MM, uniform_IMM, uniform_normalMap, uniform_DiffuseForAlpha; static GLuint uniform_MM, uniform_IMM, uniform_normalMap, uniform_DiffuseForAlpha;
static void init(); static void init();
@ -130,7 +126,6 @@ class ObjectPass2Shader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM, uniform_TM, uniform_ambient; static GLuint uniform_MM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo; static GLuint TU_Albedo;
@ -166,7 +161,6 @@ class DetailledObjectPass2Shader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
static GLuint uniform_MM, uniform_ambient; static GLuint uniform_MM, uniform_ambient;
static GLuint TU_Albedo, TU_detail; static GLuint TU_Albedo, TU_detail;
@ -178,7 +172,6 @@ class ObjectRimLimitShader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_normal, attrib_texcoord;
static GLuint uniform_MM, uniform_IMM, uniform_TM, uniform_ambient; static GLuint uniform_MM, uniform_IMM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo; static GLuint TU_Albedo;
@ -190,7 +183,6 @@ class UntexturedObjectShader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_color;
static GLuint uniform_MM, uniform_ambient; static GLuint uniform_MM, uniform_ambient;
static void init(); static void init();
@ -201,7 +193,6 @@ class ObjectUnlitShader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM; static GLuint uniform_MM;
static GLuint TU_tex; static GLuint TU_tex;
@ -213,7 +204,6 @@ class ObjectRefPass2Shader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM, uniform_TM, uniform_ambient; static GLuint uniform_MM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo; static GLuint TU_Albedo;
@ -225,7 +215,6 @@ class GrassPass2Shader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_ambient, uniform_windDir; static GLuint uniform_MVP, uniform_ambient, uniform_windDir;
static GLuint TU_Albedo; static GLuint TU_Albedo;
@ -249,7 +238,6 @@ class SphereMapShader
{ {
public: public:
static GLuint Program; static GLuint Program;
static GLuint attrib_position, attrib_normal;
static GLuint uniform_MM, uniform_IMM, uniform_ambient; static GLuint uniform_MM, uniform_IMM, uniform_ambient;
static GLuint TU_tex; static GLuint TU_tex;