Tidy up
[opengl.git] / texturevertex.glsl
index d8c97f4df3c9a73169770d7dcca7a512782a70fe..684b9b94ed98c2117496381ea1071fc53236a39f 100644 (file)
@@ -5,9 +5,11 @@ in vec3 vNormal;
 in vec3 tangent;
 in vec3 bitangent;
 in vec2 vTexCoord;
+
 uniform mat4 model;
 uniform mat4 view;
 uniform mat4 projection;
+
 out vec3 defNormal;
 out vec2 texCoord;
 
@@ -18,44 +20,21 @@ out vec3 lightPos;
 out vec3 viewPos;
 out vec3 fragPos;
 
-struct Material {
-       vec3 ambient;
-       vec3 diffuse;
-       sampler2D diffuseMap;
-       vec3 specular;
-       sampler2D specularMap;
-       float shininess;
-       
-       bool hasTexture;
-       bool hasSpecularMap;
-
-       sampler2D normalMap;
-       bool hasNormalMap;
-};
-
-uniform Material material;
-
-
 void main() {
        vec4 pos = model * vec4(vPosition, 1.f);
-       defNormal = mat3(transpose(inverse(model))) * vNormal;
        texCoord = vTexCoord;
 
        //tangent space stuff
-       if (material.hasNormalMap) {
        vec3 T = normalize(vec3(model * vec4(tangent,   0.0)));
        vec3 B = normalize(vec3(model * vec4(bitangent, 0.0)));
        vec3 N = normalize(vec3(model * vec4(vNormal,    0.0)));
        // convert TBN to world->tangent space
        mat3 TBN = transpose(mat3(T, B, N));
+
        lightPos = TBN * vLightPos;
        viewPos = TBN * vViewPos;
        fragPos = TBN * vec3(pos);
-       } else {
-               lightPos = vLightPos;
-               viewPos = vViewPos;
-               fragPos = vec3(pos);
-       }
+       defNormal = TBN * mat3(transpose(inverse(model))) * vNormal;
        
        gl_Position = projection * view * pos;
 }