|
|
@@ -1,6 +1,6 @@
|
|
|
#define LIGHTING
|
|
|
|
|
|
-// Inputs
|
|
|
+// Attributes
|
|
|
attribute vec4 a_position; // Vertex position (x, y, z, w)
|
|
|
attribute vec3 a_normal; // Vertex normal (x, y, z)
|
|
|
attribute vec2 a_texCoord; // Vertex texture coordinate (u, v)
|
|
|
@@ -12,13 +12,9 @@ attribute vec4 a_blendIndices; // Vertex blend index int u_matrixPalette
|
|
|
// Uniforms
|
|
|
uniform mat4 u_worldViewProjectionMatrix; // Matrix to transform a position to clip space
|
|
|
uniform mat4 u_inverseTransposeWorldViewMatrix; // Matrix to transform a normal to view space
|
|
|
-
|
|
|
-//uniform mat4 u_worldViewMatrix;
|
|
|
-
|
|
|
#if defined(SPECULAR) || defined(SPOT_LIGHT) || defined(POINT_LIGHT)
|
|
|
uniform mat4 u_worldViewMatrix; // Matrix to tranform a position to view space
|
|
|
#endif
|
|
|
-
|
|
|
#if defined(SKINNING)
|
|
|
uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3]; // Array of 4x3 matrices
|
|
|
#endif
|
|
|
@@ -41,7 +37,7 @@ uniform vec3 u_spotLightDirection; // Direction of a sp
|
|
|
#else
|
|
|
#endif
|
|
|
|
|
|
-// Outputs
|
|
|
+// Varyings
|
|
|
varying vec3 v_normalVector; // Normal vector in view space
|
|
|
varying vec2 v_texCoord; // Texture coordinate
|
|
|
#if defined(SPECULAR)
|
|
|
@@ -50,26 +46,28 @@ varying vec3 v_cameraDirection; // Direction the camera is looking at in
|
|
|
#if defined(POINT_LIGHT)
|
|
|
varying vec3 v_vertexToPointLightDirection; // Direction of point light w.r.t current vertex in tangent space
|
|
|
varying float v_pointLightAttenuation; // Attenuation of point light
|
|
|
-#include "lib/lighting-point.vert"
|
|
|
+#include "lighting-point.vert"
|
|
|
#elif defined(SPOT_LIGHT)
|
|
|
varying vec3 v_vertexToSpotLightDirection; // Direction of the spot light w.r.t current vertex in tangent space
|
|
|
varying float v_spotLightAttenuation; // Attenuation of spot light
|
|
|
-#include "lib/lighting-spot.vert"
|
|
|
+
|
|
|
+// Lighting
|
|
|
+#include "lighting-spot.vert"
|
|
|
#else
|
|
|
-#include "lib/lighting-directional.vert"
|
|
|
+#include "lighting-directional.vert"
|
|
|
#endif
|
|
|
|
|
|
-// Vertex attribute accessors
|
|
|
+// Skinning
|
|
|
#if defined(SKINNING)
|
|
|
-#include "lib/attributes-skinning.vert"
|
|
|
+#include "skinning.vert"
|
|
|
#else
|
|
|
-#include "lib/attributes.vert"
|
|
|
+#include "skinning-none.vert"
|
|
|
#endif
|
|
|
|
|
|
-// Vertex Program
|
|
|
+
|
|
|
void main()
|
|
|
{
|
|
|
- // Get the position and normal from attribute accessors
|
|
|
+ // Get the position and normal
|
|
|
vec4 position = getPosition();
|
|
|
vec3 normal = getNormal();
|
|
|
|