Merge object_pass*.vert

This commit is contained in:
vlj 2014-03-26 18:12:05 +01:00
parent ae5c7b8c3d
commit 8b652ababb
3 changed files with 17 additions and 30 deletions

View File

@ -1,4 +1,5 @@
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView;
uniform mat4 TextureMatrix = uniform mat4 TextureMatrix =
mat4(1., 0., 0., 0., mat4(1., 0., 0., 0.,
0., 1., 0., 0., 0., 1., 0., 0.,
@ -9,12 +10,16 @@ uniform mat4 TextureMatrix =
in vec3 Position; in vec3 Position;
in vec2 Texcoord; in vec2 Texcoord;
in vec2 SecondTexcoord; in vec2 SecondTexcoord;
in vec3 Normal;
out vec3 nor;
out vec2 uv; out vec2 uv;
out vec2 uv_bis; out vec2 uv_bis;
#else #else
attribute vec3 Position; attribute vec3 Position;
attribute vec3 Normal;
attribute vec2 Texcoord; attribute vec2 Texcoord;
attribute vec2 SecondTexcoord; attribute vec2 SecondTexcoord;
varying vec3 nor;
varying vec2 uv; varying vec2 uv;
varying vec2 uv_bis; varying vec2 uv_bis;
#endif #endif
@ -22,7 +27,8 @@ varying vec2 uv_bis;
void main(void) void main(void)
{ {
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
uv_bis = SecondTexcoord;
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.); gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
uv_bis = SecondTexcoord;
} }

View File

@ -1,19 +0,0 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView;
#if __VERSION__ >= 130
in vec3 Position;
in vec3 Normal;
out vec3 nor;
#else
attribute vec3 Position;
attribute vec3 Normal;
varying vec3 nor;
#endif
void main(void)
{
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
}

View File

@ -389,7 +389,7 @@ namespace MeshShader
void ObjectPass1Shader::init() void ObjectPass1Shader::init()
{ {
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass1.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_position = glGetAttribLocation(Program, "Position");
@ -515,7 +515,7 @@ namespace MeshShader
void ObjectPass2Shader::init() void ObjectPass2Shader::init()
{ {
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass2.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_position = glGetAttribLocation(Program, "Position");
@ -560,7 +560,7 @@ namespace MeshShader
void DetailledObjectPass2Shader::init() void DetailledObjectPass2Shader::init()
{ {
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass2.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_position = glGetAttribLocation(Program, "Position");
@ -603,7 +603,7 @@ namespace MeshShader
void ObjectUnlitShader::init() void ObjectUnlitShader::init()
{ {
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass2.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_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
@ -720,7 +720,7 @@ namespace MeshShader
{ {
initGL(); initGL();
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass2.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_position = glGetAttribLocation(Program, "Position");
@ -811,7 +811,7 @@ namespace MeshShader
void SphereMapShader::init() void SphereMapShader::init()
{ {
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass1.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").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_position = glGetAttribLocation(Program, "Position");
attrib_normal = glGetAttribLocation(Program, "Normal"); attrib_normal = glGetAttribLocation(Program, "Normal");
@ -909,7 +909,7 @@ namespace MeshShader
void CausticsShader::init() void CausticsShader::init()
{ {
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass2.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/caustics.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/caustics.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position"); attrib_position = glGetAttribLocation(Program, "Position");
@ -1094,7 +1094,7 @@ namespace MeshShader
void ColorizeShader::init() void ColorizeShader::init()
{ {
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass2.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/colorize.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/colorize.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position"); attrib_position = glGetAttribLocation(Program, "Position");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
@ -1275,7 +1275,7 @@ namespace MeshShader
void SkyboxShader::init() void SkyboxShader::init()
{ {
Program = LoadProgram( Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass2.vert").c_str(), GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sky.frag").c_str()); GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sky.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position"); attrib_position = glGetAttribLocation(Program, "Position");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");