Width and height are passed by UBO

This commit is contained in:
vlj 2014-05-17 02:39:55 +02:00
parent c465900ee3
commit 883b39591f
20 changed files with 107 additions and 108 deletions

View File

@ -1,10 +1,19 @@
uniform sampler2D displacement_tex;
uniform sampler2D mask_tex;
uniform sampler2D color_tex;
uniform vec2 screen;
uniform vec2 dir;
uniform vec2 dir2;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#if __VERSION__ >= 130
in vec2 uv;
in vec2 uv_bis;

View File

@ -1,5 +1,12 @@
uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
in vec2 quadcorner;
in vec2 texcoord;

View File

@ -20,6 +20,7 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif

View File

@ -5,6 +5,7 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
uniform vec3 windDir;

View File

@ -11,6 +11,7 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif

View File

@ -11,6 +11,7 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif

View File

@ -2,9 +2,18 @@ uniform sampler2D Albedo;
uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
uniform vec2 screen;
uniform vec3 ambient;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#if __VERSION__ >= 130
in vec3 nor;
in vec2 uv;

View File

@ -11,11 +11,11 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform samplerCube tex;
uniform vec2 screen;
#if __VERSION__ >= 130
in vec3 nor;

View File

@ -1,7 +1,16 @@
uniform sampler2D tex;
uniform sampler2D dtex;
uniform mat4 invproj;
uniform vec2 screen;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
in float lf;
in vec2 tc;

View File

@ -1,5 +1,12 @@
uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
uniform vec3 color_from;
uniform vec3 color_to;

View File

@ -1,7 +1,6 @@
uniform sampler2D ntex;
uniform sampler2D dtex;
uniform float spec;
uniform vec2 screen;
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
@ -16,6 +15,7 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif

View File

@ -11,6 +11,7 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif

View File

@ -11,12 +11,11 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform samplerCube tex;
uniform vec2 screen;
#if __VERSION__ >= 130
out vec4 FragColor;

View File

@ -6,9 +6,18 @@ uniform sampler2D tex_detail3;
uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
uniform vec2 screen;
uniform vec3 ambient;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#if __VERSION__ >= 130
in vec2 uv;
in vec2 uv_bis;

View File

@ -3,7 +3,6 @@
uniform sampler2D dtex;
uniform vec4 samplePoints[16];
uniform vec2 screen;
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
@ -18,6 +17,7 @@ layout (std140) uniform MatrixesData
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif

View File

@ -1,9 +1,18 @@
uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
uniform vec2 screen;
uniform vec3 ambient;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
vec3 getLightFactor(float specMapValue)
{
vec2 tc = gl_FragCoord.xy / screen;

View File

@ -276,7 +276,7 @@ private:
void renderParticles();
void computeSunVisibility();
void renderScene(scene::ICameraSceneNode * const camnode, std::vector<GlowData>& glows, float dt, bool hasShadows);
void computeCameraMatrix(scene::ICameraSceneNode * const camnode);
void computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height);
void renderShadows();
void renderGlow(std::vector<GlowData>& glows);
void renderSSAO();

View File

@ -144,6 +144,9 @@ void IrrDriver::renderGLSL(float dt)
rg->preRenderCallback(camera); // adjusts start referee
m_scene_manager->setActiveCamera(camnode);
const core::recti &viewport = camera->getViewport();
computeCameraMatrix(camnode, viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y);
renderScene(camnode, glows, dt, track->hasShadows());
// Debug physic
@ -183,8 +186,6 @@ void IrrDriver::renderGLSL(float dt)
}
}
const core::recti &viewport = camera->getViewport();
// Render the post-processed scene
if (UserConfigParams::m_dynamic_lights)
{
@ -258,7 +259,6 @@ void IrrDriver::renderGLSL(float dt)
void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, std::vector<GlowData>& glows, float dt, bool hasShadow)
{
computeCameraMatrix(camnode);
glBindBufferBase(GL_UNIFORM_BUFFER, 0, SharedObject::ViewProjectionMatrixesUBO);
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
@ -603,7 +603,7 @@ void IrrDriver::renderParticles()
m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT_EFFECT);
}
void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode)
void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height)
{
m_scene_manager->drawAll(scene::ESNRP_CAMERA);
irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION));
@ -689,7 +689,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode)
camnode->setNearValue(oldnear);
camnode->setFarValue(oldfar);
float *tmp = new float[16 * 8];
float *tmp = new float[18 * 8];
memcpy(tmp, irr_driver->getViewMatrix().pointer(), 16 * sizeof(float));
memcpy(&tmp[16], irr_driver->getProjMatrix().pointer(), 16 * sizeof(float));
@ -698,9 +698,11 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode)
size_t size = irr_driver->getShadowViewProj().size();
for (unsigned i = 0; i < size; i++)
memcpy(&tmp[16 * i + 64], irr_driver->getShadowViewProj()[i].pointer(), 16 * sizeof(float));
tmp[128] = width;
tmp[129] = height;
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::ViewProjectionMatrixesUBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0, 16 * 8 * sizeof(float), tmp);
glBufferSubData(GL_UNIFORM_BUFFER, 0, (16 * 8 + 2) * sizeof(float), tmp);
delete []tmp;
}

View File

@ -170,7 +170,7 @@ static void initShadowVPMUBO()
{
glGenBuffers(1, &SharedObject::ViewProjectionMatrixesUBO);
glBindBuffer(GL_UNIFORM_BUFFER, SharedObject::ViewProjectionMatrixesUBO);
glBufferData(GL_UNIFORM_BUFFER, 16 * 8 * sizeof(float), 0, GL_STATIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, (16 * 8 + 2) * sizeof(float), 0, GL_STATIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
@ -699,7 +699,6 @@ namespace MeshShader
GLuint ObjectPass2Shader::attrib_texcoord;
GLuint ObjectPass2Shader::uniform_MM;
GLuint ObjectPass2Shader::uniform_TM;
GLuint ObjectPass2Shader::uniform_screen;
GLuint ObjectPass2Shader::uniform_ambient;
GLuint ObjectPass2Shader::TU_Albedo;
@ -717,7 +716,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -737,7 +735,6 @@ namespace MeshShader
bypassUBO(Program);
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -750,7 +747,6 @@ namespace MeshShader
GLuint InstancedObjectPass2Shader::attrib_scale;
GLuint InstancedObjectPass2Shader::uniform_VP;
GLuint InstancedObjectPass2Shader::uniform_TM;
GLuint InstancedObjectPass2Shader::uniform_screen;
GLuint InstancedObjectPass2Shader::uniform_ambient;
GLuint InstancedObjectPass2Shader::TU_Albedo;
@ -772,7 +768,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
TU_Albedo = 3;
@ -793,7 +788,6 @@ namespace MeshShader
bypassUBO(Program);
glUniformMatrix4fv(uniform_VP, 1, GL_FALSE, ViewProjectionMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -806,7 +800,6 @@ namespace MeshShader
GLuint InstancedObjectRefPass2Shader::attrib_scale;
GLuint InstancedObjectRefPass2Shader::uniform_VP;
GLuint InstancedObjectRefPass2Shader::uniform_TM;
GLuint InstancedObjectRefPass2Shader::uniform_screen;
GLuint InstancedObjectRefPass2Shader::uniform_ambient;
GLuint InstancedObjectRefPass2Shader::TU_Albedo;
@ -828,7 +821,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
TU_Albedo = 3;
@ -849,7 +841,6 @@ namespace MeshShader
bypassUBO(Program);
glUniformMatrix4fv(uniform_VP, 1, GL_FALSE, ViewProjectionMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -859,7 +850,6 @@ namespace MeshShader
GLuint DetailledObjectPass2Shader::attrib_texcoord;
GLuint DetailledObjectPass2Shader::attrib_second_texcoord;
GLuint DetailledObjectPass2Shader::uniform_MM;
GLuint DetailledObjectPass2Shader::uniform_screen;
GLuint DetailledObjectPass2Shader::uniform_ambient;
GLuint DetailledObjectPass2Shader::TU_Albedo;
GLuint DetailledObjectPass2Shader::TU_detail;
@ -879,7 +869,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -900,8 +889,6 @@ namespace MeshShader
if (UserConfigParams::m_ubo_disabled)
bypassUBO(Program);
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -944,7 +931,6 @@ namespace MeshShader
GLuint ObjectRimLimitShader::uniform_MM;
GLuint ObjectRimLimitShader::uniform_IMM;
GLuint ObjectRimLimitShader::uniform_TM;
GLuint ObjectRimLimitShader::uniform_screen;
GLuint ObjectRimLimitShader::uniform_ambient;
GLuint ObjectRimLimitShader::TU_Albedo;
@ -963,7 +949,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
@ -987,8 +972,6 @@ namespace MeshShader
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_IMM, 1, GL_FALSE, InverseModelMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -997,7 +980,6 @@ namespace MeshShader
GLuint UntexturedObjectShader::attrib_position;
GLuint UntexturedObjectShader::attrib_color;
GLuint UntexturedObjectShader::uniform_MM;
GLuint UntexturedObjectShader::uniform_screen;
GLuint UntexturedObjectShader::uniform_ambient;
void UntexturedObjectShader::init()
@ -1012,7 +994,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -1029,8 +1010,6 @@ namespace MeshShader
if (UserConfigParams::m_ubo_disabled)
bypassUBO(Program);
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -1041,7 +1020,6 @@ namespace MeshShader
GLuint ObjectRefPass2Shader::attrib_texcoord;
GLuint ObjectRefPass2Shader::uniform_MM;
GLuint ObjectRefPass2Shader::uniform_TM;
GLuint ObjectRefPass2Shader::uniform_screen;
GLuint ObjectRefPass2Shader::uniform_ambient;
GLuint ObjectRefPass2Shader::TU_Albedo;
@ -1060,7 +1038,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -1081,8 +1058,6 @@ namespace MeshShader
bypassUBO(Program);
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -1092,7 +1067,6 @@ namespace MeshShader
GLuint GrassPass2Shader::attrib_texcoord;
GLuint GrassPass2Shader::attrib_color;
GLuint GrassPass2Shader::uniform_MVP;
GLuint GrassPass2Shader::uniform_screen;
GLuint GrassPass2Shader::uniform_ambient;
GLuint GrassPass2Shader::uniform_windDir;
GLuint GrassPass2Shader::TU_Albedo;
@ -1111,7 +1085,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
uniform_windDir = glGetUniformLocation(Program, "windDir");
TU_Albedo = 3;
@ -1128,8 +1101,6 @@ namespace MeshShader
const core::vector3df &windDirection)
{
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
glUniform3f(uniform_windDir, windDirection.X, windDirection.Y, windDirection.Z);
@ -1144,7 +1115,6 @@ namespace MeshShader
GLuint InstancedGrassPass2Shader::attrib_orientation;
GLuint InstancedGrassPass2Shader::attrib_scale;
GLuint InstancedGrassPass2Shader::uniform_VP;
GLuint InstancedGrassPass2Shader::uniform_screen;
GLuint InstancedGrassPass2Shader::uniform_ambient;
GLuint InstancedGrassPass2Shader::uniform_windDir;
GLuint InstancedGrassPass2Shader::uniform_invproj;
@ -1173,7 +1143,6 @@ namespace MeshShader
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
GLuint uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
uniform_windDir = glGetUniformLocation(Program, "windDir");
uniform_invproj = glGetUniformLocation(Program, "invproj");
@ -1201,7 +1170,6 @@ namespace MeshShader
glUniformMatrix4fv(uniform_VP, 1, GL_FALSE, ViewProjectionMatrix.pointer());
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, invproj.pointer());
glUniformMatrix4fv(uniform_IVM, 1, GL_FALSE, InverseViewMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
glUniform3f(uniform_SunDir, SunDir.X, SunDir.Y, SunDir.Z);
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
@ -1213,7 +1181,6 @@ namespace MeshShader
GLuint SphereMapShader::attrib_normal;
GLuint SphereMapShader::uniform_MM;
GLuint SphereMapShader::uniform_IMM;
GLuint SphereMapShader::uniform_screen;
GLuint SphereMapShader::TU_tex;
void SphereMapShader::init()
@ -1226,7 +1193,6 @@ namespace MeshShader
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix");
GLuint uniform_tex = glGetUniformLocation(Program, "tex");
uniform_screen = glGetUniformLocation(Program, "screen");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
TU_tex = 3;
@ -1242,7 +1208,6 @@ namespace MeshShader
bypassUBO(Program);
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniformMatrix4fv(uniform_IMM, 1, GL_FALSE, InverseModelMatrix.pointer());
glUniform2f(uniform_screen, screen.X, screen.Y);
}
GLuint SplattingShader::Program;
@ -1250,7 +1215,6 @@ namespace MeshShader
GLuint SplattingShader::attrib_texcoord;
GLuint SplattingShader::attrib_second_texcoord;
GLuint SplattingShader::uniform_MM;
GLuint SplattingShader::uniform_screen;
GLuint SplattingShader::uniform_ambient;
GLuint SplattingShader::TU_tex_layout;
GLuint SplattingShader::TU_tex_detail0;
@ -1275,7 +1239,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
TU_tex_layout = 3;
TU_tex_detail0 = 4;
@ -1298,8 +1261,6 @@ namespace MeshShader
void SplattingShader::setUniforms(const core::matrix4 &ModelMatrix)
{
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniform2f(uniform_screen, float(UserConfigParams::m_width),
float(UserConfigParams::m_height));
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -1310,7 +1271,6 @@ namespace MeshShader
GLuint CausticsShader::uniform_MVP;
GLuint CausticsShader::uniform_dir;
GLuint CausticsShader::uniform_dir2;
GLuint CausticsShader::uniform_screen;
GLuint CausticsShader::uniform_ambient;
GLuint CausticsShader::TU_Albedo;
GLuint CausticsShader::TU_caustictex;
@ -1331,7 +1291,6 @@ namespace MeshShader
GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ambient = glGetUniformLocation(Program, "ambient");
TU_Albedo = 3;
TU_caustictex = 4;
@ -1350,7 +1309,6 @@ namespace MeshShader
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
glUniform2f(uniform_dir, dir.X, dir.Y);
glUniform2f(uniform_dir2, dir2.X, dir2.Y);
glUniform2f(uniform_screen, screen.X, screen.Y);
const video::SColorf s = irr_driver->getSceneManager()->getAmbientLight();
glUniform3f(uniform_ambient, s.r, s.g, s.b);
}
@ -1424,7 +1382,6 @@ namespace MeshShader
GLuint TransparentFogShader::uniform_start;
GLuint TransparentFogShader::uniform_end;
GLuint TransparentFogShader::uniform_col;
GLuint TransparentFogShader::uniform_screen;
GLuint TransparentFogShader::uniform_ipvmat;
void TransparentFogShader::init()
@ -1444,7 +1401,6 @@ namespace MeshShader
uniform_start = glGetUniformLocation(Program, "start");
uniform_end = glGetUniformLocation(Program, "end");
uniform_col = glGetUniformLocation(Program, "col");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_ipvmat = glGetUniformLocation(Program, "ipvmat");
}
@ -1458,7 +1414,6 @@ namespace MeshShader
glUniform1f(uniform_start, start);
glUniform1f(uniform_end, end);
glUniform3f(uniform_col, col.X, col.Y, col.Z);
glUniform2f(uniform_screen, float(UserConfigParams::m_width), float(UserConfigParams::m_height));
glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
glUniform1i(uniform_tex, TU_tex);
}
@ -1751,7 +1706,6 @@ namespace MeshShader
GLuint DisplaceShader::uniform_color_tex;
GLuint DisplaceShader::uniform_dir;
GLuint DisplaceShader::uniform_dir2;
GLuint DisplaceShader::uniform_screen;
void DisplaceShader::init()
{
@ -1768,7 +1722,6 @@ namespace MeshShader
uniform_mask_tex = glGetUniformLocation(Program, "mask_tex");
uniform_dir = glGetUniformLocation(Program, "dir");
uniform_dir2 = glGetUniformLocation(Program, "dir2");
uniform_screen = glGetUniformLocation(Program, "screen");
}
void DisplaceShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex)
@ -1777,7 +1730,6 @@ namespace MeshShader
glUniformMatrix4fv(uniform_MV, 1, GL_FALSE, ModelViewMatrix.pointer());
glUniform2f(uniform_dir, dir.X, dir.Y);
glUniform2f(uniform_dir2, dir2.X, dir2.Y);
glUniform2f(uniform_screen, screen.X, screen.Y);
glUniform1i(uniform_displacement_tex, TU_displacement_tex);
glUniform1i(uniform_mask_tex, TU_mask_tex);
glUniform1i(uniform_color_tex, TU_color_tex);
@ -1787,7 +1739,6 @@ namespace MeshShader
GLuint SkyboxShader::attrib_position;
GLuint SkyboxShader::uniform_MM;
GLuint SkyboxShader::uniform_tex;
GLuint SkyboxShader::uniform_screen;
GLuint SkyboxShader::cubevao;
void SkyboxShader::init()
@ -1798,7 +1749,6 @@ namespace MeshShader
attrib_position = glGetAttribLocation(Program, "Position");
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_screen = glGetUniformLocation(Program, "screen");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -1817,7 +1767,6 @@ namespace MeshShader
bypassUBO(Program);
glUniformMatrix4fv(uniform_MM, 1, GL_FALSE, ModelMatrix.pointer());
glUniform1i(uniform_tex, TU_tex);
glUniform2f(uniform_screen, screen.X, screen.Y);
}
}
@ -1832,7 +1781,6 @@ namespace LightShader
GLuint PointLightShader::uniform_ntex;
GLuint PointLightShader::uniform_dtex;
GLuint PointLightShader::uniform_spec;
GLuint PointLightShader::uniform_screen;
GLuint PointLightShader::vbo;
GLuint PointLightShader::vao;
@ -1851,7 +1799,6 @@ namespace LightShader
uniform_ntex = glGetUniformLocation(Program, "ntex");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_spec = glGetUniformLocation(Program, "spec");
uniform_screen = glGetUniformLocation(Program, "screen");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
@ -1880,7 +1827,6 @@ namespace LightShader
if (UserConfigParams::m_ubo_disabled)
bypassUBO(Program);
glUniform1f(uniform_spec, 200);
glUniform2f(uniform_screen, screen.X, screen.Y);
glUniform1i(uniform_ntex, TU_ntex);
glUniform1i(uniform_dtex, TU_dtex);
@ -1990,7 +1936,6 @@ namespace ParticleShader
GLuint SimpleParticleRender::uniform_viewmatrix;
GLuint SimpleParticleRender::uniform_tex;
GLuint SimpleParticleRender::uniform_dtex;
GLuint SimpleParticleRender::uniform_screen;
GLuint SimpleParticleRender::uniform_invproj;
GLuint SimpleParticleRender::uniform_color_from;
GLuint SimpleParticleRender::uniform_color_to;
@ -2011,7 +1956,6 @@ namespace ParticleShader
uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_invproj = glGetUniformLocation(Program, "invproj");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_color_from = glGetUniformLocation(Program, "color_from");
assert(uniform_color_from != -1);
@ -2024,7 +1968,6 @@ namespace ParticleShader
const ParticleSystemProxy* particle_system)
{
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniform2f(uniform_screen, width, height);
glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
glUniform1i(uniform_tex, TU_tex);
@ -2048,7 +1991,6 @@ namespace ParticleShader
GLuint FlipParticleRender::uniform_viewmatrix;
GLuint FlipParticleRender::uniform_tex;
GLuint FlipParticleRender::uniform_dtex;
GLuint FlipParticleRender::uniform_screen;
GLuint FlipParticleRender::uniform_invproj;
void FlipParticleRender::init()
@ -2068,14 +2010,12 @@ namespace ParticleShader
uniform_viewmatrix = glGetUniformLocation(Program, "ViewMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_invproj = glGetUniformLocation(Program, "invproj");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_dtex = glGetUniformLocation(Program, "dtex");
}
void FlipParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex)
{
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniform2f(uniform_screen, width, height);
glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
glUniform1i(uniform_tex, TU_tex);
@ -2169,7 +2109,6 @@ namespace FullScreenShader
GLuint DepthOfFieldShader::uniform_tex;
GLuint DepthOfFieldShader::uniform_depth;
GLuint DepthOfFieldShader::uniform_invproj;
GLuint DepthOfFieldShader::uniform_screen;
GLuint DepthOfFieldShader::vao;
void DepthOfFieldShader::init()
@ -2179,7 +2118,6 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/dof.frag").c_str());
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_depth = glGetUniformLocation(Program, "dtex");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_invproj = glGetUniformLocation(Program, "invprojm");
vao = createVAO(Program);
}
@ -2187,7 +2125,6 @@ namespace FullScreenShader
void DepthOfFieldShader::setUniforms(const core::matrix4 &invproj, const core::vector2df &screen, unsigned TU_tex, unsigned TU_dtex)
{
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, invproj.pointer());
glUniform2f(uniform_screen, screen.X, screen.Y);
glUniform1i(uniform_tex, TU_tex);
glUniform1i(uniform_depth, TU_dtex);
}
@ -2551,7 +2488,6 @@ namespace FullScreenShader
GLuint SSAOShader::uniform_dtex;
GLuint SSAOShader::uniform_noise_texture;
GLuint SSAOShader::uniform_samplePoints;
GLuint SSAOShader::uniform_screen;
GLuint SSAOShader::vao;
float SSAOShader::SSAOSamples[64];
@ -2566,7 +2502,6 @@ namespace FullScreenShader
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_noise_texture = glGetUniformLocation(Program, "noise_texture");
uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]");
uniform_screen = glGetUniformLocation(Program, "screen");
vao = createVAO(Program);
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -2690,7 +2625,6 @@ namespace FullScreenShader
if (UserConfigParams::m_ubo_disabled)
bypassUBO(Program);
glUniform4fv(uniform_samplePoints, 16, SSAOSamples);
glUniform2f(uniform_screen, screen.X, screen.Y);
glUniform1i(uniform_dtex, TU_dtex);
glUniform1i(uniform_noise_texture, TU_noise);

View File

@ -131,7 +131,7 @@ class ObjectPass2Shader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM, uniform_TM, uniform_screen, uniform_ambient;
static GLuint uniform_MM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
static void init();
@ -143,7 +143,7 @@ class InstancedObjectPass2Shader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_VP, uniform_TM, uniform_screen, uniform_ambient;
static GLuint uniform_VP, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
static void init();
@ -155,7 +155,7 @@ class InstancedObjectRefPass2Shader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_VP, uniform_TM, uniform_screen, uniform_ambient;
static GLuint uniform_VP, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
static void init();
@ -167,7 +167,7 @@ class DetailledObjectPass2Shader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
static GLuint uniform_MM, uniform_screen, uniform_ambient;
static GLuint uniform_MM, uniform_ambient;
static GLuint TU_Albedo, TU_detail;
static void init();
@ -179,7 +179,7 @@ class ObjectRimLimitShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_normal, attrib_texcoord;
static GLuint uniform_MM, uniform_IMM, uniform_TM, uniform_screen, uniform_ambient;
static GLuint uniform_MM, uniform_IMM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
static void init();
@ -191,7 +191,7 @@ class UntexturedObjectShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_color;
static GLuint uniform_MM, uniform_screen, uniform_ambient;
static GLuint uniform_MM, uniform_ambient;
static void init();
static void setUniforms(const core::matrix4 &ModelMatrix);
@ -214,7 +214,7 @@ class ObjectRefPass2Shader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MM, uniform_TM, uniform_screen, uniform_ambient;
static GLuint uniform_MM, uniform_TM, uniform_ambient;
static GLuint TU_Albedo;
static void init();
@ -226,7 +226,7 @@ class GrassPass2Shader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir;
static GLuint uniform_MVP, uniform_ambient, uniform_windDir;
static GLuint TU_Albedo;
static void init();
@ -238,7 +238,7 @@ class InstancedGrassPass2Shader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_normal, attrib_color, attrib_origin, attrib_orientation, attrib_scale;
static GLuint uniform_VP, uniform_TM, uniform_IVM, uniform_screen, uniform_ambient, uniform_windDir, uniform_invproj, uniform_SunDir;
static GLuint uniform_VP, uniform_TM, uniform_IVM, uniform_ambient, uniform_windDir, uniform_invproj, uniform_SunDir;
static GLuint TU_Albedo, TU_dtex;
static void init();
@ -250,7 +250,7 @@ class SphereMapShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_normal;
static GLuint uniform_MM, uniform_IMM, uniform_screen;
static GLuint uniform_MM, uniform_IMM;
static GLuint TU_tex;
static void init();
@ -262,7 +262,7 @@ class SplattingShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
static GLuint uniform_MM, uniform_screen, uniform_ambient;
static GLuint uniform_MM, uniform_ambient;
static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
static void init();
@ -274,7 +274,7 @@ class CausticsShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint uniform_MVP, uniform_dir, uniform_dir2, uniform_screen, uniform_ambient;
static GLuint uniform_MVP, uniform_dir, uniform_dir2, uniform_ambient;
static GLuint TU_Albedo, TU_caustictex;
static void init();
@ -308,7 +308,7 @@ class TransparentFogShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_TM, uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_screen, uniform_ipvmat;
static GLuint uniform_MVP, uniform_TM, uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_ipvmat;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
@ -407,7 +407,7 @@ class DisplaceShader
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_screen, uniform_dir, uniform_dir2;
static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_dir, uniform_dir2;
static void init();
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
@ -418,7 +418,7 @@ class SkyboxShader
public:
static GLuint Program;
static GLuint attrib_position;
static GLuint uniform_MM, uniform_tex, uniform_screen;
static GLuint uniform_MM, uniform_tex;
static GLuint cubevao;
static void init();
@ -449,7 +449,7 @@ namespace LightShader
public:
static GLuint Program;
static GLuint attrib_Position, attrib_Energy, attrib_Color, attrib_Radius;
static GLuint uniform_ntex, uniform_dtex, uniform_spec, uniform_screen;
static GLuint uniform_ntex, uniform_dtex, uniform_spec;
static GLuint vbo;
static GLuint vao;
@ -489,7 +489,7 @@ class SimpleParticleRender
public:
static GLuint Program;
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_invproj, uniform_color_from, uniform_color_to;
static void init();
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
@ -502,7 +502,7 @@ class FlipParticleRender
public:
static GLuint Program;
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_invproj;
static void init();
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
@ -549,7 +549,7 @@ class DepthOfFieldShader
{
public:
static GLuint Program;
static GLuint uniform_tex, uniform_depth, uniform_screen, uniform_invproj;
static GLuint uniform_tex, uniform_depth, uniform_invproj;
static GLuint vao;
static void init();
@ -738,7 +738,7 @@ class SSAOShader
{
public:
static GLuint Program;
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_samplePoints, uniform_screen;
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_samplePoints;
static GLuint vao;
static float SSAOSamples[64];