Browse Source

Merge pull request #499 from blackberry-gaming/next-setaylor

Next setaylor
Sean Paul Taylor 13 years ago
parent
commit
5494d4d329

+ 19 - 20
gameplay/gameplay.vcxproj

@@ -206,26 +206,25 @@
     <None Include="res\logo_powered_black.png" />
     <None Include="res\logo_powered_black.png" />
     <None Include="res\logo_powered_white.png" />
     <None Include="res\logo_powered_white.png" />
     <None Include="res\logo_white.png" />
     <None Include="res\logo_white.png" />
-    <None Include="res\shaders\bumped.fsh" />
-    <None Include="res\shaders\bumped.vsh" />
-    <None Include="res\shaders\colored-unlit.fsh" />
-    <None Include="res\shaders\colored-unlit.vsh" />
-    <None Include="res\shaders\colored.fsh" />
-    <None Include="res\shaders\colored.vsh" />
-    <None Include="res\shaders\lib\attributes-skinning.vsh" />
-    <None Include="res\shaders\lib\attributes.vsh" />
-    <None Include="res\shaders\lib\lighting-directional.fsh" />
-    <None Include="res\shaders\lib\lighting-directional.vsh" />
-    <None Include="res\shaders\lib\lighting-point.fsh" />
-    <None Include="res\shaders\lib\lighting-point.vsh" />
-    <None Include="res\shaders\lib\lighting-spot.fsh" />
-    <None Include="res\shaders\lib\lighting-spot.vsh" />
-    <None Include="res\shaders\lib\lighting.fsh" />
-    <None Include="res\shaders\lib\lighting.vsh" />
-    <None Include="res\shaders\textured-unlit.fsh" />
-    <None Include="res\shaders\textured-unlit.vsh" />
-    <None Include="res\shaders\textured.fsh" />
-    <None Include="res\shaders\textured.vsh" />
+    <None Include="res\shaders\bumped.frag" />
+    <None Include="res\shaders\bumped.vert" />
+    <None Include="res\shaders\colored-unlit.frag" />
+    <None Include="res\shaders\colored-unlit.vert" />
+    <None Include="res\shaders\colored.frag" />
+    <None Include="res\shaders\colored.vert" />
+    <None Include="res\shaders\lib\attributes-skinning.vert" />
+    <None Include="res\shaders\lib\attributes.vert" />
+    <None Include="res\shaders\lib\lighting-directional.frag" />
+    <None Include="res\shaders\lib\lighting-directional.vert" />
+    <None Include="res\shaders\lib\lighting-point.frag" />
+    <None Include="res\shaders\lib\lighting-point.vert" />
+    <None Include="res\shaders\lib\lighting-spot.frag" />
+    <None Include="res\shaders\lib\lighting-spot.vert" />
+    <None Include="res\shaders\lib\lighting.frag" />
+    <None Include="res\shaders\textured-unlit.frag" />
+    <None Include="res\shaders\textured-unlit.vert" />
+    <None Include="res\shaders\textured.frag" />
+    <None Include="res\shaders\textured.vert" />
     <None Include="src\BoundingBox.inl" />
     <None Include="src\BoundingBox.inl" />
     <None Include="src\BoundingSphere.inl" />
     <None Include="src\BoundingSphere.inl" />
     <None Include="src\Curve.inl" />
     <None Include="src\Curve.inl" />

+ 19 - 22
gameplay/gameplay.vcxproj.filters

@@ -613,64 +613,61 @@
     <None Include="src\Joystick.inl">
     <None Include="src\Joystick.inl">
       <Filter>src</Filter>
       <Filter>src</Filter>
     </None>
     </None>
-    <None Include="res\shaders\bumped.fsh">
+    <None Include="res\shaders\textured.vert">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\bumped.vsh">
+    <None Include="res\shaders\textured.frag">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\colored.fsh">
+    <None Include="res\shaders\textured-unlit.vert">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\colored.vsh">
+    <None Include="res\shaders\textured-unlit.frag">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\colored-unlit.fsh">
+    <None Include="res\shaders\colored.vert">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\colored-unlit.vsh">
+    <None Include="res\shaders\colored.frag">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\textured.fsh">
+    <None Include="res\shaders\colored-unlit.vert">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\textured.vsh">
+    <None Include="res\shaders\colored-unlit.frag">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\textured-unlit.fsh">
+    <None Include="res\shaders\bumped.vert">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\textured-unlit.vsh">
+    <None Include="res\shaders\bumped.frag">
       <Filter>res\shaders</Filter>
       <Filter>res\shaders</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\attributes.vsh">
+    <None Include="res\shaders\lib\lighting.frag">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\attributes-skinning.vsh">
+    <None Include="res\shaders\lib\lighting-spot.vert">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\lighting.fsh">
+    <None Include="res\shaders\lib\lighting-spot.frag">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\lighting.vsh">
+    <None Include="res\shaders\lib\lighting-point.vert">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\lighting-directional.fsh">
+    <None Include="res\shaders\lib\lighting-point.frag">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\lighting-directional.vsh">
+    <None Include="res\shaders\lib\lighting-directional.vert">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\lighting-point.fsh">
+    <None Include="res\shaders\lib\lighting-directional.frag">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\lighting-point.vsh">
+    <None Include="res\shaders\lib\attributes.vert">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
-    <None Include="res\shaders\lib\lighting-spot.fsh">
-      <Filter>res\shaders\lib</Filter>
-    </None>
-    <None Include="res\shaders\lib\lighting-spot.vsh">
+    <None Include="res\shaders\lib\attributes-skinning.vert">
       <Filter>res\shaders\lib</Filter>
       <Filter>res\shaders\lib</Filter>
     </None>
     </None>
   </ItemGroup>
   </ItemGroup>

+ 69 - 0
gameplay/res/shaders/bumped.frag

@@ -0,0 +1,69 @@
+#define LIGHTING
+#define BUMPED
+#ifdef OPENGL_ES
+precision highp float;
+#endif
+
+// Inputs
+varying vec3 v_normalVector;					// Normal vector in view space
+varying vec2 v_texCoord;						// Texture Coordinate
+#if defined(SPECULAR)
+varying vec3 v_cameraDirection;                 // Camera direction
+#endif
+#if defined(POINT_LIGHT)
+varying vec3 v_vertexToPointLightDirection;		// Light direction w.r.t current vertex in tangent space.
+varying float v_pointLightAttenuation;			// Attenuation of point light.
+#elif defined(SPOT_LIGHT)
+varying vec3 v_spotLightDirection;				// Direction of spot light in tangent space.
+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.
+#else
+varying vec3 v_lightDirection;					// Direction of light in tangent space.
+#endif
+#if defined(SPECULAR)
+varying vec3 v_cameraDirection;                 // Camera direction
+#endif
+
+// Uniforms
+uniform sampler2D u_textureDiffuse;        		// Diffuse map texture
+uniform sampler2D u_textureNormal;       		// Normal map texture
+uniform vec3 u_lightDirection;					// Light direction
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_ambientColor;                    // Ambient color
+#if defined(SPECULAR)
+uniform float u_specularExponent;				// Specular exponent.
+#endif
+#if defined(MODULATE_COLOR)
+uniform vec4 u_modulateColor;					// Modulation color
+#endif
+#if defined(MODULATE_ALPHA)
+uniform float u_modulateAlpha;					// Modulation alpha
+#endif
+#include "lib/lighting.frag"
+#if defined(POINT_LIGHT)
+#include "lib/lighting-point.frag"
+#elif defined(SPOT_LIGHT)
+uniform float u_spotLightInnerAngleCos;			// The bright spot [0.0 - 1.0]
+uniform float u_spotLightOuterAngleCos;			// The soft outer part [0.0 - 1.0]
+#include "lib/lighting-spot.frag"
+#else
+#include "lib/lighting-directional.frag"
+#endif
+
+void main()
+{
+    // Fetch diffuse color from texture.
+    _baseColor = texture2D(u_textureDiffuse, v_texCoord);
+
+    // Light the pixel
+    gl_FragColor.a = _baseColor.a;
+    gl_FragColor.rgb = getLitPixel();
+
+	// Global color modulation
+	#if defined(MODULATE_COLOR)
+	gl_FragColor *= u_modulateColor;
+	#endif
+	#if defined(MODULATE_ALPHA)
+    gl_FragColor.a *= u_modulateAlpha;
+    #endif
+}

+ 0 - 48
gameplay/res/shaders/bumped.fsh

@@ -1,48 +0,0 @@
-#define BUMPED
-
-#ifdef OPENGL_ES
-precision highp float;
-#endif
-
-// Uniforms
-uniform sampler2D u_textureDiffuse;        	// Diffuse texture.
-uniform sampler2D u_textureNormal;       	// Normal map texture.
-
-#if defined(MODULATE_COLOR)
-uniform vec4 u_modulateColor;               // Modulation color
-#endif
-#if defined(MODULATE_ALPHA)
-uniform float u_modulateAlpha;              // Modulation alpha
-#endif
-
-// Inputs
-varying vec3 v_normalVector;                // Normal vector in view space.
-varying vec2 v_texCoord;                    // Texture Coordinate.
-
-// Lighting
-#include "lib/lighting.fsh"
-#if defined(POINT_LIGHT)
-#include "lib/lighting-point.fsh"
-#elif defined(SPOT_LIGHT)
-#include "lib/lighting-spot.fsh"
-#else
-#include "lib/lighting-directional.fsh"
-#endif
-
-void main()
-{
-    // Fetch diffuse color from texture.
-    _baseColor = texture2D(u_textureDiffuse, v_texCoord);
-
-    // Light the pixel
-    gl_FragColor.a = _baseColor.a;
-    gl_FragColor.rgb = getLitPixel();
-
-	// Global color modulation
-	#if defined(MODULATE_COLOR)
-	gl_FragColor *= u_modulateColor;
-	#endif
-	#if defined(MODULATE_ALPHA)
-    gl_FragColor.a *= u_modulateAlpha;
-    #endif
-}

+ 94 - 0
gameplay/res/shaders/bumped.vert

@@ -0,0 +1,94 @@
+#define LIGHTING
+#define BUMPED
+
+// 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
+#if defined(SKINNING)
+uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices as an array of floats
+#endif
+#if defined(SPECULAR)
+uniform mat4 u_worldViewMatrix;								// Matrix to tranform a position to view space
+uniform vec3 u_cameraPosition;                 				// Position of the camera in view space
+#endi
+#if defined(TEXTURE_REPEAT)
+uniform vec2 u_textureRepeat;
+#endif
+#if defined(TEXTURE_OFFSET)
+uniform vec2 u_textureOffset;
+#endif
+#if defined(POINT_LIGHT)
+uniform vec3 u_pointLightPosition;							// Position
+uniform float u_pointLightRangeInverse;						// Inverse of light range
+#elif defined(SPOT_LIGHT)
+uniform vec3 u_spotLightPosition;							// Position
+uniform float u_spotLightRangeInverse;						// Inverse of light range
+uniform vec3 u_spotLightDirection;							// Direction
+#else
+uniform vec3 u_lightDirection;								// Direction
+#endif
+
+// Inputs
+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)
+attribute vec3 a_tangent;									// Vertex Tangent               (x, y, z)
+attribute vec3 a_binormal;									// Vertex Binormal/Bitangent    (x, y, z)
+
+// Outputs
+varying vec3 v_normalVector;								// Normal vector in view space
+varying vec2 v_texCoord;									// Output Texture Coordinate     (u,v)
+// Lighting
+#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"
+#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
+varying vec3 v_spotLightDirection;							// Direction of spot light in tangent space
+#include "lib/lighting-spot.vert"
+#else
+uniform vec3 u_lightDirection;								// Direction of light
+#include "lib/lighting-directional.vert"
+#endif
+
+// Vertex Attribute Accessors
+#if defined(SKINNING)
+#include "lib/attributes-skinning.vert"
+#else
+#include "lib/attributes.vert" 
+#endif
+
+void main()
+{
+    // Get the position, normal, tangents and binormals.
+    vec4 position = getPosition();
+    vec3 normal = getNormal();
+    vec3 tangent = getTangent();
+    vec3 binormal = getBinormal();
+    
+    // Transform position to clip space.
+    gl_Position = u_worldViewProjectionMatrix * position;
+
+    // Transform the normal, tangent and binormals to view space.
+    mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
+    vec3 normalVector = normalize(inverseTransposeWorldViewMatrix * normal);
+    
+    // Create a transform to convert a vector to tangent space.
+    vec3 tangentVector  = normalize(inverseTransposeWorldViewMatrix * tangent);
+    vec3 binormalVector = normalize(inverseTransposeWorldViewMatrix * binormal);
+    mat3 tangentSpaceTransformMatrix = mat3(tangentVector.x, binormalVector.x, normalVector.x, tangentVector.y, binormalVector.y, normalVector.y, tangentVector.z, binormalVector.z, normalVector.z);
+    
+    // Apply light.
+    applyLight(tangentSpaceTransformMatrix);
+    
+    // Texture transformation.
+    v_texCoord = a_texCoord;
+    #if defined(TEXTURE_REPEAT)
+    v_texCoord *= u_textureRepeat;
+    #endif
+    #if defined(TEXTURE_OFFSET)
+    v_texCoord += u_textureOffset;
+    #endif
+}

+ 0 - 72
gameplay/res/shaders/bumped.vsh

@@ -1,72 +0,0 @@
-#define BUMPED
-
-// 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
-#if defined(TEXTURE_REPEAT)
-uniform vec2 u_textureRepeat;
-#endif
-#if defined(TEXTURE_OFFSET)
-uniform vec2 u_textureOffset;
-#endif
-
-// Inputs
-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)
-attribute vec3 a_tangent;                           // Vertex Tangent               (x, y, z)
-attribute vec3 a_binormal;                          // Vertex Binormal/Bitangent    (x, y, z)
-
-// Outputs
-varying vec3 v_normalVector;                        // Normal vector in view space.
-varying vec2 v_texCoord;                            // Output Texture Coordinate     (u,v)
-
-// Lighting
-#include "lib/lighting.vsh"
-#if defined(POINT_LIGHT)
-#include "lib/lighting-point.vsh"
-#elif defined(SPOT_LIGHT)
-#include "lib/lighting-spot.vsh"
-#else
-#include "lib/lighting-directional.vsh"
-#endif
-
-// Attribute Accessors (getPosition(), getNormal(), etc.)
-#if defined(SKINNING)
-#include "lib/attributes-skinning.vsh"
-#else
-#include "lib/attributes.vsh" 
-#endif
-
-void main()
-{
-    // Get the position, normal, tangents and binormals.
-    vec4 position = getPosition();
-    vec3 normal = getNormal();
-    vec3 tangent = getTangent();
-    vec3 binormal = getBinormal();
-    
-    // Transform position to clip space.
-    gl_Position = u_worldViewProjectionMatrix * position;
-
-    // Transform the normal, tangent and binormals to view space.
-    mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
-    vec3 normalVector = normalize(inverseTransposeWorldViewMatrix * normal);
-    
-    // Create a transform to convert a vector to tangent space.
-    vec3 tangentVector  = normalize(inverseTransposeWorldViewMatrix * tangent);
-    vec3 binormalVector = normalize(inverseTransposeWorldViewMatrix * binormal);
-    mat3 tangentSpaceTransformMatrix = mat3(tangentVector.x, binormalVector.x, normalVector.x, tangentVector.y, binormalVector.y, normalVector.y, tangentVector.z, binormalVector.z, normalVector.z);
-    
-    // Apply light.
-    applyLight(tangentSpaceTransformMatrix);
-    
-    // Texture transformation.
-    v_texCoord = a_texCoord;
-    #if defined(TEXTURE_REPEAT)
-    v_texCoord *= u_textureRepeat;
-    #endif
-    #if defined(TEXTURE_OFFSET)
-    v_texCoord += u_textureOffset;
-    #endif
-}

+ 1 - 0
gameplay/res/shaders/colored-unlit.fsh → gameplay/res/shaders/colored-unlit.frag

@@ -17,6 +17,7 @@ uniform vec4 u_modulateColor;               // Modulation color
 uniform float u_modulateAlpha;              // Modulation alpha
 uniform float u_modulateAlpha;              // Modulation alpha
 #endif
 #endif
 
 
+// Fragment program
 void main()
 void main()
 {
 {
     // Set base diffuse color
     // Set base diffuse color

+ 39 - 0
gameplay/res/shaders/colored-unlit.vert

@@ -0,0 +1,39 @@
+// Inputs
+attribute vec4 a_position;									// Vertex Position							(x, y, z, w)
+#if defined(SKINNING)
+attribute vec4 a_blendWeights;								// Vertex blend weight, up to 4				(0, 1, 2, 3) 
+attribute vec4 a_blendIndices;								// Vertex blend index int u_matrixPalette	(0, 1, 2, 3)
+#endif
+#if defined(VERTEX_COLOR)
+attribute vec3 a_color;										// Vertex Color								(r, g, b)
+varying vec3 v_color;										// Output Vertex color						(r, g, b)
+#endif
+
+
+// Uniforms
+uniform mat4 u_worldViewProjectionMatrix;					// Matrix to transform a position to clip space.
+#if defined(SKINNING)
+uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices as an array of floats
+#endif
+
+// Attribute accessor
+#if defined(SKINNING)
+#include "lib/attributes-skinning.vert"
+#else
+#include "lib/attributes.vert" 
+#endif
+
+// Vertex Program
+void main()
+{
+    // Get the vertex position
+    vec4 position = getPosition();
+    
+    // Transform position to clip space.a
+    gl_Position = u_worldViewProjectionMatrix *  position;
+    
+     // Pass on vertex color to fragment shader
+    #if defined(VERTEX_COLOR)
+	v_color = a_color;
+    #endif
+}

+ 0 - 29
gameplay/res/shaders/colored-unlit.vsh

@@ -1,29 +0,0 @@
-// Uniforms
-uniform mat4 u_worldViewProjectionMatrix;           // Matrix to transform a position to clip space.
-
-// Inputs
-attribute vec4 a_position;                          // Vertex Position          (x, y, z, w)
-#if defined(VERTEX_COLOR)
-attribute vec3 a_color;                             // Vertex Color             (r, g, b)
-varying vec3 v_color;								// Output Vertex color      (r, g, b)
-#endif
-
-#if defined(SKINNING)
-#include "lib/attributes-skinning.vsh"
-#else
-#include "lib/attributes.vsh" 
-#endif
-
-void main()
-{
-    // Get the vertex position
-    vec4 position = getPosition();
-    
-    // Transform position to clip space.a
-    gl_Position = u_worldViewProjectionMatrix *  position;
-    
-     // Pass on vertex color to fragment shader
-    #if defined(VERTEX_COLOR)
-	v_color = a_color;
-    #endif
-}

+ 70 - 0
gameplay/res/shaders/colored.frag

@@ -0,0 +1,70 @@
+#define LIGHTING
+#ifdef OPENGL_ES
+precision highp float;
+#endif
+
+// Inputs
+varying vec3 v_normalVector;					// Normal vector in view space
+#if defined(VERTEX_COLOR)
+varying vec3 v_color;							// Vertex color
+#endif
+#if defined(POINT_LIGHT)
+varying vec3 v_vertexToPointLightDirection;		// Light direction w.r.t current vertex in tangent space
+varying float v_pointLightAttenuation;			// Attenuation of point light
+#elif defined(SPOT_LIGHT)
+varying vec3 v_spotLightDirection;				// Direction of spot light in tangent space.
+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
+#else
+varying vec3 v_lightDirection;					// Direction of light in tangent space
+#endif
+#if defined(SPECULAR)
+varying vec3 v_cameraDirection;                 // Camera direction
+#endif
+
+// Uniforms
+uniform vec4 u_baseColor;               		// Base color
+uniform vec3 u_lightDirection;					// Light direction
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_ambientColor;                    // Ambient color
+#if defined(SPECULAR)
+uniform float u_specularExponent;				// Specular exponent
+#endif
+#if defined(MODULATE_COLOR)
+uniform vec4 u_modulateColor;					// Modulation color
+#endif
+#if defined(MODULATE_ALPHA)
+uniform float u_modulateAlpha;					// Modulation alpha
+#endif
+#include "lib/lighting.frag"
+#if defined(POINT_LIGHT)
+#include "lib/lighting-point.frag"
+#elif defined(SPOT_LIGHT)
+uniform float u_spotLightInnerAngleCos;			// The bright spot [0.0 - 1.0]
+uniform float u_spotLightOuterAngleCos;			// The soft outer part [0.0 - 1.0]
+#include "lib/lighting-spot.frag"
+#else
+#include "lib/lighting-directional.frag"
+#endif
+
+// Fragment program
+void main()
+{
+    // Set base diffuse color
+    #if defined(VERTEX_COLOR)
+	_baseColor.rgb = v_color;
+	#else
+	_baseColor = u_baseColor;
+	#endif
+
+    // Light the pixel
+    gl_FragColor.a = _baseColor.a;
+    gl_FragColor.rgb = getLitPixel();
+    
+	#if defined(MODULATE_COLOR)
+    gl_FragColor.a *= u_modulateColor;
+    #endif
+	#if defined(MODULATE_ALPHA)
+    gl_FragColor.a *= u_modulateAlpha;
+    #endif
+}

+ 0 - 50
gameplay/res/shaders/colored.fsh

@@ -1,50 +0,0 @@
-#ifdef OPENGL_ES
-precision highp float;
-#endif
-
-// Uniforms
-uniform vec4 u_baseColor;               	// Modulation color
-
-#if defined(MODULATE_COLOR)
-uniform vec4 u_modulateColor;               // Modulation color
-#endif
-#if defined(MODULATE_ALPHA)
-uniform float u_modulateAlpha;              // Modulation alpha
-#endif
-
-// Inputs
-varying vec3 v_normalVector;                // Normal vector in view space
-#if defined(VERTEX_COLOR)
-varying vec3 v_color;						// Vertex color
-#endif
-
-// Lighting
-#include "lib/lighting.fsh"
-#if defined(POINT_LIGHT)
-#include "lib/lighting-point.fsh"
-#elif defined(SPOT_LIGHT)
-#include "lib/lighting-spot.fsh"
-#else
-#include "lib/lighting-directional.fsh"
-#endif
-
-void main()
-{
-    // Set base diffuse color
-    #if defined(VERTEX_COLOR)
-	_baseColor.rgb = v_color;
-	#else
-	_baseColor = u_baseColor;
-	#endif
-
-    // Light the pixel
-    gl_FragColor.a = _baseColor.a;
-    gl_FragColor.rgb = getLitPixel();
-    
-	#if defined(MODULATE_COLOR)
-    gl_FragColor.a *= u_modulateColor;
-    #endif
-	#if defined(MODULATE_ALPHA)
-    gl_FragColor.a *= u_modulateAlpha;
-    #endif
-}

+ 81 - 0
gameplay/res/shaders/colored.vert

@@ -0,0 +1,81 @@
+#define LIGHTING
+
+// Inputs
+attribute vec4 a_position;									// Vertex Position							(x, y, z, w)
+attribute vec3 a_normal;									// Vertex Normal							(x, y, z)
+#if defined(SKINNING)
+attribute vec4 a_blendWeights;								// Vertex blend weight, up to 4				(0, 1, 2, 3) 
+attribute vec4 a_blendIndices;								// Vertex blend index int u_matrixPalette	(0, 1, 2, 3)
+#endif
+#if defined(VERTEX_COLOR)
+attribute vec3 a_color;										// Output Vertex Color
+varying vec3 v_color;										// Output Vertex Color 
+#endif
+
+// 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.
+#if defined(SKINNING)
+uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices
+#endif
+#if defined(SPECULAR)
+uniform mat4 u_worldViewMatrix;								// Matrix to tranform a position to view space.
+uniform vec3 u_cameraPosition;                 				// Position of the camera in view space.
+#endif
+#if defined(POINT_LIGHT)
+uniform vec3 u_pointLightPosition;							// Position of light
+uniform float u_pointLightRangeInverse;						// Inverse of light range 
+#elif defined(SPOT_LIGHT)
+uniform vec3 u_spotLightPosition;							// Position of light
+uniform float u_spotLightRangeInverse;						// Inverse of light range.
+#else
+#endif
+
+// Outputs
+varying vec3 v_normalVector;								// Normal vector in view space.
+#if defined(SPECULAR)
+varying vec3 v_cameraDirection;								// Direction the camera is looking at in tangent space.
+#endif
+// Lighting
+#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"
+#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"
+#else
+uniform vec3 u_lightDirection;								// Direction of light
+#include "lib/lighting-directional.vert"
+#endif
+
+// Vertex attribute accessors
+#if defined(SKINNING)
+#include "lib/attributes-skinning.vert"
+#else
+#include "lib/attributes.vert" 
+#endif
+
+// Vertex program
+void main()
+{
+    // Get the position and normal
+    vec4 position = getPosition();
+    vec3 normal = getNormal();
+
+    // Transform position to clip space.
+    gl_Position = u_worldViewProjectionMatrix * position;
+
+    // Transform normal to view space.
+    mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
+    v_normalVector = inverseTransposeWorldViewMatrix * normal;
+
+    // Apply light.
+    applyLight(position);
+    
+    // Pass the vertex color to fragment shader
+    #if defined(VERTEX_COLOR)
+	v_color = a_color;
+    #endif
+}

+ 0 - 51
gameplay/res/shaders/colored.vsh

@@ -1,51 +0,0 @@
-// 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.
-
-// Inputs
-attribute vec4 a_position;                          // Vertex Position (x, y, z, w)
-attribute vec3 a_normal;                            // Vertex Normal (x, y, z)
-#if defined(VERTEX_COLOR)
-attribute vec3 a_color;                             // Vertex Color (r, g, b)
-varying vec3 v_color;								// Output Vertex color 
-#endif
-
-// Outputs
-varying vec3 v_normalVector;                        // Normal vector in view space.
-
-#include "lib/lighting.vsh"
-#if defined(POINT_LIGHT)
-#include "lib/lighting-point.vsh"
-#elif defined(SPOT_LIGHT)
-#include "lib/lighting-spot.vsh"
-#else
-#include "lib/lighting-directional.vsh"
-#endif
-
-#if defined(SKINNING)
-#include "lib/attributes-skinning.vsh"
-#else
-#include "lib/attributes.vsh" 
-#endif
-
-void main()
-{
-    // Get the position and normal
-    vec4 position = getPosition();
-    vec3 normal = getNormal();
-
-    // Transform position to clip space.
-    gl_Position = u_worldViewProjectionMatrix * position;
-
-    // Transform normal to view space.
-    mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
-    v_normalVector = inverseTransposeWorldViewMatrix * normal;
-
-    // Apply light.
-    applyLight(position);
-    
-    // Pass the vertex color to fragment shader
-    #if defined(VERTEX_COLOR)
-	v_color = a_color;
-    #endif
-}

+ 0 - 9
gameplay/res/shaders/lib/attributes-skinning.vsh → gameplay/res/shaders/lib/attributes-skinning.vert

@@ -1,10 +1,3 @@
-attribute vec4 a_blendWeights;
-attribute vec4 a_blendIndices;
-
-// 32 4x3 matrices as an array of floats
-uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];
-
-// Global 
 vec4 _skinnedPosition;
 vec4 _skinnedPosition;
 #if defined(LIGHTING)
 #if defined(LIGHTING)
 vec3 _skinnedNormal;
 vec3 _skinnedNormal;
@@ -17,7 +10,6 @@ void skinPosition(float blendWeight, int matrixIndex)
     tmp.y = dot(a_position, u_matrixPalette[matrixIndex + 1]);
     tmp.y = dot(a_position, u_matrixPalette[matrixIndex + 1]);
     tmp.z = dot(a_position, u_matrixPalette[matrixIndex + 2]);
     tmp.z = dot(a_position, u_matrixPalette[matrixIndex + 2]);
     tmp.w = a_position.w;
     tmp.w = a_position.w;
-
     _skinnedPosition += blendWeight * tmp;
     _skinnedPosition += blendWeight * tmp;
 }
 }
 
 
@@ -51,7 +43,6 @@ void skinTangentSpaceVector(vec3 vector, float blendWeight, int matrixIndex)
     tmp.x = dot(vector, u_matrixPalette[matrixIndex].xyz);
     tmp.x = dot(vector, u_matrixPalette[matrixIndex].xyz);
     tmp.y = dot(vector, u_matrixPalette[matrixIndex + 1].xyz);
     tmp.y = dot(vector, u_matrixPalette[matrixIndex + 1].xyz);
     tmp.z = dot(vector, u_matrixPalette[matrixIndex + 2].xyz);
     tmp.z = dot(vector, u_matrixPalette[matrixIndex + 2].xyz);
-	
     _skinnedNormal += blendWeight * tmp;
     _skinnedNormal += blendWeight * tmp;
 }
 }
 
 

+ 0 - 0
gameplay/res/shaders/lib/attributes.vsh → gameplay/res/shaders/lib/attributes.vert


+ 0 - 2
gameplay/res/shaders/lib/lighting-directional.fsh → gameplay/res/shaders/lib/lighting-directional.frag

@@ -1,5 +1,3 @@
-varying vec3 v_lightDirection;                 // Direction of light in tangent space.
-
 #if defined(BUMPED)
 #if defined(BUMPED)
 
 
 vec3 getLitPixel()
 vec3 getLitPixel()

+ 5 - 7
gameplay/res/shaders/lib/lighting-directional.vsh → gameplay/res/shaders/lib/lighting-directional.vert

@@ -1,16 +1,13 @@
 #if defined(BUMPED)
 #if defined(BUMPED)
 
 
-uniform vec3 u_lightDirection;                  // Direction of light
-varying vec3 v_lightDirection;                  // Direction of light in tangent space.
-
 void applyLight(mat3 tangentSpaceTransformMatrix)
 void applyLight(mat3 tangentSpaceTransformMatrix)
 {
 {
     // Transform light direction to tangent space
     // Transform light direction to tangent space
     v_lightDirection = tangentSpaceTransformMatrix * u_lightDirection;
     v_lightDirection = tangentSpaceTransformMatrix * u_lightDirection;
     
     
-    // Compute the camera direction for specular lighting
     #if defined(SPECULAR)
     #if defined(SPECULAR)
-    
+
+    // Compute the camera direction for specular lighting
     vec4 positionWorldSpace = u_worldViewMatrix * a_position;
     vec4 positionWorldSpace = u_worldViewMatrix * a_position;
     v_cameraDirection = u_cameraPosition - positionWorldSpace.xyz;
     v_cameraDirection = u_cameraPosition - positionWorldSpace.xyz;
     
     
@@ -21,9 +18,10 @@ void applyLight(mat3 tangentSpaceTransformMatrix)
 
 
 void applyLight(vec4 position)
 void applyLight(vec4 position)
 {
 {
-    // Compute the camera direction for specular lighting
-    #if defined(SPECULAR)
     
     
+    #if defined(SPECULAR)
+
+    // Compute the camera direction for specular lighting
     vec4 positionWorldSpace = u_worldViewMatrix * position;
     vec4 positionWorldSpace = u_worldViewMatrix * position;
     v_cameraDirection = u_cameraPosition - positionWorldSpace.xyz;
     v_cameraDirection = u_cameraPosition - positionWorldSpace.xyz;
 
 

+ 0 - 3
gameplay/res/shaders/lib/lighting-point.fsh → gameplay/res/shaders/lib/lighting-point.frag

@@ -1,6 +1,3 @@
-varying vec3 v_vertexToPointLightDirection;   // Light direction w.r.t current vertex in tangent space.
-varying float v_pointLightAttenuation;        // Attenuation of point light.
-
 #if defined(BUMPED)
 #if defined(BUMPED)
 
 
 vec3 getLitPixel()
 vec3 getLitPixel()

+ 0 - 5
gameplay/res/shaders/lib/lighting-point.vsh → gameplay/res/shaders/lib/lighting-point.vert

@@ -1,8 +1,3 @@
-uniform vec3 u_pointLightPosition;                  // Position
-uniform float u_pointLightRangeInverse;             // Inverse of light range 
-varying vec3 v_vertexToPointLightDirection;         // Direction of point light w.r.t current vertex in tangent space.
-varying float v_pointLightAttenuation;              // Attenuation of point light.
-
 #if defined(BUMPED)
 #if defined(BUMPED)
 
 
 void applyLight(mat3 tangentSpaceTransformMatrix)
 void applyLight(mat3 tangentSpaceTransformMatrix)

+ 2 - 13
gameplay/res/shaders/lib/lighting-spot.fsh → gameplay/res/shaders/lib/lighting-spot.frag

@@ -1,10 +1,3 @@
-uniform float u_spotLightInnerAngleCos;       // The bright spot [0.0 - 1.0]
-uniform float u_spotLightOuterAngleCos;       // The soft outer part [0.0 - 1.0]
-
-varying vec3 v_spotLightDirection;            // Direction of spot light in tangent space.
-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.
-
 float lerpstep( float lower, float upper, float s)
 float lerpstep( float lower, float upper, float s)
 {
 {
     return clamp( ( s - lower ) / ( upper - lower ), 0.0, 1.0 );
     return clamp( ( s - lower ) / ( upper - lower ), 0.0, 1.0 );
@@ -19,13 +12,10 @@ vec3 getLitPixel()
     vec3 spotLightDirection = normalize(v_spotLightDirection);
     vec3 spotLightDirection = normalize(v_spotLightDirection);
     vec3 vertexToSpotLightDirection = normalize(v_vertexToSpotLightDirection);
     vec3 vertexToSpotLightDirection = normalize(v_vertexToSpotLightDirection);
     
     
-    // "-lightDirection" because light direction points in opposite direction to
-    // to spot direction.
-    // Calculate spot light effect.
+    // "-lightDirection" because light direction points in opposite direction to to spot direction.
     float spotCurrentAngleCos = max(0.0, dot(spotLightDirection, -vertexToSpotLightDirection));
     float spotCurrentAngleCos = max(0.0, dot(spotLightDirection, -vertexToSpotLightDirection));
     
     
-    // Intensity of spot depends on the spot light attenuation and the 
-    // part of the cone vertexToSpotLightDirection points to (inner or outer).
+    // Intensity of spot depends on the spot light attenuation and the part of the cone vertexToSpotLightDirection points to (inner or outer).
     float spotLightAttenuation = clamp(v_spotLightAttenuation, 0.0, 1.0);
     float spotLightAttenuation = clamp(v_spotLightAttenuation, 0.0, 1.0);
     spotLightAttenuation *= lerpstep(u_spotLightOuterAngleCos, u_spotLightInnerAngleCos, spotCurrentAngleCos);
     spotLightAttenuation *= lerpstep(u_spotLightOuterAngleCos, u_spotLightInnerAngleCos, spotCurrentAngleCos);
 
 
@@ -51,7 +41,6 @@ vec3 getLitPixel()
     vec3 vertexToSpotLightDirection = normalize(v_vertexToSpotLightDirection);
     vec3 vertexToSpotLightDirection = normalize(v_vertexToSpotLightDirection);
 
 
     // "-lightDirection" is used because light direction points in opposite direction to to spot direction.
     // "-lightDirection" is used because light direction points in opposite direction to to spot direction.
-    // Calculate spot light effect.
     float spotCurrentAngleCos = max(0.0, dot(spotLightDirection, -vertexToSpotLightDirection));
     float spotCurrentAngleCos = max(0.0, dot(spotLightDirection, -vertexToSpotLightDirection));
     
     
     // Intensity of spot depends on the spot light attenuation and the 
     // Intensity of spot depends on the spot light attenuation and the 

+ 0 - 14
gameplay/res/shaders/lib/lighting-spot.vsh → gameplay/res/shaders/lib/lighting-spot.vert

@@ -1,13 +1,5 @@
 #if defined(BUMPED)
 #if defined(BUMPED)
 
 
-uniform vec3 u_spotLightPosition;                   // Position
-uniform float u_spotLightRangeInverse;              // Inverse of light range.
-uniform vec3 u_spotLightDirection;                  // Direction
-
-varying vec3 v_spotLightDirection;                  // Direction of spot light in tangent space.
-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.
-
 void applyLight(mat3 tangentSpaceTransformMatrix)
 void applyLight(mat3 tangentSpaceTransformMatrix)
 {
 {
     vec4 positionWorldViewSpace = u_worldViewMatrix * a_position;
     vec4 positionWorldViewSpace = u_worldViewMatrix * a_position;
@@ -37,12 +29,6 @@ void applyLight(mat3 tangentSpaceTransformMatrix)
 
 
 #else
 #else
 
 
-uniform vec3 u_spotLightPosition;                   // Position
-uniform float u_spotLightRangeInverse;              // Inverse of light range.
-
-varying vec3 v_vertexToSpotLightDirection;          // Light direction w.r.t current vertex.
-varying float v_spotLightAttenuation;               // Attenuation of spot light.
-
 void applyLight(vec4 position)
 void applyLight(vec4 position)
 {
 {
     // World space position.
     // World space position.

+ 4 - 12
gameplay/res/shaders/lib/lighting.fsh → gameplay/res/shaders/lib/lighting.frag

@@ -1,18 +1,10 @@
-uniform vec3 u_lightDirection;					// Light direction.
-uniform vec3 u_lightColor;                      // Light color.
-uniform vec3 u_ambientColor;                    // Ambient color.
-
-// Variables
-vec4 _baseColor;                                // Base color.
-vec3 _ambientColor;                             // Ambient Color.
-vec3 _diffuseColor;                             // Diffuse Color.
+vec4 _baseColor;
+vec3 _ambientColor;
+vec3 _diffuseColor;
 
 
 #if defined(SPECULAR)
 #if defined(SPECULAR)
 
 
-vec3 _specularColor;    						// Specular color.
-
-uniform float u_specularExponent;				// Specular exponent.
-varying vec3 v_cameraDirection;                 // Camera direction.
+vec3 _specularColor;
 
 
 vec3 computeLighting(vec3 normalVector, vec3 lightDirection, float attenuation, vec3 cameraDirection)
 vec3 computeLighting(vec3 normalVector, vec3 lightDirection, float attenuation, vec3 cameraDirection)
 {
 {

+ 0 - 9
gameplay/res/shaders/lib/lighting.vsh

@@ -1,9 +0,0 @@
-#define LIGHTING
-
-#if defined(SPECULAR)
-
-uniform mat4 u_worldViewMatrix;                 // Matrix to tranform a position to view space.
-uniform vec3 u_cameraPosition;                 	// Position of the camera in view space.
-varying vec3 v_cameraDirection;                 // Direction the camera is looking at in tangent space.
-
-#endif

+ 1 - 1
gameplay/res/shaders/textured-unlit.fsh → gameplay/res/shaders/textured-unlit.frag

@@ -7,7 +7,6 @@ uniform sampler2D u_textureDiffuse;     	// Diffuse texture
 #if defined(TEXTURE_LIGHT)
 #if defined(TEXTURE_LIGHT)
 uniform sampler2D u_textureLight;     		// Lightmap texture
 uniform sampler2D u_textureLight;     		// Lightmap texture
 #endif
 #endif
-
 #if defined(MODULATE_COLOR)
 #if defined(MODULATE_COLOR)
 uniform vec4 u_modulateColor;               // Modulation color
 uniform vec4 u_modulateColor;               // Modulation color
 #endif
 #endif
@@ -18,6 +17,7 @@ uniform float u_modulateAlpha;              // Modulation alpha
 // Inputs
 // Inputs
 varying vec2 v_texCoord;                	// Texture coordinate(u, v)
 varying vec2 v_texCoord;                	// Texture coordinate(u, v)
 
 
+// Fragment Program
 void main()
 void main()
 {
 {
     // Sample the texture for the color
     // Sample the texture for the color

+ 48 - 0
gameplay/res/shaders/textured-unlit.vert

@@ -0,0 +1,48 @@
+// Inputs
+attribute vec4 a_position;									// Vertex Position							(x, y, z, w)
+attribute vec2 a_texCoord;									// Vertex Texture Coordinate				(u, v)
+#if defined(SKINNING)
+attribute vec4 a_blendWeights;								// Vertex blend weight, up to 4				(0, 1, 2, 3) 
+attribute vec4 a_blendIndices;								// Vertex blend index int u_matrixPalette	(0, 1, 2, 3)
+#endif
+
+// Uniforms
+uniform mat4 u_worldViewProjectionMatrix;					// Matrix to transform a position to clip space
+#if defined(SKINNING)
+uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices
+#endif
+#if defined(TEXTURE_REPEAT)
+uniform vec2 u_textureRepeat;								// Texture repeat for tiling
+#endif
+#if defined(TEXTURE_OFFSET)
+uniform vec2 u_textureOffset;								// Texture offset
+#endif
+
+// Outputs
+varying vec2 v_texCoord;									// Texture Coordinate
+
+// Vertex attribute accessors
+#if defined(SKINNING)
+#include "lib/attributes-skinning.vert"
+#else
+#include "lib/attributes.vert" 
+#endif
+
+// Vertex Program
+void main()
+{
+    // Get the vertex position
+    vec4 position = getPosition();
+
+    // Transform position to clip space.
+    gl_Position = u_worldViewProjectionMatrix * position;
+
+    // Texture transformation.
+    v_texCoord = a_texCoord;
+    #if defined(TEXTURE_REPEAT)
+    v_texCoord *= u_textureRepeat;
+    #endif
+    #if defined(TEXTURE_OFFSET)
+    v_texCoord += u_textureOffset;
+    #endif
+}

+ 0 - 40
gameplay/res/shaders/textured-unlit.vsh

@@ -1,40 +0,0 @@
-// Uniforms
-uniform mat4 u_worldViewProjectionMatrix;       // Matrix to transform a position to clip space
-#if defined(TEXTURE_REPEAT)
-uniform vec2 u_textureRepeat;
-#endif
-#if defined(TEXTURE_OFFSET)
-uniform vec2 u_textureOffset;
-#endif
-
-// Inputs
-attribute vec4 a_position;                      // Vertex Position              (x, y, z, w)
-attribute vec2 a_texCoord;                      // Vertex Texture Coordinate    (u, v)
-
-// Outputs
-varying vec2 v_texCoord;                        // Output Texture Coordinate    (u, v)
-
-// Attribute Accessors (getPosition(), getNormal(), etc.)
-#if defined(SKINNING)
-#include "lib/attributes-skinning.vsh"
-#else
-#include "lib/attributes.vsh" 
-#endif
-
-void main()
-{
-    // Get the vertex position
-    vec4 position = getPosition();
-
-    // Transform position to clip space.
-    gl_Position = u_worldViewProjectionMatrix * position;
-
-    // Texture transformation.
-    v_texCoord = a_texCoord;
-    #if defined(TEXTURE_REPEAT)
-    v_texCoord *= u_textureRepeat;
-    #endif
-    #if defined(TEXTURE_OFFSET)
-    v_texCoord += u_textureOffset;
-    #endif
-}

+ 66 - 0
gameplay/res/shaders/textured.frag

@@ -0,0 +1,66 @@
+#define LIGHTING
+
+#ifdef OPENGL_ES
+precision highp float;
+#endif
+
+// Inputs
+varying vec3 v_normalVector;                    // Normal vector in view space
+varying vec2 v_texCoord;                        // Texture coordinate
+#if defined(POINT_LIGHT)
+varying vec3 v_vertexToPointLightDirection;		// Light direction w.r.t current vertex in tangent space.
+varying float v_pointLightAttenuation;			// Attenuation of point light.
+#elif defined(SPOT_LIGHT)
+varying vec3 v_spotLightDirection;				// Direction of spot light in tangent space.
+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.
+#else
+varying vec3 v_lightDirection;					// Direction of light in tangent space.
+#endif
+#if defined(SPECULAR)
+varying vec3 v_cameraDirection;                 // Camera direction
+#endif
+
+// Uniforms
+uniform sampler2D u_textureDiffuse;             // Diffuse map texture
+uniform vec3 u_lightDirection;					// Light direction
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_ambientColor;                    // Ambient color
+#if defined(SPECULAR)
+uniform float u_specularExponent;				// Specular exponent
+#endif
+#if defined(MODULATE_COLOR)
+uniform vec4 u_modulateColor;               	// Modulation color
+#endif
+#if defined(MODULATE_ALPHA)
+uniform float u_modulateAlpha;              	// Modulation alpha
+#endif
+#include "/lib/lighting.frag"
+#if defined(POINT_LIGHT)
+#include "lib/lighting-point.frag"
+#elif defined(SPOT_LIGHT)
+uniform float u_spotLightInnerAngleCos;			// The bright spot [0.0 - 1.0]
+uniform float u_spotLightOuterAngleCos;			// The soft outer part [0.0 - 1.0]
+#include "lib/lighting-spot.frag"
+#else
+#include "lib/lighting-directional.frag"
+#endif
+
+// Fragment Program
+void main()
+{
+    // Sample the diffuse texture for base color
+    _baseColor = texture2D(u_textureDiffuse, v_texCoord);
+
+    // Light the pixel
+    gl_FragColor.a = _baseColor.a;
+    gl_FragColor.rgb = getLitPixel();
+	
+	// Global color modulation
+	#if defined(MODULATE_COLOR)
+	gl_FragColor *= u_modulateColor;
+	#endif
+	#if defined(MODULATE_ALPHA)
+    gl_FragColor.a *= u_modulateAlpha;
+    #endif
+}

+ 0 - 45
gameplay/res/shaders/textured.fsh

@@ -1,45 +0,0 @@
-#ifdef OPENGL_ES
-precision highp float;
-#endif
-
-// Uniforms
-uniform sampler2D u_textureDiffuse;             // Diffuse texture.
-
-#if defined(MODULATE_COLOR)
-uniform vec4 u_modulateColor;               	// Modulation color
-#endif
-#if defined(MODULATE_ALPHA)
-uniform float u_modulateAlpha;              	// Modulation alpha
-#endif
-
-// Inputs
-varying vec3 v_normalVector;                    // NormalVector in view space.
-varying vec2 v_texCoord;                        // Texture coordinate (u, v).
-
-// Lighting
-#include "lib/lighting.fsh"                     // Functions for lighting
-#if defined(POINT_LIGHT)
-#include "lib/lighting-point.fsh"
-#elif defined(SPOT_LIGHT)
-#include "lib/lighting-spot.fsh"
-#else
-#include "lib/lighting-directional.fsh"
-#endif
-
-void main()
-{
-    // Sample the texture for base color
-    _baseColor = texture2D(u_textureDiffuse, v_texCoord);
-
-    // Light the pixel
-    gl_FragColor.a = _baseColor.a;
-    gl_FragColor.rgb = getLitPixel();
-	
-	// Global color modulation
-	#if defined(MODULATE_COLOR)
-	gl_FragColor *= u_modulateColor;
-	#endif
-	#if defined(MODULATE_ALPHA)
-    gl_FragColor.a *= u_modulateAlpha;
-    #endif
-}

+ 87 - 0
gameplay/res/shaders/textured.vert

@@ -0,0 +1,87 @@
+#define LIGHTING
+
+// Inputs
+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)
+#if defined(SKINNING)
+attribute vec4 a_blendWeights;								// Vertex blend weight, up to 4				(0, 1, 2, 3) 
+attribute vec4 a_blendIndices;								// Vertex blend index int u_matrixPalette	(0, 1, 2, 3)
+#endif
+
+// 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
+#if defined(SKINNING)
+uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices
+#endif
+#if defined(SPECULAR)
+uniform mat4 u_worldViewMatrix;								// Matrix to tranform a position to view space
+uniform vec3 u_cameraPosition;                 				// Position of the camera in view space
+#endif
+#if defined(TEXTURE_REPEAT)
+uniform vec2 u_textureRepeat;								// Texture repeat for tiling
+#endif
+#if defined(TEXTURE_OFFSET)
+uniform vec2 u_textureOffset;								// Texture offset
+#endif
+#if defined(POINT_LIGHT)
+uniform vec3 u_pointLightPosition;							// Position of light
+uniform float u_pointLightRangeInverse;						// Inverse of light range 
+#elif defined(SPOT_LIGHT)
+uniform vec3 u_spotLightPosition;							// Position of light
+uniform float u_spotLightRangeInverse;						// Inverse of light range
+#else
+#endif
+
+// Outputs
+varying vec3 v_normalVector;								// Normal vector in view space
+varying vec2 v_texCoord;									// Texture coordinate
+#if defined(SPECULAR)
+varying vec3 v_cameraDirection;								// Direction the camera is looking at in tangent space
+#endif
+#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"
+#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"
+#else
+#include "lib/lighting-directional.vert"
+#endif
+
+// Vertex attribute accessors
+#if defined(SKINNING)
+#include "lib/attributes-skinning.vert"
+#else
+#include "lib/attributes.vert" 
+#endif
+
+// Vertex Program
+void main()
+{
+    // Get the position and normal from attribute accessors
+    vec4 position = getPosition();
+    vec3 normal = getNormal();
+
+    // Transform position to clip space.
+    gl_Position = u_worldViewProjectionMatrix * position;
+
+    // Transform normal to view space.
+    mat3 normalMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
+    v_normalVector = normalMatrix * normal;
+
+    // Apply light.
+    applyLight(position);
+    
+    // Texture transformation
+    v_texCoord = a_texCoord;
+    #if defined(TEXTURE_REPEAT)
+    v_texCoord *= u_textureRepeat;
+    #endif
+    #if defined(TEXTURE_OFFSET)
+    v_texCoord += u_textureOffset;
+    #endif
+}

+ 0 - 61
gameplay/res/shaders/textured.vsh

@@ -1,61 +0,0 @@
-// 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
-#if defined(TEXTURE_REPEAT)
-uniform vec2 u_textureRepeat;
-#endif
-#if defined(TEXTURE_OFFSET)
-uniform vec2 u_textureOffset;
-#endif
-
-// Inputs
-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)
-
-// Outputs
-varying vec3 v_normalVector;                        // Output normal vector in view space   (x, y, z)
-varying vec2 v_texCoord;                            // Output texture coordinate            (u, v)
-
-// Lighting
-#include "lib/lighting.vsh"
-#if defined(POINT_LIGHT)
-#include "lib/lighting-point.vsh"
-#elif defined(SPOT_LIGHT)
-#include "lib/lighting-spot.vsh"
-#else
-#include "lib/lighting-directional.vsh"
-#endif
-
-// Attribute Accessors (getPosition(), getNormal(), etc.)
-#if defined(SKINNING)
-#include "lib/attributes-skinning.vsh"
-#else
-#include "lib/attributes.vsh" 
-#endif
-
-void main()
-{
-    // Get the position and normal
-    vec4 position = getPosition();
-    vec3 normal = getNormal();
-
-    // Transform position to clip space.
-    gl_Position = u_worldViewProjectionMatrix * position;
-
-    // Transform normal to view space.
-    mat3 normalMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
-    v_normalVector = normalMatrix * normal;
-
-    // Apply light.
-    applyLight(position);
-    
-    // Texture transformation
-    v_texCoord = a_texCoord;
-    #if defined(TEXTURE_REPEAT)
-    v_texCoord *= u_textureRepeat;
-    #endif
-    #if defined(TEXTURE_OFFSET)
-    v_texCoord += u_textureOffset;
-    #endif
-}

+ 1 - 1
gameplay/src/Effect.cpp

@@ -180,13 +180,13 @@ void replaceIncludes(const char* filepath, const char* source, std::string& out)
             if (includedSource == NULL)
             if (includedSource == NULL)
             {
             {
                 GP_ERROR("Compile failed for shader '%s' invalid filepath.", filepathStr.c_str());
                 GP_ERROR("Compile failed for shader '%s' invalid filepath.", filepathStr.c_str());
-                SAFE_DELETE_ARRAY(includedSource);
                 return;
                 return;
             }
             }
             else
             else
             {
             {
                 // Valid file so lets attempt to see if we need to append anything to it too (recurse...)
                 // Valid file so lets attempt to see if we need to append anything to it too (recurse...)
                 replaceIncludes(directoryPath.c_str(), includedSource, out);
                 replaceIncludes(directoryPath.c_str(), includedSource, out);
+                SAFE_DELETE_ARRAY(includedSource);
             }
             }
         }
         }
         else
         else