Sfoglia il codice sorgente

- Moves Font, Form and Sprite shaders to file in the gameplay/res/shaders directory
- Cleaned up shaders and removed shader/lib folder.

setaylor 13 anni fa
parent
commit
9147a88ecf

+ 9 - 9
gameplay/res/shaders/colored-unlit.frag

@@ -2,14 +2,6 @@
 precision highp float;
 #endif
 
-// Inputs
-#if defined(VERTEX_COLOR)
-varying vec3 v_color;						// Input Vertex color ( r g b )
-#endif
-#if defined(TEXTURE_LIGHTMAP)
-varying vec2 v_texCoord;
-#endif
-
 // Uniforms
 uniform vec4 u_diffuseColor;               	// Diffuse color
 #if defined(TEXTURE_LIGHTMAP)
@@ -22,7 +14,15 @@ uniform vec4 u_modulateColor;               // Modulation color
 uniform float u_modulateAlpha;              // Modulation alpha
 #endif
 
-// Fragment program
+// Varyings
+#if defined(VERTEX_COLOR)
+varying vec3 v_color;						// Input Vertex color ( r g b )
+#endif
+#if defined(TEXTURE_LIGHTMAP)
+varying vec2 v_texCoord;
+#endif
+
+
 void main()
 {
     // Set base diffuse color

+ 12 - 12
gameplay/res/shaders/colored-unlit.vert

@@ -1,4 +1,4 @@
-// Inputs
+// Attributes
 attribute vec4 a_position;									// Vertex Position							(x, y, z, w)
 #if defined(TEXTURE_LIGHTMAP)
 attribute vec2 a_texCoord;                                  // Texture Coordinate (for lightmapping)
@@ -11,7 +11,13 @@ attribute vec4 a_blendIndices;								// Vertex blend index int u_matrixPalette
 attribute vec3 a_color;										// Vertex Color								(r, g, b)
 #endif
 
-// Outputs
+// 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
+
+// Varyings
 #if defined(TEXTURE_LIGHTMAP)
 varying vec2 v_texCoord;                                    // Output Texture Coordinate
 #endif
@@ -19,20 +25,14 @@ varying vec2 v_texCoord;                                    // Output Texture Co
 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
+// 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 vertex position

+ 24 - 21
gameplay/res/shaders/colored.frag

@@ -3,6 +3,25 @@
 precision highp float;
 #endif
 
+// Uniforms
+uniform vec4 u_diffuseColor;               		// Diffuse color
+uniform vec3 u_ambientColor;                    // Ambient color
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_lightDirection;					// Light direction
+#if defined(SPECULAR)
+uniform float u_specularExponent;				// Specular exponent
+#endif
+#if 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]
+#endif
+#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)
@@ -22,32 +41,16 @@ varying vec3 v_lightDirection;					// Direction of light in tangent space
 varying vec3 v_cameraDirection;                 // Camera direction
 #endif
 
-// Uniforms
-uniform vec4 u_diffuseColor;               		// Diffuse color
-uniform vec3 u_ambientColor;                    // Ambient color
-uniform vec3 u_lightColor;                      // Light color
-uniform vec3 u_lightDirection;					// Light direction
-#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"
+// Lighting
+#include "lighting.frag"
 #if defined(POINT_LIGHT)
-#include "lib/lighting-point.frag"
+#include "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"
+#include "lighting-spot.frag"
 #else
-#include "lib/lighting-directional.frag"
+#include "lighting-directional.frag"
 #endif
 
-// Fragment program
 void main()
 {
     // Set base diffuse color

+ 10 - 9
gameplay/res/shaders/colored.vert

@@ -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)
 #if defined(SKINNING)
@@ -31,33 +31,34 @@ uniform float u_spotLightRangeInverse;						// Inverse of light range.
 #else
 #endif
 
-// Outputs
+// Varyings
 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"
+#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"
+#include "lighting-spot.vert"
 #else
 uniform vec3 u_lightDirection;								// Direction of light
-#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

+ 17 - 0
gameplay/res/shaders/font.frag

@@ -0,0 +1,17 @@
+#ifdef OPENGL_ES
+precision highp float;
+#endif
+
+// Uniforms
+uniform sampler2D u_texture;
+
+// Varyings
+varying vec2 v_texCoord;
+varying vec4 v_color;
+
+
+void main()
+{
+    gl_FragColor = v_color;
+    gl_FragColor.a = texture2D(u_texture, v_texCoord).a * v_color.a;
+}

+ 19 - 0
gameplay/res/shaders/font.vert

@@ -0,0 +1,19 @@
+// Atttributes
+attribute vec3 a_position;
+attribute vec2 a_texCoord;
+attribute vec4 a_color;
+
+// Uniforms
+uniform mat4 u_projectionMatrix;
+
+// Varyings
+varying vec2 v_texCoord;
+varying vec4 v_color;
+
+
+void main()
+{
+    gl_Position = u_projectionMatrix * vec4(a_position, 1);
+    v_texCoord = a_texCoord;
+    v_color = a_color;
+}

+ 15 - 0
gameplay/res/shaders/form.frag

@@ -0,0 +1,15 @@
+#ifdef OPENGL_ES
+precision highp float;
+#endif
+
+// Uniforms
+uniform sampler2D u_texture;
+
+// Varyings
+varying vec2 v_texCoord;
+
+
+void main()
+{
+    gl_FragColor = texture2D(u_texture, v_texCoord);
+}

+ 16 - 0
gameplay/res/shaders/form.vert

@@ -0,0 +1,16 @@
+// Attributes
+attribute vec3 a_position;
+attribute vec2 a_texCoord;
+
+// Uniforms
+uniform mat4 u_worldViewProjectionMatrix;
+
+// Varyings
+varying vec2 v_texCoord;
+
+
+void main()
+{
+    gl_Position = u_worldViewProjectionMatrix * vec4(a_position, 1);
+    v_texCoord = a_texCoord;
+}

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


+ 0 - 1
gameplay/res/shaders/lib/lighting-directional.vert → gameplay/res/shaders/lighting-directional.vert

@@ -12,7 +12,6 @@ void applyLight(mat3 tangentSpaceTransformMatrix)
     v_cameraDirection = u_cameraPosition - positionWorldViewSpace.xyz;
 
     #endif
-
 }
 
 #else

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


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


+ 0 - 0
gameplay/res/shaders/lib/lighting-spot.frag → gameplay/res/shaders/lighting-spot.frag


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


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


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


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


+ 16 - 0
gameplay/res/shaders/sprite.frag

@@ -0,0 +1,16 @@
+#ifdef OPENGL_ES
+precision highp float;
+#endif
+
+// Uniforms
+uniform sampler2D u_texture;
+
+// Varyings
+varying vec2 v_texCoord;
+varying vec4 v_color;
+
+
+void main()
+{
+    gl_FragColor = v_color * texture2D(u_texture, v_texCoord);
+}

+ 19 - 0
gameplay/res/shaders/sprite.vert

@@ -0,0 +1,19 @@
+// Attributes
+attribute vec3 a_position;
+attribute vec2 a_texCoord;
+attribute vec4 a_color;
+
+// Uniforms
+uniform mat4 u_projectionMatrix;
+
+// Varyings
+varying vec2 v_texCoord;
+varying vec4 v_color;
+
+
+void main()
+{
+    gl_Position = u_projectionMatrix * vec4(a_position, 1);
+    v_texCoord = a_texCoord;
+    v_color = a_color;
+}

+ 16 - 17
gameplay/res/shaders/terrain.frag

@@ -2,34 +2,32 @@
 precision highp float;
 #endif
 
-// Inputs
-#if defined(NORMAL_MAP)
-vec3 v_normalVector;                            // Normal vector variable (from normal map)
-#else
-varying vec3 v_normalVector;					// Normal vector from vertex shader
-#endif
-varying vec2 v_texCoord0;
-
 // Uniforms
 uniform vec3 u_ambientColor;                    // Ambient color
 uniform vec3 u_lightColor;                      // Light color
 uniform vec3 u_lightDirection;					// Light direction
-
 #if defined(DEBUG_PATCHES)
-uniform float u_row;
-uniform float u_column;
+uniform float u_row;                            // Patch row
+uniform float u_column;                         // Patch column
 #endif
-
 #if (LAYER_COUNT > 0)
-uniform sampler2D u_samplers[SAMPLER_COUNT];
+uniform sampler2D u_samplers[SAMPLER_COUNT];    // Surface layer samplers
 #endif
-
 #if defined (NORMAL_MAP)
-uniform sampler2D u_normalMap;
+uniform sampler2D u_normalMap;                  // Normal map
 #endif
 
-#include "lib/lighting.frag"
-#include "lib/lighting-directional.frag"
+// Varyings
+#if defined(NORMAL_MAP)
+vec3 v_normalVector;                            // Normal vector variable (from normal map)
+#else
+varying vec3 v_normalVector;					// Normal vector from vertex shader
+#endif
+varying vec2 v_texCoord0;
+
+// Lighting
+#include "lighting.frag"
+#include "lighting-directional.frag"
 
 #if (LAYER_COUNT > 1)
 void blendLayer(sampler2D textureMap, vec2 textureRepeat, float alphaBlend)
@@ -43,6 +41,7 @@ void blendLayer(sampler2D textureMap, vec2 textureRepeat, float alphaBlend)
 }
 #endif
 
+
 void main()
 {
 #if (LAYER_COUNT > 0)

+ 3 - 4
gameplay/res/shaders/terrain.vert

@@ -1,4 +1,4 @@
-// Inputs
+// Attributes
 attribute vec4 a_position;									// Vertex Position							(x, y, z, w)
 #ifndef NORMAL_MAP
 attribute vec3 a_normal;									// Vertex Normal							(x, y, z)
@@ -21,7 +21,7 @@ uniform mat4 u_normalMatrix;					            // Matrix used for normal vector tr
 #endif
 uniform vec3 u_lightDirection;								// Direction of light
 
-// Outputs
+// Varyings
 #ifndef NORMAL_MAP
 varying vec3 v_normalVector;								// Normal vector out
 #endif
@@ -36,6 +36,7 @@ varying vec2 v_texCoord2;
 varying vec2 v_texCoord3;
 #endif
 
+
 void main()
 {
     // Transform position to clip space.
@@ -45,9 +46,7 @@ void main()
     // Pass normal to fragment shader
     v_normalVector = (u_normalMatrix * vec4(a_normal.x, a_normal.y, a_normal.z, 0)).xyz;
 #endif
-
     v_texCoord0 = a_texCoord0;
-
 #if LAYER_COUNT > 1
     v_texCoord1 = a_texCoord1;
 #endif

+ 27 - 23
gameplay/res/shaders/textured-bumped.frag

@@ -5,7 +5,27 @@
 precision highp float;
 #endif
 
-// Inputs
+// Uniforms
+uniform sampler2D u_diffuseTexture;        		// Diffuse map texture
+uniform sampler2D u_normalmapTexture;       	// Normalmap texture
+uniform vec3 u_ambientColor;                    // Ambient color
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_lightDirection;					// Light direction
+#if defined(SPECULAR)
+uniform float u_specularExponent;				// Specular exponent.
+#endif
+#if 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]
+#endif
+#if defined(MODULATE_COLOR)
+uniform vec4 u_modulateColor;					// Modulation color
+#endif
+#if defined(MODULATE_ALPHA)
+uniform float u_modulateAlpha;					// Modulation alpha
+#endif
+
+// Varyings
 varying vec3 v_normalVector;					// Normal vector in view space
 varying vec2 v_texCoord;						// Texture Coordinate
 #if defined(POINT_LIGHT)
@@ -22,33 +42,17 @@ varying vec3 v_lightDirection;					// Direction of light in tangent space.
 varying vec3 v_cameraDirection;                 // Camera direction
 #endif
 
-// Uniforms
-uniform sampler2D u_diffuseTexture;        		// Diffuse map texture
-uniform sampler2D u_normalmapTexture;       	// Normalmap texture
-uniform vec3 u_ambientColor;                    // Ambient color
-uniform vec3 u_lightColor;                      // Light color
-uniform vec3 u_lightDirection;					// Light direction
-#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"
+// Lighting
+#include "lighting.frag"
 #if defined(POINT_LIGHT)
-#include "lib/lighting-point.frag"
+#include "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"
+#include "lighting-spot.frag"
 #else
-#include "lib/lighting-directional.frag"
+#include "lighting-directional.frag"
 #endif
 
-// Fragment program
+
 void main()
 {
     // Fetch diffuse color from texture.

+ 9 - 10
gameplay/res/shaders/textured-bumped.vert

@@ -15,12 +15,10 @@ 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
-
 #if defined(SPECULAR) || defined(SPOT_LIGHT) || defined(POINT_LIGHT)
 uniform mat4 u_worldViewMatrix;								// Matrix to tranform a position to view space
 uniform mat4 u_worldMatrix;								    // Matrix to tranform a position to world space
 #endif
-
 #if defined(SKINNING)
 uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices
 #endif
@@ -44,35 +42,36 @@ uniform vec3 u_spotLightDirection;							// Direction of light
 uniform vec3 u_lightDirection;								// Direction of light
 #endif
 
-// Outputs
+// Varyings
 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
+
 // 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"
+#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
 varying vec3 v_spotLightDirection;							// Direction of spot light in tangent space
-#include "lib/lighting-spot.vert"
+#include "lighting-spot.vert"
 #else
 varying vec3 v_lightDirection;								// Direction of light
-#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, normal, tangents and binormals.

+ 2 - 2
gameplay/res/shaders/textured-unlit.frag

@@ -14,13 +14,13 @@ uniform vec4 u_modulateColor;               // Modulation color
 uniform float u_modulateAlpha;              // Modulation alpha
 #endif
 
-// Inputs
+// Varyings
 varying vec2 v_texCoord0;                	// Texture coordinate(u, v)
 #if defined(TEXCOORD1)
 varying vec2 v_texCoord1;                   // Second tex coord for multi-texturing
 #endif
 
-// Fragment Program
+
 void main()
 {
     // Sample the texture for the color

+ 6 - 6
gameplay/res/shaders/textured-unlit.vert

@@ -1,4 +1,4 @@
-// Inputs
+// Attributes
 attribute vec4 a_position;									// Vertex Position							(x, y, z, w)
 attribute vec2 a_texCoord0;									// Vertex Texture Coordinate				(u, v)
 #if defined(TEXCOORD1)
@@ -21,20 +21,20 @@ uniform vec2 u_textureRepeat;								// Texture repeat for tiling
 uniform vec2 u_textureOffset;								// Texture offset
 #endif
 
-// Outputs
+// Varyings
 varying vec2 v_texCoord0;									// Texture Coordinate
 #if defined(TEXCOORD1)
 varying vec2 v_texCoord1;                                   // Second tex coord for multi-texturing
 #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 vertex position

+ 21 - 22
gameplay/res/shaders/textured.frag

@@ -4,7 +4,22 @@
 precision highp float;
 #endif
 
-// Inputs
+// Uniforms
+uniform sampler2D u_diffuseTexture;             // Diffuse map texture
+uniform vec3 u_ambientColor;                    // Ambient color
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_lightDirection;					// Light direction
+#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
+
+// Varyings
 varying vec3 v_normalVector;                    // Normal vector in view space
 varying vec2 v_texCoord;                        // Texture coordinate
 #if defined(POINT_LIGHT)
@@ -21,36 +36,20 @@ varying vec3 v_lightDirection;					// Direction of light in tangent space.
 varying vec3 v_cameraDirection;                 // Camera direction
 #endif
 
-// Uniforms
-uniform sampler2D u_diffuseTexture;             // Diffuse map texture
-uniform vec3 u_ambientColor;                    // Ambient color
-uniform vec3 u_lightColor;                      // Light color
-uniform vec3 u_lightDirection;					// Light direction
-
-#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"
+// Lighting 
+#include "lighting.frag"
 #if defined(POINT_LIGHT)
-#include "lib/lighting-point.frag"
+#include "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]
 uniform vec3 u_spotLightDirection;              // Direction of a spot light source
-#include "lib/lighting-spot.frag"
+#include "lighting-spot.frag"
 #else
-#include "lib/lighting-directional.frag"
+#include "lighting-directional.frag"
 #endif
 
-uniform vec3 u_cameraPosition;
 
-// Fragment Program
 void main()
 {
     // Sample the diffuse texture for base color

+ 12 - 14
gameplay/res/shaders/textured.vert

@@ -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();
 

+ 4 - 29
gameplay/src/Font.cpp

@@ -4,34 +4,9 @@
 #include "FileSystem.h"
 #include "Bundle.h"
 
-// Default font vertex shader
-#define FONT_VSH \
-    "uniform mat4 u_projectionMatrix;\n" \
-    "attribute vec3 a_position;\n" \
-    "attribute vec2 a_texCoord;\n" \
-    "attribute vec4 a_color;\n" \
-    "varying vec2 v_texCoord;\n" \
-    "varying vec4 v_color;\n" \
-    "void main()\n" \
-    "{\n" \
-        "gl_Position = u_projectionMatrix * vec4(a_position, 1);\n" \
-        "v_texCoord = a_texCoord;\n" \
-        "v_color = a_color;\n" \
-    "}\n"
-
-// Default font fragment shader
-#define FONT_FSH \
-    "#ifdef OPENGL_ES\n" \
-    "precision highp float;\n" \
-    "#endif\n" \
-    "varying vec2 v_texCoord;\n" \
-    "varying vec4 v_color;\n" \
-    "uniform sampler2D u_texture;\n" \
-    "void main()\n" \
-    "{\n" \
-        "gl_FragColor = v_color;\n" \
-        "gl_FragColor.a = texture2D(u_texture, v_texCoord).a * v_color.a;\n" \
-    "}"
+// Default font shaders
+#define FONT_VSH "res/shaders/font.vert"
+#define FONT_FSH "res/shaders/font.frag"
 
 namespace gameplay
 {
@@ -124,7 +99,7 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
     // Create the effect for the font's sprite batch.
     if (__fontEffect == NULL)
     {
-        __fontEffect = Effect::createFromSource(FONT_VSH, FONT_FSH);
+        __fontEffect = Effect::createFromFile(FONT_VSH, FONT_FSH);
         if (__fontEffect == NULL)
         {
             GP_ERROR("Failed to create effect for font.");

+ 4 - 22
gameplay/src/Form.cpp

@@ -10,27 +10,9 @@
 #include "CheckBox.h"
 #include "Scene.h"
 
-#define FORM_VSH \
-    "uniform mat4 u_worldViewProjectionMatrix;\n" \
-    "attribute vec3 a_position;\n" \
-    "attribute vec2 a_texCoord;\n" \
-    "varying vec2 v_texCoord;\n" \
-    "void main()\n" \
-    "{\n" \
-        "gl_Position = u_worldViewProjectionMatrix * vec4(a_position, 1);\n" \
-        "v_texCoord = a_texCoord;\n" \
-    "}\n"
-
-#define FORM_FSH \
-    "#ifdef OPENGL_ES\n" \
-    "precision highp float;\n" \
-    "#endif\n" \
-    "varying vec2 v_texCoord;\n" \
-    "uniform sampler2D u_texture;\n" \
-    "void main()\n" \
-    "{\n" \
-        "gl_FragColor = texture2D(u_texture, v_texCoord);\n" \
-    "}\n"
+// Default form shaders
+#define FORM_VSH "res/shaders/form.vert"
+#define FORM_FSH "res/shaders/form.frag"
 
 namespace gameplay
 {
@@ -332,7 +314,7 @@ static Effect* createEffect()
     Effect* effect = NULL;
     if (__formEffect == NULL)
     {
-        __formEffect = Effect::createFromSource(FORM_VSH, FORM_FSH);
+        __formEffect = Effect::createFromFile(FORM_VSH, FORM_FSH);
         if (__formEffect == NULL)
         {
             GP_ERROR("Unable to load form effect.");

+ 4 - 28
gameplay/src/SpriteBatch.cpp

@@ -14,33 +14,9 @@
     vtx.u = vu; vtx.v = vv; \
     vtx.r = vr; vtx.g = vg; vtx.b = vb; vtx.a = va
 
-// Default sprite vertex shader
-#define SPRITE_VSH \
-    "uniform mat4 u_projectionMatrix;\n" \
-    "attribute vec3 a_position;\n" \
-    "attribute vec2 a_texCoord;\n" \
-    "attribute vec4 a_color;\n" \
-    "varying vec2 v_texCoord;\n" \
-    "varying vec4 v_color;\n" \
-    "void main()\n" \
-    "{\n" \
-        "gl_Position = u_projectionMatrix * vec4(a_position, 1);\n" \
-        "v_texCoord = a_texCoord;\n" \
-        "v_color = a_color;\n" \
-    "}\n"
-
-// Default sprite fragment shader
-#define SPRITE_FSH \
-    "#ifdef OPENGL_ES\n" \
-    "precision highp float;\n" \
-    "#endif\n" \
-    "varying vec2 v_texCoord;\n" \
-    "varying vec4 v_color;\n" \
-    "uniform sampler2D u_texture;\n" \
-    "void main()\n" \
-    "{\n" \
-        "gl_FragColor = v_color * texture2D(u_texture, v_texCoord);\n" \
-    "}\n"
+// Default sprite shaders
+#define SPRITE_VSH "res/shaders/sprite.vert"
+#define SPRITE_FSH "res/shaders/sprite.frag"
 
 namespace gameplay
 {
@@ -88,7 +64,7 @@ SpriteBatch* SpriteBatch::create(Texture* texture,  Effect* effect, unsigned int
         // Create our static sprite effect.
         if (__spriteEffect == NULL)
         {
-            __spriteEffect = Effect::createFromSource(SPRITE_VSH, SPRITE_FSH);
+            __spriteEffect = Effect::createFromFile(SPRITE_VSH, SPRITE_FSH);
             if (__spriteEffect == NULL)
             {
                 GP_ERROR("Unable to load sprite effect.");

+ 5 - 1
gameplay/src/TerrainPatch.cpp

@@ -5,6 +5,10 @@
 #include "Scene.h"
 #include "Game.h"
 
+// Default terrain shaders
+#define TERRAIN_VSH "res/shaders/terrain.vert"
+#define TERRAIN_FSH "res/shaders/terrain.frag"
+
 namespace gameplay
 {
 
@@ -470,7 +474,7 @@ bool TerrainPatch::updateMaterial()
             }
         }
 
-        Material* material = Material::create("res/shaders/terrain.vert", "res/shaders/terrain.frag", defines.str().c_str());
+        Material* material = Material::create(TERRAIN_VSH, TERRAIN_FSH, defines.str().c_str());
         if (!material)
             return false;
         material->getStateBlock()->setCullFace(true);