Merge instanced_object_pass vertex shaders.

This commit is contained in:
Vincent Lejeune 2014-03-23 19:28:07 +01:00
parent 5dd2d28134
commit 5c8ef365a5
3 changed files with 6 additions and 25 deletions

View File

@ -6,7 +6,10 @@ in vec3 Orientation;
in vec3 Position;
in vec3 Normal;
in vec2 Texcoord;
out vec3 nor;
out vec2 uv;
void main(void)
{
@ -15,4 +18,5 @@ void main(void)
mat4 TransposeInverseModelView = transpose(inverse(ViewMatrix * ModelMatrix));
gl_Position = ViewProjectionMatrix * ModelMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
uv = Texcoord;
}

View File

@ -1,23 +0,0 @@
uniform mat4 ViewProjectionMatrix;
uniform mat4 TextureMatrix =
mat4(1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.);
in vec3 Origin;
in vec3 Position;
in vec2 Texcoord;
out vec2 uv;
void main(void)
{
mat4 ModelMatrix = mat4(1.);
ModelMatrix[3].xyz += Origin;
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
gl_Position = ViewProjectionMatrix * ModelMatrix * vec4(Position, 1.);
}

View File

@ -512,7 +512,7 @@ namespace MeshShader
void InstancedObjectPass1Shader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass1.vert").c_str(),
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_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/object_pass1.frag").c_str());
attrib_origin = glGetAttribLocation(Program, "Origin");
@ -587,7 +587,7 @@ namespace MeshShader
void InstancedObjectPass2Shader::init()
{
Program = LoadProgram(
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass2.vert").c_str(),
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").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());
attrib_position = glGetAttribLocation(Program, "Position");