2
0
Эх сурвалжийг харах

More gutting, removed old shaders, added a single unlit ES2 shader, more outlines of new renderer

Ivan Safrin 10 жил өмнө
parent
commit
9045c4a9fd
48 өөрчлөгдсөн 550 нэмэгдсэн , 1581 устгасан
  1. BIN
      Assets/Default asset pack/default.pak
  2. 0 129
      Assets/Default asset pack/default/ColSpecEmit.frag
  3. 0 102
      Assets/Default asset pack/default/DefaultParticleShader.frag
  4. 0 121
      Assets/Default asset pack/default/DefaultShader.frag
  5. 0 13
      Assets/Default asset pack/default/DefaultShader.vert
  6. 0 121
      Assets/Default asset pack/default/DefaultShaderNoTexture.frag
  7. 0 147
      Assets/Default asset pack/default/DefaultShaderShadows.frag
  8. 0 22
      Assets/Default asset pack/default/DefaultShaderShadows.vert
  9. 0 26
      Assets/Default asset pack/default/DefaultShaderVertex.frag
  10. 0 111
      Assets/Default asset pack/default/DefaultShaderVertex.vert
  11. 0 25
      Assets/Default asset pack/default/DefaultShaderVertexNoTexture.frag
  12. 0 64
      Assets/Default asset pack/default/GPUSkinning.vert
  13. 0 46
      Assets/Default asset pack/default/LightCube.frag
  14. 0 28
      Assets/Default asset pack/default/LightCube.vert
  15. 0 158
      Assets/Default asset pack/default/NorColSpec.frag
  16. 0 18
      Assets/Default asset pack/default/NormalShader.vert
  17. 0 6
      Assets/Default asset pack/default/PassThrough.frag
  18. 0 8
      Assets/Default asset pack/default/ScreenShader.vert
  19. 0 28
      Assets/Default asset pack/default/SkyBox.frag
  20. 5 6
      Assets/Default asset pack/default/Unlit.frag
  21. 9 4
      Assets/Default asset pack/default/Unlit.vert
  22. 0 7
      Assets/Default asset pack/default/UnlitUntextured.frag
  23. 2 144
      Assets/Default asset pack/default/default.mat
  24. 0 2
      Core/Contents/CMakeLists.txt
  25. 1 1
      Core/Contents/Include/PolyCocoaCore.h
  26. 0 60
      Core/Contents/Include/PolyFixedShader.h
  27. 5 1
      Core/Contents/Include/PolyGPUDrawBuffer.h
  28. 1 4
      Core/Contents/Include/PolyMaterialManager.h
  29. 6 1
      Core/Contents/Include/PolyOpenGLGraphicsInterface.h
  30. 1 1
      Core/Contents/Include/PolyParticleEmitter.h
  31. 4 1
      Core/Contents/Include/PolyRenderDataArray.h
  32. 10 4
      Core/Contents/Include/PolyRenderer.h
  33. 2 0
      Core/Contents/Include/PolyResource.h
  34. 22 26
      Core/Contents/Include/PolyShader.h
  35. 1 8
      Core/Contents/Include/PolyTexture.h
  36. 0 1
      Core/Contents/Include/Polycode.h
  37. 0 56
      Core/Contents/Source/PolyFixedShader.cpp
  38. 55 35
      Core/Contents/Source/PolyMaterialManager.cpp
  39. 16 16
      Core/Contents/Source/PolyMesh.cpp
  40. 292 3
      Core/Contents/Source/PolyOpenGLGraphicsInterface.cpp
  41. 2 2
      Core/Contents/Source/PolyParticleEmitter.cpp
  42. 4 0
      Core/Contents/Source/PolyRenderDataArray.cpp
  43. 91 3
      Core/Contents/Source/PolyRenderer.cpp
  44. 1 0
      Core/Contents/Source/PolyResource.cpp
  45. 9 7
      Core/Contents/Source/PolyResourceManager.cpp
  46. 4 3
      Core/Contents/Source/PolySceneMesh.cpp
  47. 6 6
      Core/Contents/Source/PolyShader.cpp
  48. 1 6
      Core/Contents/Source/PolyTexture.cpp

BIN
Assets/Default asset pack/default.pak


+ 0 - 129
Assets/Default asset pack/default/ColSpecEmit.frag

@@ -1,129 +0,0 @@
-varying vec3 normal;
-varying vec4 pos;
-varying vec4 vertexColor;
-
-uniform sampler2D diffuse;
-uniform sampler2D specular_map;
-uniform sampler2D emit_map;
-
-uniform vec4 diffuse_color;
-uniform vec4 specular_color;
-uniform vec4 ambient_color;
-uniform float shininess;
-
-float calculateAttenuation(in int i, in float dist)
-{
-    return(1.0 / (gl_LightSource[i].constantAttenuation +
-                  gl_LightSource[i].linearAttenuation * dist +
-                  gl_LightSource[i].quadraticAttenuation * dist * dist));
-}
-
-void pointLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-	
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation;
-	  }
-	}
-}
-
-
-void spotLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float cos_outer_cone_angle = (1.0-gl_LightSource[i].spotExponent) * gl_LightSource[i].spotCosCutoff;
-	float cos_cur_angle = dot(-normalize(gl_LightSource[i].spotDirection), sn.xyz);
-	float cos_inner_cone_angle = gl_LightSource[i].spotCosCutoff;
-
-	float cos_inner_minus_outer_angle = cos_inner_cone_angle - cos_outer_cone_angle;
-	float spot = 0.0;
-	spot = clamp((cos_cur_angle - cos_outer_cone_angle) / cos_inner_minus_outer_angle, 0.0, 1.0);
-	       
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation * spot;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation * spot;
-	  }
-	}
-}
-
-void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	for (int i = 0; i < numLights; i++) {
-		if (gl_LightSource[i].spotCutoff == 180.0) {
-			pointLight(i, normal, pos, diffuse, specular);
-		} else {
-			spotLight(i, normal, pos, diffuse, specular);
-		}
-    }
-}
-
-
-void main()
-{
-	vec4 diffuse_val  = vec4(0.0);
-	vec4 specular_val = vec4(0.0);
-	doLights(6, normal, pos, diffuse_val, specular_val);
-	
-	specular_val.xyz *= texture2D(specular_map, gl_TexCoord[0].st).xyz * gl_FrontMaterial.specular.a;
-
-	vec4 emitVal = texture2D(emit_map, gl_TexCoord[0].st);
-	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);		
-		
-    vec4 color = diffuse_val + ambient_color; 	           
-    color = clamp((color*vertexColor*texColor) + specular_val, 0.0, 1.0);  
-
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-
-	color = mix(color, texColor, emitVal);
-
-	color = mix(gl_Fog.color, color, fogFactor );   
-	color.a = vertexColor.a * texColor.a * diffuse_color.a;	
-	gl_FragColor = color;
-
-}

+ 0 - 102
Assets/Default asset pack/default/DefaultParticleShader.frag

@@ -1,102 +0,0 @@
-varying vec3 normal;
-varying vec4 pos;
-varying vec4 vertexColor;
-uniform sampler2D diffuse;
-
-uniform vec4 diffuse_color;
-uniform vec4 ambient_color;
-
-
-float calculateAttenuation(in int i, in float dist)
-{
-    return(1.0 / (gl_LightSource[i].constantAttenuation +
-                  gl_LightSource[i].linearAttenuation * dist +
-                  gl_LightSource[i].quadraticAttenuation * dist * dist));
-}
-
-void pointLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse) {
-	vec4 color = diffuse_color;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-	
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float nDotL = 1.0;
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation;
-}
-
-
-void spotLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse) {
-	vec4 color = diffuse_color;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float cos_outer_cone_angle = (1.0-gl_LightSource[i].spotExponent) * gl_LightSource[i].spotCosCutoff;
-	float cos_cur_angle = dot(-normalize(gl_LightSource[i].spotDirection), sn.xyz);
-	float cos_inner_cone_angle = gl_LightSource[i].spotCosCutoff;
-
-	float cos_inner_minus_outer_angle = cos_inner_cone_angle - cos_outer_cone_angle;
-	float spot = 0.0;
-	spot = clamp((cos_cur_angle - cos_outer_cone_angle) / cos_inner_minus_outer_angle, 0.0, 1.0);
-	       
-	float nDotL = 1.0;
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation * spot;
-
-}
-
-void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse) {
-	for (int i = 0; i < numLights; i++) {
-		if (gl_LightSource[i].spotCutoff == 180.0) {
-			pointLight(i, normal, pos, diffuse);
-		} else {
-			spotLight(i, normal, pos, diffuse);
-		}
-    }
-}
-
-
-void main()
-{
-	vec4 diffuse_val  = vec4(0.0);
-	doLights(6, normal, pos, diffuse_val);
-		
-	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);		
-		
-    vec4 color = diffuse_val + ambient_color;	
-    color = clamp(color*vertexColor*texColor, 0.0, 1.0);	
-
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-
-	color = mix(gl_Fog.color, color, fogFactor );    
-	color.a = diffuse_color.a * texColor.a * vertexColor.a;  	
-	gl_FragColor = color;
-
-}

+ 0 - 121
Assets/Default asset pack/default/DefaultShader.frag

@@ -1,121 +0,0 @@
-varying vec3 normal;
-varying vec4 pos;
-varying vec4 vertexColor;
-
-uniform sampler2D diffuse;
-uniform vec4 diffuse_color;
-uniform vec4 specular_color;
-uniform vec4 ambient_color;
-uniform float shininess;
-
-float calculateAttenuation(in int i, in float dist)
-{
-    return(1.0 / (gl_LightSource[i].constantAttenuation +
-                  gl_LightSource[i].linearAttenuation * dist +
-                  gl_LightSource[i].quadraticAttenuation * dist * dist));
-}
-
-void pointLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-	
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation;
-	  }
-	}
-}
-
-
-void spotLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float cos_outer_cone_angle = (1.0-gl_LightSource[i].spotExponent) * gl_LightSource[i].spotCosCutoff;
-	float cos_cur_angle = dot(-normalize(gl_LightSource[i].spotDirection), sn.xyz);
-	float cos_inner_cone_angle = gl_LightSource[i].spotCosCutoff;
-
-	float cos_inner_minus_outer_angle = cos_inner_cone_angle - cos_outer_cone_angle;
-	float spot = 0.0;
-	spot = clamp((cos_cur_angle - cos_outer_cone_angle) / cos_inner_minus_outer_angle, 0.0, 1.0);
-	       
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation * spot;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation * spot;
-	  }
-	}
-}
-
-void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	for (int i = 0; i < numLights; i++) {
-		if (gl_LightSource[i].spotCutoff == 180.0) {
-			pointLight(i, normal, pos, diffuse, specular);
-		} else {
-			spotLight(i, normal, pos, diffuse, specular);
-		}
-    }
-}
-
-
-void main()
-{
-	vec4 diffuse_val  = vec4(0.0);
-	vec4 specular_val = vec4(0.0);
-	doLights(6, normal, pos, diffuse_val, specular_val);
-		
-	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);		
-		
-    vec4 color = diffuse_val + ambient_color; 	           
-    color = clamp((color*vertexColor*texColor) + specular_val, 0.0, 1.0);  
-
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-
-	color = mix(gl_Fog.color, color, fogFactor );   
-	color.a = vertexColor.a * texColor.a * diffuse_color.a;	
-	gl_FragColor = color;
-
-}

+ 0 - 13
Assets/Default asset pack/default/DefaultShader.vert

@@ -1,13 +0,0 @@
-varying vec3 normal;
-varying vec4 pos;
-varying vec4 rawpos;
-varying vec4 vertexColor;
-
-void main() {
-	normal = gl_NormalMatrix * gl_Normal;
-	gl_Position = ftransform();
-	pos = gl_ModelViewMatrix * gl_Vertex;
-	rawpos = gl_Vertex;
-    vertexColor = gl_Color;
-	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
-}

+ 0 - 121
Assets/Default asset pack/default/DefaultShaderNoTexture.frag

@@ -1,121 +0,0 @@
-varying vec3 normal;
-varying vec4 pos;
-varying vec4 vertexColor;
-
-uniform vec4 diffuse_color;
-uniform vec4 specular_color;
-uniform vec4 ambient_color;
-uniform float shininess;
-
-float calculateAttenuation(in int i, in float dist)
-{
-    return(1.0 / (gl_LightSource[i].constantAttenuation +
-                  gl_LightSource[i].linearAttenuation * dist +
-                  gl_LightSource[i].quadraticAttenuation * dist * dist));
-}
-
-void pointLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-	
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation;
-	  }
-	}
-}
-
-
-void spotLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float cos_outer_cone_angle = (1.0-gl_LightSource[i].spotExponent) * gl_LightSource[i].spotCosCutoff;
-	float cos_cur_angle = dot(-normalize(gl_LightSource[i].spotDirection), sn.xyz);
-	float cos_inner_cone_angle = gl_LightSource[i].spotCosCutoff;
-
-	float cos_inner_minus_outer_angle = cos_inner_cone_angle - cos_outer_cone_angle;
-	float spot = 0.0;
-	spot = clamp((cos_cur_angle - cos_outer_cone_angle) / cos_inner_minus_outer_angle, 0.0, 1.0);
-	       
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation * spot;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation * spot;
-	  }
-	}
-}
-
-void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	for (int i = 0; i < numLights; i++) {
-		if (gl_LightSource[i].spotCutoff == 180.0) {
-			pointLight(i, normal, pos, diffuse, specular);
-		} else {
-			spotLight(i, normal, pos, diffuse, specular);
-		}
-    }
-}
-
-
-void main()
-{
-	vec4 diffuse_val  = vec4(0.0);
-	vec4 specular_val = vec4(0.0);
-	doLights(6, normal, pos, diffuse_val, specular_val);
-		
-    vec4 color = (diffuse_val  * 1.0) +
-                 (specular_val * 1.0)+
-                 ambient_color;
-	                 
-    color = clamp(color*vertexColor, 0.0, 1.0);
-    
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-
-	color = mix(gl_Fog.color, color, fogFactor );    
-	color.a = vertexColor.a;	
-	gl_FragColor = color;
-
-}

+ 0 - 147
Assets/Default asset pack/default/DefaultShaderShadows.frag

@@ -1,147 +0,0 @@
-varying vec3 normal;
-varying vec4 pos;
-varying vec4 vertexColor;
-varying vec4 ShadowCoord0;
-varying vec4 ShadowCoord1;
-
-uniform sampler2D diffuse;
-uniform sampler2D shadowMap0;
-uniform sampler2D shadowMap1;
-
-uniform vec4 diffuse_color;
-uniform vec4 specular_color;
-uniform vec4 ambient_color;
-uniform float shininess;
-
-uniform float shadowAmount;
-
-
-float calculateAttenuation(in int i, in float dist)
-{
-    return(1.0 / (gl_LightSource[i].constantAttenuation +
-                  gl_LightSource[i].linearAttenuation * dist +
-                  gl_LightSource[i].quadraticAttenuation * dist * dist));
-}
-
-void pointLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-	
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation;
-	  }
-	}
-}
-
-
-void spotLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular, sampler2D shadowMap, vec4 ShadowCoord) {
-	
-	vec4 shadowCoordinateWdivide = ShadowCoord / ShadowCoord.w;
-	//shadowCoordinateWdivide.z -= 0.00005;
-	float distanceFromLight = texture2D(shadowMap,shadowCoordinateWdivide.st).z;
-	float shadow = 1.0;
-	if (shadowCoordinateWdivide.x > 0.001 && shadowCoordinateWdivide.y > 0.001 && shadowCoordinateWdivide.x < 0.999 && shadowCoordinateWdivide.y < 0.999)
-		shadow = distanceFromLight < shadowCoordinateWdivide.z ? 0.0 : 1.0 ;
-	
-	shadow = clamp(shadow+(1.0-shadowAmount), 0.0, 1.0);
-	
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float cos_outer_cone_angle = (1.0-gl_LightSource[i].spotExponent) * gl_LightSource[i].spotCosCutoff;
-	float cos_cur_angle = dot(-normalize(gl_LightSource[i].spotDirection), sn.xyz);
-	float cos_inner_cone_angle = gl_LightSource[i].spotCosCutoff;
-
-	float cos_inner_minus_outer_angle = cos_inner_cone_angle - cos_outer_cone_angle;
-	float spot = 0.0;
-	spot = clamp((cos_cur_angle - cos_outer_cone_angle) / cos_inner_minus_outer_angle, 0.0, 1.0);
-	       
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation * spot * shadow;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation * spot * shadow;
-	  }
-	}
-}
-
-void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {    
-   	int spot = 0;
-    for (int i = 0; i < numLights; i++)
-    {
-		if (gl_LightSource[i].spotCutoff == 180.0) {
-				pointLight(i, normal, pos, diffuse, specular);
-		}  else {
-            	if(spot == 0) {
-					spotLight(i, normal, pos, diffuse, specular,shadowMap0, ShadowCoord0);            		                 
-					spot = 1;
-            	} else {
-					spotLight(i, normal, pos, diffuse, specular,shadowMap1, ShadowCoord1);            		
-            	}
-        }
-    } 
-    
-}
-
-
-void main()
-{
-	vec4 diffuse_val  = vec4(0.0);
-	vec4 specular_val = vec4(0.0);
-	doLights(6, normal, pos, diffuse_val, specular_val);
-		
-	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);		
-		
-    vec4 color = diffuse_val + ambient_color;	
-    color = clamp((color*vertexColor*texColor) + specular_val, 0.0, 1.0);	
-
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-
-	color = mix(gl_Fog.color, color, fogFactor );    
-	color.a = diffuse_color.a * texColor.a;	
-	gl_FragColor = color;
-
-}

+ 0 - 22
Assets/Default asset pack/default/DefaultShaderShadows.vert

@@ -1,22 +0,0 @@
-varying vec3 normal;
-varying vec4 pos;
-varying vec4 rawpos;
-varying vec4 vertexColor;
-varying vec4 ShadowCoord0;
-varying vec4 ShadowCoord1;
-uniform mat4 shadowMatrix0;
-uniform mat4 shadowMatrix1;
-uniform mat4 modelMatrix;
-
-void main() {
-	normal = gl_NormalMatrix * gl_Normal;
-	gl_Position = ftransform();
-	pos = gl_ModelViewMatrix * gl_Vertex;
-	rawpos = gl_Vertex;
-	
-	ShadowCoord0 = shadowMatrix0 * modelMatrix * gl_Vertex;	
-	ShadowCoord1 = shadowMatrix1 * modelMatrix * gl_Vertex;		
-			
-    vertexColor = gl_Color;
-	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
-}

+ 0 - 26
Assets/Default asset pack/default/DefaultShaderVertex.frag

@@ -1,26 +0,0 @@
-uniform sampler2D diffuse;
-varying vec4 vertexColor;
-varying vec4 specularColor;
-
-void main()
-{
-	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);	
-    vec4 color = (texColor*vertexColor) + specularColor;    
-
-    
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-	
-	color = mix(gl_Fog.color, color, fogFactor );  
-    color.a = vertexColor.a * texColor.a;	
-	gl_FragColor = color;
-    
-}

+ 0 - 111
Assets/Default asset pack/default/DefaultShaderVertex.vert

@@ -1,111 +0,0 @@
-uniform float shininess;
-uniform vec4 diffuse_color;
-uniform vec4 specular_color;
-uniform vec4 ambient_color;
-
-float calculateAttenuation(in int i, in float dist)
-{
-    return(1.0 / (gl_LightSource[i].constantAttenuation +
-                  gl_LightSource[i].linearAttenuation * dist +
-                  gl_LightSource[i].quadraticAttenuation * dist * dist));
-}
-
-void pointLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation;
-	  }
-	}
-}
-
-
-void spotLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	vec4 s = pos-lpos; 
-	vec4 sn = -normalize(s);
-
-	vec3 light = sn.xyz;
-	vec3 n = normalize(normal);
-	vec3 r = -reflect(light, n);
-	r = normalize(r);
-	vec3 v = -pos.xyz;
-	v = normalize(v);
-
-	float cos_outer_cone_angle = (1.0-gl_LightSource[i].spotExponent) * gl_LightSource[i].spotCosCutoff;
-	float cos_cur_angle = dot(-normalize(gl_LightSource[i].spotDirection), sn.xyz);
-	float cos_inner_cone_angle = gl_LightSource[i].spotCosCutoff;
-
-	float cos_inner_minus_outer_angle = cos_inner_cone_angle - cos_outer_cone_angle;
-	float spot = 0.0;
-	spot = clamp((cos_cur_angle - cos_outer_cone_angle) / cos_inner_minus_outer_angle, 0.0, 1.0);
-
-	float nDotL = dot(n, sn.xyz);
-	if(nDotL > 0.0) {
-		float dist = length(s);    
-		float attenuation = calculateAttenuation(i, dist);
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation * spot;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(max(0.0,dot(r, v)), shininess) * attenuation * spot;
-	  }
-	}
-}
-
-void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	for (int i = 0; i < numLights; i++) {
-		if (gl_LightSource[i].spotCutoff == 180.0) {
-			pointLight(i, normal, pos, diffuse, specular);
-		} else {
-			spotLight(i, normal, pos, diffuse, specular);
-		}
-    }
-}
-
-varying vec4 vertexColor;
-varying vec4 specularColor;
-
-void main() {
-	vec3 normal = gl_NormalMatrix * gl_Normal;
-	gl_Position = ftransform();
-	vec4 pos = gl_ModelViewMatrix * gl_Vertex;
-	vec4 rawpos = gl_Vertex;
-    vertexColor = gl_Color;
-	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
-
-	vec4 diffuse_val  = vec4(0.0);
-	vec4 specular_val = vec4(0.0);
-	doLights(6, normal, pos, diffuse_val, specular_val);
-	
-    vec4 color = diffuse_val +
-                 ambient_color;
-	
-	color.a = diffuse_color.a; 
-	specularColor = specular_val;
-	
-    vertexColor = clamp(color*vertexColor, 0.0, 1.0);  	
-}

+ 0 - 25
Assets/Default asset pack/default/DefaultShaderVertexNoTexture.frag

@@ -1,25 +0,0 @@
-
-varying vec4 vertexColor;
-varying vec4 specularColor;
-
-void main()
-{
-    vec4 color = vertexColor + specularColor;
-    
-    
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-
-	color = mix(gl_Fog.color, color, fogFactor ); 
-	color.a = vertexColor.a;
-	gl_FragColor = color;
-    
-}

+ 0 - 64
Assets/Default asset pack/default/GPUSkinning.vert

@@ -1,64 +0,0 @@
-#define MAX_JOINT_COUNT 64
-
-uniform mat4 skeletonMatrix[MAX_JOINT_COUNT];
-
-attribute vec4 vBoneIndices;
-attribute vec4 vBoneWeights;
-
-varying vec3 normal;
-varying vec4 pos;
-varying vec4 rawpos;
-varying vec4 vertexColor;
-
-
-mat3 m3( mat4 m )
-{
-	mat3 result;
-
-	result[0][0] = m[0][0]; 
-	result[0][1] = m[0][1]; 
-	result[0][2] = m[0][2]; 
-
-
-	result[1][0] = m[1][0]; 
-	result[1][1] = m[1][1]; 
-	result[1][2] = m[1][2]; 
-
-	result[2][0] = m[2][0]; 
-	result[2][1] = m[2][1]; 
-	result[2][2] = m[2][2]; 
-
-	return result;
-}
-
-
-void jointInfluence(in mat4 joint_matrix, in float weight, in vec4 position, inout vec4 outPosition, in vec3 normal, inout vec3 outNormal)
-{
-  outPosition += weight * (joint_matrix * position);
-
-  mat3 normalMatrix = m3(joint_matrix);
-  outNormal += weight * (normalMatrix * normal);
-}
-
-void main() {
-
-	vec4 inVert = gl_Vertex;
-	vec4 outVert = vec4(0.0, 0.0, 0.0, 0.0);
-
-	vec3 inNormal = gl_Normal;
-	vec3 outNormal = vec3(0.0, 0.0, 0.0);
-
-	jointInfluence(skeletonMatrix[int(vBoneIndices.x)], vBoneWeights.x, inVert, outVert, inNormal, outNormal);
-    jointInfluence(skeletonMatrix[int(vBoneIndices.y)], vBoneWeights.y, inVert, outVert, inNormal, outNormal);
-    jointInfluence(skeletonMatrix[int(vBoneIndices.z)], vBoneWeights.z, inVert, outVert, inNormal, outNormal);
-    jointInfluence(skeletonMatrix[int(vBoneIndices.w)], vBoneWeights.w, inVert, outVert, inNormal, outNormal);
-
-	outVert.w = 1.0;
-
-	normal = gl_NormalMatrix * normalize(outNormal);	
-	gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * outVert;
-	pos = gl_ModelViewMatrix * outVert;
-	rawpos = outVert;
-    vertexColor = gl_Color;
-	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
-}

+ 0 - 46
Assets/Default asset pack/default/LightCube.frag

@@ -1,46 +0,0 @@
-uniform samplerCube lightCube;
-varying vec4 vertexColor;
-varying vec3 normal;
-uniform vec4 ambient_color;
-varying vec3 worldNormal;
-
-uniform float lightFactor;
-
-vec3 hash3( float n )
-{
-    return fract(sin(vec3(n,n+1.0,n+2.0))*vec3(43758.5453123,22578.1459123,19642.3490423));
-}
-
-void main()
-{
-	vec3 col = vec3(0.0);
-	for( int i=0; i<32; i++ )
-	{			
-		vec3 rr = normalize(-1.0 + 2.0*hash3(float(i)*123.5463));
-		rr = normalize( worldNormal + 7.0*rr );
-		rr = rr * sign(dot(worldNormal,rr));
-        col += pow( textureCube( lightCube, rr ).xyz, vec3(2.2) ) * dot(rr,worldNormal);
-	}
-
-	col = col * lightFactor;
-
-    vec4 texColor = vec4(col, 1.0);
-
-    vec4 color = vec4(1.0,1.0,1.0,1.0) + ambient_color; 	           
-    color = clamp((color*vertexColor*texColor), 0.0, 1.0);  
-
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-	color = mix(gl_Fog.color, color, fogFactor );   
-
-	color.a = vertexColor.a * texColor.a;    
-    gl_FragColor = color;
-}

+ 0 - 28
Assets/Default asset pack/default/LightCube.vert

@@ -1,28 +0,0 @@
-varying vec3 normal;
-varying vec3 worldNormal;
-varying vec4 pos;
-varying vec4 rawpos;
-varying vec4 vertexColor;
-
-uniform mat4 modelMatrix;
-
-mat3 mat3_emu(mat4 m4) {
-  return mat3(
-      m4[0][0], m4[0][1], m4[0][2],
-      m4[1][0], m4[1][1], m4[1][2],
-      m4[2][0], m4[2][1], m4[2][2]);
-}
-
-void main() {
-	normal = gl_NormalMatrix * gl_Normal;
-
-	mat3 rotN = mat3_emu(modelMatrix);
-	worldNormal = rotN * gl_Normal;
-	worldNormal = normalize(worldNormal);
-
-	gl_Position = ftransform();
-	pos = gl_ModelViewMatrix * gl_Vertex;
-	rawpos = gl_Vertex;
-    vertexColor = gl_Color;
-	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
-}

+ 0 - 158
Assets/Default asset pack/default/NorColSpec.frag

@@ -1,158 +0,0 @@
-varying vec3 normal;
-varying vec3 tangent;
-varying vec3 binormal;
-varying vec4 pos;
-varying vec4 vertexColor;
-
-uniform sampler2D diffuse;
-uniform sampler2D normal_map;
-uniform sampler2D specular_map;
-uniform sampler2D emit_map;
-
-uniform vec4 diffuse_color;
-uniform vec4 specular_color;
-uniform vec4 ambient_color;
-uniform float shininess;
-
-float calculateAttenuation(in int i, in float dist)
-{
-    return(1.0 / (gl_LightSource[i].constantAttenuation +
-                  gl_LightSource[i].linearAttenuation * dist +
-                  gl_LightSource[i].quadraticAttenuation * dist * dist));
-}
-
-void pointLight(in int i, in vec3 bump, in vec3 normal, in vec3 tangent, in vec3 binormal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	
-	vec3 tmpVec = lpos.xyz - pos.xyz;	
-	lpos.x = dot(tmpVec, tangent);
-	lpos.y = dot(tmpVec, binormal);
-	lpos.z = dot(tmpVec, normal);	
-	
-	float distSqr = dot(lpos.xyz, lpos.xyz);
-	vec3 lVec = lpos.xyz * inversesqrt(distSqr);
-	
-	tmpVec = -pos.xyz;
-	vec3 v;
-	v.x = dot(tmpVec, tangent);
-	v.y = dot(tmpVec, binormal);
-	v.z = dot(tmpVec, normal);	
-	
-	v = normalize(v);
-
-	float nDotL = dot(lVec, bump);
-	if(nDotL > 0.0) {
-		float dist = length(lpos.xyz);    
-		float attenuation = calculateAttenuation(i, dist);
-
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(clamp(dot(reflect(-lVec, bump), v),0.0,1.0), shininess) * attenuation;
-	  }
-	}
-}
-
-
-void spotLight(in int i, in vec3 bump, in vec3 normal, in vec3 tangent, in vec3 binormal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	vec4 color = diffuse_color;
-	vec4 matspec = specular_color;
-	float shininess = shininess;
-	vec4 lightspec = gl_LightSource[i].specular;
-	vec4 lpos = gl_LightSource[i].position;
-	
-	vec3 tmpVec = lpos.xyz - pos.xyz;	
-	lpos.x = dot(tmpVec, tangent);
-	lpos.y = dot(tmpVec, binormal);
-	lpos.z = dot(tmpVec, normal);	
-	
-	float distSqr = dot(lpos.xyz, lpos.xyz);
-	vec3 lVec = lpos.xyz * inversesqrt(distSqr);
-	
-	tmpVec = -pos.xyz;
-	vec3 v;
-	v.x = dot(tmpVec, tangent);
-	v.y = dot(tmpVec, binormal);
-	v.z = dot(tmpVec, normal);	
-	
-	v = normalize(v);
-	
-	tmpVec = gl_LightSource[i].spotDirection.xyz;
-	vec3 lDir;
-	lDir.x = dot(tmpVec, tangent);
-	lDir.y = dot(tmpVec, binormal);
-	lDir.z = dot(tmpVec, normal);	
-	
-	lDir = normalize(lDir);
-
-	
-	float cos_outer_cone_angle = (1.0-gl_LightSource[i].spotExponent) * gl_LightSource[i].spotCosCutoff;
-	float cos_cur_angle = dot(-lDir, lVec);
-	float cos_inner_cone_angle = gl_LightSource[i].spotCosCutoff;
-
-	float cos_inner_minus_outer_angle = cos_inner_cone_angle - cos_outer_cone_angle;
-	float spot = clamp((cos_cur_angle - cos_outer_cone_angle) / cos_inner_minus_outer_angle, 0.0, 1.0);
-	       	
-
-	float nDotL = dot(lVec, bump);
-	if(nDotL > 0.0) {
-		float dist = length(lpos.xyz);    
-		float attenuation = calculateAttenuation(i, dist);
-
-		diffuse  += color * max(0.0, nDotL) * gl_LightSource[i].diffuse * attenuation * spot;
-
-	  if (shininess != 0.0) {
-    	specular += lightspec * matspec * pow(clamp(dot(reflect(-lVec, bump), v),0.0,1.0), shininess) * attenuation * spot;
-	  }
-	}}
-
-void doLights(in int numLights, in vec3 bump, in vec3 normal, in vec3 tangent, in vec3 binormal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
-	for (int i = 0; i < numLights; i++) {
-		if (gl_LightSource[i].spotCutoff == 180.0) {
-			pointLight(i, bump, normal, tangent, binormal, pos, diffuse, specular);
-		} else {
-			spotLight(i, bump, normal, tangent, binormal, pos, diffuse, specular);
-		}
-    }
-}
-
-
-void main()
-{
-	vec4 diffuse_val  = vec4(0.0);
-	vec4 specular_val = vec4(0.0);
-	
-	vec3 bump = normalize( texture2D(normal_map, gl_TexCoord[0].st).xyz * 2.0 - 1.0);
-		
-	doLights(6, bump, normal, tangent, binormal, pos, diffuse_val, specular_val);
-	
-	specular_val.xyz *= texture2D(specular_map, gl_TexCoord[0].st).xyz * gl_FrontMaterial.specular.a;
-			
-	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);		
-		
-    vec4 color = (diffuse_val  * texColor * vertexColor) +
-                 (specular_val * 1.0)+
-                 (ambient_color * texColor * vertexColor);
-    color = clamp(color, 0.0, 1.0);
-    
-
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-
-	color = mix(gl_Fog.color, color, fogFactor ); 
-	color.a = diffuse_color.a * texColor.a;
-	gl_FragColor = color;
-
-}

+ 0 - 18
Assets/Default asset pack/default/NormalShader.vert

@@ -1,18 +0,0 @@
-varying vec3 normal;
-varying vec3 tangent;
-varying vec3 binormal;
-varying vec4 pos;
-varying vec4 rawpos;
-varying vec4 vertexColor;
-attribute vec3 vTangent;
-
-void main() {
-	normal = normalize(gl_NormalMatrix * gl_Normal);
-	tangent = normalize(gl_NormalMatrix * vTangent); 
-	binormal = normalize(cross(normal, tangent));
-	gl_Position = ftransform();
-	pos = gl_ModelViewMatrix * gl_Vertex;
-	rawpos = gl_Vertex;
-    vertexColor = gl_Color;
-	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
-}

+ 0 - 6
Assets/Default asset pack/default/PassThrough.frag

@@ -1,6 +0,0 @@
-uniform sampler2D screenColorBuffer;
- 
-void main(void)
-{
-   gl_FragColor = texture2D(screenColorBuffer,gl_TexCoord[0].st);
-}

+ 0 - 8
Assets/Default asset pack/default/ScreenShader.vert

@@ -1,8 +0,0 @@
-varying vec2 vTexCoord;
-void main(void)
-{
-	gl_TexCoord[0] = gl_MultiTexCoord0;		      
-//   vec2 Pos;
-//   Pos = sign(); 
-   gl_Position = vec4(gl_Vertex.xy, 0.0, 1.0);
-}

+ 0 - 28
Assets/Default asset pack/default/SkyBox.frag

@@ -1,28 +0,0 @@
-uniform samplerCube lightCube;
-varying vec4 vertexColor;
-varying vec3 normal;
-uniform vec4 ambient_color;
-varying vec3 worldNormal;
-
-void main()
-{
-    vec4 texColor = textureCube(lightCube, worldNormal * -1.0);
-
-    vec4 color = vec4(1.0,1.0,1.0,1.0) + ambient_color; 	           
-    color = clamp((color*vertexColor*texColor), 0.0, 1.0);  
-
-    // fog
-	const float LOG2 = 1.442695;
-	float z = gl_FragCoord.z / gl_FragCoord.w;
-	float fogFactor = exp2( -gl_Fog.density * 
-				   gl_Fog.density * 
-				   z * 
-				   z * 
-				   LOG2 );
-
-	fogFactor = clamp(fogFactor, 0.0, 1.0);
-	color = mix(gl_Fog.color, color, fogFactor );   
-
-	color.a = vertexColor.a * texColor.a;    
-    gl_FragColor = color;
-}

+ 5 - 6
Assets/Default asset pack/default/Unlit.frag

@@ -1,9 +1,8 @@
+uniform sampler2D texture;
+uniform vec2 scroll;
 
 
-uniform sampler2D diffuse;
-varying vec4 vertexColor;
+varying vec2 texCoordVar;
 
 
-void main()
-{
-	vec4 texColor = texture2D(diffuse, gl_TexCoord[0].st);
-    gl_FragColor = texColor*vertexColor;
+void main() {
+	gl_FragColor = texture2D( texture, texCoordVar + scroll);
 }
 }

+ 9 - 4
Assets/Default asset pack/default/Unlit.vert

@@ -1,8 +1,13 @@
+attribute vec4 position;
+attribute vec2 texCoord;
+
+uniform mat4 modelView;
+uniform mat4 projection;
+varying vec2 texCoordVar;
 
 
-varying vec4 vertexColor;
 void main()
 void main()
 {
 {
-    gl_TexCoord[0] = gl_MultiTexCoord0;		
-    vertexColor = gl_Color;
-    gl_Position = ftransform();
+	vec4 p = modelView * position;
+	gl_Position = projection * p;
+	texCoordVar = texCoord;
 }
 }

+ 0 - 7
Assets/Default asset pack/default/UnlitUntextured.frag

@@ -1,7 +0,0 @@
-
-varying vec4 vertexColor;
-
-void main()
-{
-    gl_FragColor = vertexColor;
-}

+ 2 - 144
Assets/Default asset pack/default/default.mat

@@ -1,159 +1,17 @@
 <?xml version="1.0" ?>
 <?xml version="1.0" ?>
 <polycode>	
 <polycode>	
-	<shaders>		
-		<shader type="glsl" name="DefaultShader" numPointLights="6" numSpotLights="2">		
-			<vp source="default/DefaultShader.vert"/>
-			<fp source="default/DefaultShader.frag"/>
-		</shader>
-		<shader type="glsl" name="ColSpecEmit" numPointLights="6" numSpotLights="2">		
-			<vp source="default/DefaultShader.vert"/>
-			<fp source="default/ColSpecEmit.frag"/>
-		</shader>			
-		<shader type="glsl" name="DefaultShaderNoTexture" numPointLights="6" numSpotLights="2">	
-			<vp source="default/DefaultShader.vert"/>
-			<fp source="default/DefaultShaderNoTexture.frag"/>
-		</shader>
-		<shader type="glsl" name="DefaultShaderShadows" numPointLights="6" numSpotLights="2">		
-			<vp source="default/DefaultShaderShadows.vert"/>
-			<fp source="default/DefaultShaderShadows.frag"/>
-		</shader>		
-		<shader type="glsl" name="DefaultShaderVertex" numPointLights="6" numSpotLights="2">		
-			<vp source="default/DefaultShaderVertex.vert"/>
-			<fp source="default/DefaultShaderVertex.frag"/>
-		</shader>			
-		<shader type="glsl" name="DefaultShaderVertexNoTexture" numPointLights="6" numSpotLights="2">		
-			<vp source="default/DefaultShaderVertex.vert"/>
-			<fp source="default/DefaultShaderVertexNoTexture.frag"/>
-		</shader>
-		<shader type="glsl" name="DefaultParticleShader" numPointLights="6" numSpotLights="2">		
-			<vp source="default/DefaultShader.vert"/>
-			<fp source="default/DefaultParticleShader.frag"/>
-		</shader>															
+	<shaders>														
 		<shader type="glsl" name="Unlit" numPointLights="0" numSpotLights="0">		
 		<shader type="glsl" name="Unlit" numPointLights="0" numSpotLights="0">		
 			<vp source="default/Unlit.vert"/>
 			<vp source="default/Unlit.vert"/>
 			<fp source="default/Unlit.frag"/>
 			<fp source="default/Unlit.frag"/>
 		</shader>
 		</shader>
-		<shader type="glsl" name="UnlitUntextured" numPointLights="0" numSpotLights="0">		
-			<vp source="default/Unlit.vert"/>
-			<fp source="default/UnlitUntextured.frag"/>
-		</shader>		
-		<shader type="glsl" name="LightCube" numPointLights="0" numSpotLights="0">		
-			<vp source="default/LightCube.vert"/>
-			<fp source="default/LightCube.frag"/>
-		</shader>
-		<shader type="glsl" name="SkyBox" numPointLights="0" numSpotLights="0">		
-			<vp source="default/LightCube.vert"/>
-			<fp source="default/SkyBox.frag"/>
-		</shader>		
-		<shader type="glsl" name="NorColSpec" numPointLights="6" numSpotLights="2">		
-			<vp source="default/NormalShader.vert"/>
-			<fp source="default/NorColSpec.frag"/>
-		</shader>
-		<shader type="glsl" name="PassThrough" screen="true">
-			<vp source="default/ScreenShader.vert"/>
-			<fp source="default/PassThrough.frag"/>
-		</shader>	
 	</shaders>	
 	</shaders>	
-	<materials>
-		<material name="DefaultVertex">
-			<shader name="DefaultShaderVertexNoTexture">
-			</shader>
-		</material>		
-		<material name="DefaultVertexTextured">
-			<shader name="DefaultShaderVertex">
-			</shader>
-		</material>
-		<material name="DefaultVertexTexturedAdditive" blendingMode="2">
-			<shader name="DefaultShaderVertex">
-			</shader>
-		</material>						
-		<material name="Default">
-			<shader name="DefaultShaderNoTexture">
-			</shader>
-		</material>			
-		<material name="DefaultTextured">
-			<shader name="DefaultShader">
-				<textures>
-				</textures>				
-			</shader>
-		</material>
-		<material name="ColSpecEmit">
-			<shader name="ColSpecEmit">
-				<textures>
-				</textures>				
-			</shader>
-		</material>
-		<material name="DefaultTexturedAdditive" blendingMode="2">
-			<shader name="DefaultShader">
-				<textures>
-				</textures>				
-			</shader>
-		</material>	
-		<material name="UnlitWireframe" wireframe="true">
-			<shader name="UnlitUntextured">
-			</shader>
-		</material>
-		<material name="UnlitUntextured">
-			<shader name="UnlitUntextured">
-			</shader>
-		</material>	
-		<material name="UnlitUntexturedAdditive" blendingMode="2">
-			<shader name="UnlitUntextured">
-			</shader>
-		</material>		
+	<materials>	
 		<material name="Unlit">
 		<material name="Unlit">
 			<shader name="Unlit">
 			<shader name="Unlit">
 				<textures>
 				<textures>
 				</textures>				
 				</textures>				
 			</shader>
 			</shader>
 		</material>
 		</material>
-		<material name="UnlitAdditive" blendingMode="2">
-			<shader name="Unlit">
-				<textures>
-				</textures>				
-			</shader>
-		</material>		
-		<material name="UnlitAdditive" blendingMode="2">
-			<shader name="Unlit">
-				<textures>
-				</textures>				
-			</shader>
-		</material>		
-		<material name="DefaultWithShadows">
-			<shader name="DefaultShaderShadows">
-				<textures>
-				</textures>				
-			</shader>
-		</material>
-		<material name="Particles">
-			<shader name="DefaultParticleShader">
-				<textures>
-				</textures>				
-			</shader>
-		</material>
-		<material name="ParticlesAdditive" blendingMode="2">
-			<shader name="DefaultParticleShader">
-				<textures>
-				</textures>				
-			</shader>
-		</material>
-		<material name="LightCube">
-			<shader name="LightCube">
-				<textures>
-				</textures>				
-			</shader>
-		</material>
-		<material name="SkyBox">
-			<shader name="SkyBox">
-				<textures>
-				</textures>				
-			</shader>
-		</material>		
-		<material name="NormalColorSpecular">
-			<shader name="NorColSpec">
-				<textures>
-				</textures>				
-			</shader>
-		</material>		
 	</materials>
 	</materials>
 </polycode>
 </polycode>

+ 0 - 2
Core/Contents/CMakeLists.txt

@@ -17,7 +17,6 @@ SET(polycore_SRCS
     Source/PolyEvent.cpp
     Source/PolyEvent.cpp
     Source/PolyEventDispatcher.cpp
     Source/PolyEventDispatcher.cpp
     Source/PolyEventHandler.cpp
     Source/PolyEventHandler.cpp
-    Source/PolyFixedShader.cpp
     Source/PolyFont.cpp
     Source/PolyFont.cpp
     Source/PolyFontGlyphSheet.cpp
     Source/PolyFontGlyphSheet.cpp
     Source/PolyFontManager.cpp
     Source/PolyFontManager.cpp
@@ -99,7 +98,6 @@ SET(polycore_HDRS
     Include/PolyEventDispatcher.h
     Include/PolyEventDispatcher.h
     Include/PolyEvent.h
     Include/PolyEvent.h
     Include/PolyEventHandler.h
     Include/PolyEventHandler.h
-    Include/PolyFixedShader.h
     Include/PolyFont.h
     Include/PolyFont.h
 	Include/PolyFontGlyphSheet.h
 	Include/PolyFontGlyphSheet.h
     Include/PolyFontManager.h
     Include/PolyFontManager.h

+ 1 - 1
Core/Contents/Include/PolyCocoaCore.h

@@ -169,7 +169,7 @@ namespace Polycode {
         void handleVideoModeChange(VideoModeChangeInfo *modeInfo);
         void handleVideoModeChange(VideoModeChangeInfo *modeInfo);
         void flushRenderContext();
         void flushRenderContext();
         
         
-	protected:	
+	protected:
 	
 	
 		PolycodeView *glView;
 		PolycodeView *glView;
 		uint64_t initTime;
 		uint64_t initTime;

+ 0 - 60
Core/Contents/Include/PolyFixedShader.h

@@ -1,60 +0,0 @@
-/*
-Copyright (C) 2011 by Ivan Safrin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#pragma once
-#include "PolyString.h"
-#include "PolyLogger.h"
-#include "PolyGlobals.h"
-#include "PolyShader.h"
-#include "PolyTexture.h"
-
-namespace Polycode {
-
-	class _PolyExport FixedShader : public Shader {
-		public:
-			FixedShader();
-			virtual ~FixedShader();
-			
-			ShaderBinding *createBinding();
-
-		protected:
-			
-	};
-
-	class _PolyExport FixedShaderBinding : public ShaderBinding {
-		public:
-			FixedShaderBinding(FixedShader *shader);
-			~FixedShaderBinding();
-			
-			void addTexture(const String& name, Texture *texture);
-			void addCubemap(const String& name, Cubemap *cubemap);
-			
-			Texture *getDiffuseTexture();
-			
-		protected:
-
-			std::vector<Texture*> textures;
-			std::vector<Cubemap*> cubemaps;
-			FixedShader *fixedShader;
-	};
-
-}

+ 5 - 1
Core/Contents/Include/PolyGPUDrawBuffer.h

@@ -25,6 +25,7 @@
 #include "PolyMesh.h"
 #include "PolyMesh.h"
 #include "PolyShader.h"
 #include "PolyShader.h"
 #include "PolyRectangle.h"
 #include "PolyRectangle.h"
+#include "PolyMaterial.h"
 
 
 namespace Polycode {
 namespace Polycode {
     
     
@@ -48,6 +49,9 @@ namespace Polycode {
         
         
         Matrix4 modelMatrix;
         Matrix4 modelMatrix;
         
         
+        Material *material;
+        ShaderBinding *shaderBinding;
+        
         std::vector<RenderDataArray*> attributeArrays;
         std::vector<RenderDataArray*> attributeArrays;
         std::vector<LocalShaderParam> uniforms;
         std::vector<LocalShaderParam> uniforms;
     };
     };
@@ -58,7 +62,7 @@ namespace Polycode {
         GPUDrawBuffer();
         GPUDrawBuffer();
         ~GPUDrawBuffer();
         ~GPUDrawBuffer();
         
         
-        Matrix4 projectionMatrix;        
+        Matrix4 projectionMatrix;
         Polycode::Rectangle viewport;
         Polycode::Rectangle viewport;
         std::vector<GPUDrawCall> drawCalls;
         std::vector<GPUDrawCall> drawCalls;
     };
     };

+ 1 - 4
Core/Contents/Include/PolyMaterialManager.h

@@ -61,11 +61,8 @@ namespace Polycode {
 			void reloadProgramsAndTextures();
 			void reloadProgramsAndTextures();
 			void reloadPrograms();
 			void reloadPrograms();
 		
 		
-			//SceneRenderTexture *createRenderTexture(Scene *targetScene, Camera *targetCamera, int renderWidth,int renderHeight);
 			Texture *getTextureByResourcePath(const String& resourcePath) const;
 			Texture *getTextureByResourcePath(const String& resourcePath) const;
-			
-			ShaderProgram *createProgramFromFile(String programPath);
-			
+			ShaderProgram *createProgramFromFile(String programPath);			
             void loadMaterialLibraryIntoPool(ResourcePool *pool, const String &materialFile);
             void loadMaterialLibraryIntoPool(ResourcePool *pool, const String &materialFile);
         
         
 			// cubemaps
 			// cubemaps

+ 6 - 1
Core/Contents/Include/PolyOpenGLGraphicsInterface.h

@@ -56,13 +56,18 @@ namespace Polycode {
 
 
 		// implementation
 		// implementation
         
         
-        void executeDrawCall(const GPUDrawCall& drawCall);
         void createTexture(Texture *texture, int filteringMode, int anisotropy, bool createMipmaps);
         void createTexture(Texture *texture, int filteringMode, int anisotropy, bool createMipmaps);
         void setViewport(unsigned int x,unsigned  int y,unsigned  int width, unsigned height);
         void setViewport(unsigned int x,unsigned  int y,unsigned  int width, unsigned height);
         void clearBuffers(bool colorBuffer, bool depthBuffer, bool stencilBuffer);
         void clearBuffers(bool colorBuffer, bool depthBuffer, bool stencilBuffer);
+        void setParamInShader(Shader *shader, const ProgramParam &param, LocalShaderParam *localParam);
+        void createProgram(ShaderProgram *program);
+        void createShader(Shader *shader);
         
         
 	protected:
 	protected:
 		
 		
+        static int getPolycodeParamType(int glType);
+        static int getAttributeSize(int glType);
+        void setUniformMatrix(GLint paramLocation, const Polycode::Matrix4& matrix);
         
         
 	};
 	};
 }
 }

+ 1 - 1
Core/Contents/Include/PolyParticleEmitter.h

@@ -63,7 +63,7 @@ namespace Polycode {
             Vector3 getGravity() const;
             Vector3 getGravity() const;
         
         
             void fixedUpdate();
             void fixedUpdate();
-            void Render();
+            void Render(GPUDrawBuffer *buffer);
         
         
             void updateParticles();
             void updateParticles();
             void rebuildParticles();
             void rebuildParticles();

+ 4 - 1
Core/Contents/Include/PolyRenderDataArray.h

@@ -79,13 +79,16 @@ namespace Polycode {
          */
          */
         static const int TEXCOORD2_DATA_ARRAY = 8;
         static const int TEXCOORD2_DATA_ARRAY = 8;
         
         
+        
     };
     };
 
 
     class VertexDataArray : public RenderDataArray {
     class VertexDataArray : public RenderDataArray {
     public:
     public:
-        VertexDataArray(unsigned int type) : RenderDataArray(type) {
+        VertexDataArray(unsigned char countPerVertex, unsigned int type) : RenderDataArray(type), countPerVertex(countPerVertex) {
         }
         }
         
         
+        unsigned char getCountPerVertex();
+        unsigned char countPerVertex;
         std::vector<PolyRendererVertexType> data;
         std::vector<PolyRendererVertexType> data;
         virtual void *getArrayData();
         virtual void *getArrayData();
         virtual unsigned int getDataSize();
         virtual unsigned int getDataSize();

+ 10 - 4
Core/Contents/Include/PolyRenderer.h

@@ -40,13 +40,12 @@ namespace Polycode {
     class _PolyExport GraphicsInterface : public PolyBase {
     class _PolyExport GraphicsInterface : public PolyBase {
         public:
         public:
             GraphicsInterface();
             GraphicsInterface();
-            virtual void executeDrawCall(const GPUDrawCall& drawCall) = 0;
+            virtual void setParamInShader(Shader *shader, const ProgramParam &param, LocalShaderParam *localParam) = 0;
             virtual void createTexture(Texture *texture, int filteringMode, int anisotropy, bool createMipmaps) = 0;
             virtual void createTexture(Texture *texture, int filteringMode, int anisotropy, bool createMipmaps) = 0;
             virtual void setViewport(unsigned int x,unsigned  int y,unsigned  int width, unsigned height) = 0;
             virtual void setViewport(unsigned int x,unsigned  int y,unsigned  int width, unsigned height) = 0;
             virtual void clearBuffers(bool colorBuffer, bool depthBuffer, bool stencilBuffer) = 0;
             virtual void clearBuffers(bool colorBuffer, bool depthBuffer, bool stencilBuffer) = 0;
-        
-        protected:
-        
+            virtual void createProgram(ShaderProgram *program) = 0;
+            virtual void createShader(Shader *shader) = 0;
     };
     };
     
     
     class _PolyExport RendererThreadJob {
     class _PolyExport RendererThreadJob {
@@ -71,10 +70,14 @@ namespace Polycode {
             void enqueueJob(int jobType, void *data);
             void enqueueJob(int jobType, void *data);
             void processJob(const RendererThreadJob &job);
             void processJob(const RendererThreadJob &job);
         
         
+            void processDrawBuffer(GPUDrawBuffer *buffer);
+        
             static const int JOB_REQUEST_CONTEXT_CHANGE = 0;
             static const int JOB_REQUEST_CONTEXT_CHANGE = 0;
             static const int JOB_CREATE_TEXTURE = 1;
             static const int JOB_CREATE_TEXTURE = 1;
             static const int JOB_PROCESS_DRAW_BUFFER = 2;
             static const int JOB_PROCESS_DRAW_BUFFER = 2;
             static const int JOB_FLUSH_CONTEXT = 3;
             static const int JOB_FLUSH_CONTEXT = 3;
+            static const int JOB_CREATE_PROGRAM = 4;
+            static const int JOB_CREATE_SHADER = 5;
         
         
         protected:
         protected:
             Core *core;
             Core *core;
@@ -103,6 +106,8 @@ namespace Polycode {
         void setBackingResolutionScale(Number xScale, Number yScale);
         void setBackingResolutionScale(Number xScale, Number yScale);
         Number getBackingResolutionScaleX();
         Number getBackingResolutionScaleX();
         Number getBackingResolutionScaleY();
         Number getBackingResolutionScaleY();
+        ShaderProgram *createProgram(const String &fileName);
+        Shader *createShader(ShaderProgram *vertexProgram, ShaderProgram *fragmentProgram);
         
         
         void setAnisotropyAmount(Number amount);
         void setAnisotropyAmount(Number amount);
         Number getAnisotropyAmount();
         Number getAnisotropyAmount();
@@ -124,6 +129,7 @@ namespace Polycode {
         
         
         
         
 	protected:
 	protected:
+        
       
       
         Number backingResolutionScaleX;
         Number backingResolutionScaleX;
         Number backingResolutionScaleY;
         Number backingResolutionScaleY;

+ 2 - 0
Core/Contents/Include/PolyResource.h

@@ -68,6 +68,8 @@ namespace Polycode {
 						
 						
 			//@}
 			//@}
 			
 			
+            void *platformData;
+        
 		protected:
 		protected:
 
 
 			
 			

+ 22 - 26
Core/Contents/Include/PolyShader.h

@@ -39,19 +39,25 @@ namespace Polycode {
 	class _PolyExport ProgramParam {
 	class _PolyExport ProgramParam {
 		public:
 		public:
 	
 	
-	String name;
-	int type;
+        String name;
+        int type;
 
 
-	static void *createParamData(int type);
-	
-	static const int PARAM_UNKNOWN = 0;	
-	static const int PARAM_NUMBER = 1;
-	static const int PARAM_VECTOR2 = 2;		
-	static const int PARAM_VECTOR3 = 3;
-	static const int PARAM_COLOR = 4;
-	static const int PARAM_MATRIX = 5;
+        static void *createParamData(int type);
+        
+        static const int PARAM_UNKNOWN = 0;	
+        static const int PARAM_NUMBER = 1;
+        static const int PARAM_VECTOR2 = 2;		
+        static const int PARAM_VECTOR3 = 3;
+        static const int PARAM_COLOR = 4;
+        static const int PARAM_MATRIX = 5;
 	};
 	};
 	
 	
+    class _PolyExport ProgramAttribute {
+        public:
+            int size;
+            String name;
+    };
+    
 	typedef struct {
 	typedef struct {
 		Texture *texture;
 		Texture *texture;
 		String name;
 		String name;
@@ -64,23 +70,19 @@ namespace Polycode {
 
 
 	class _PolyExport ShaderProgram : public Resource {
 	class _PolyExport ShaderProgram : public Resource {
 		public:
 		public:
-			explicit ShaderProgram(int type);
+			explicit ShaderProgram(const String &fileName);
 			virtual ~ShaderProgram();
 			virtual ~ShaderProgram();
 			
 			
 			virtual void reloadProgram() {}
 			virtual void reloadProgram() {}
-			
 			static const int TYPE_VERT = 0;
 			static const int TYPE_VERT = 0;
-			static const int TYPE_FRAG = 1;		
-			
+			static const int TYPE_FRAG = 1;
 			int type;
 			int type;
-			
 			void reloadResource();
 			void reloadResource();
-			
 	};
 	};
 
 
 	class _PolyExport Shader : public Resource {
 	class _PolyExport Shader : public Resource {
 		public:
 		public:
-			explicit Shader(int type);
+			explicit Shader();
 			virtual ~Shader();
 			virtual ~Shader();
 
 
 			int getType() const;
 			int getType() const;
@@ -94,9 +96,6 @@ namespace Polycode {
 			
 			
 			virtual void setVertexProgram(ShaderProgram *vp) {}
 			virtual void setVertexProgram(ShaderProgram *vp) {}
 			virtual void setFragmentProgram(ShaderProgram *fp) {}
 			virtual void setFragmentProgram(ShaderProgram *fp) {}
-			
-			static const int FIXED_SHADER = 0;
-			static const int MODULE_SHADER = 1;
 
 
 			int numSpotLights;
 			int numSpotLights;
 			int numPointLights;
 			int numPointLights;
@@ -104,17 +103,14 @@ namespace Polycode {
 			std::vector<String> expectedTextures;
 			std::vector<String> expectedTextures;
 			std::vector<String> expectedCubemaps;			
 			std::vector<String> expectedCubemaps;			
 			std::vector<ProgramParam> expectedParams;
 			std::vector<ProgramParam> expectedParams;
+			std::vector<ProgramAttribute> expectedAttributes;
 								
 								
 			bool screenShader;
 			bool screenShader;
 			
 			
-			ShaderProgram *vp;
-			ShaderProgram *fp;			
-			
-		protected:
-		
+			ShaderProgram *vertexProgram;
+			ShaderProgram *fragmentProgram;
 		
 		
 			String name;
 			String name;
-			int type;
 	};
 	};
 	
 	
 	class _PolyExport ShaderRenderTarget : public PolyBase {
 	class _PolyExport ShaderRenderTarget : public PolyBase {

+ 1 - 8
Core/Contents/Include/PolyTexture.h

@@ -30,12 +30,9 @@ namespace Polycode {
 
 
 	class _PolyExport Texture : public Resource {
 	class _PolyExport Texture : public Resource {
 		public:
 		public:
-		Texture(unsigned int width, unsigned int height, char *textureData,bool clamp, bool createMipmaps, int type=Image::IMAGE_RGBA);
+            Texture(unsigned int width, unsigned int height, char *textureData,bool clamp, bool createMipmaps, int type=Image::IMAGE_RGBA);
 			Texture(Image *image);
 			Texture(Image *image);
 			virtual ~Texture();
 			virtual ~Texture();
-
-			Number scrollSpeedX;
-			Number scrollSpeedY;
 			
 			
 			void reloadResource();
 			void reloadResource();
 			
 			
@@ -50,8 +47,6 @@ namespace Polycode {
 		
 		
 			bool clamp;
 			bool clamp;
 			char *textureData;
 			char *textureData;
-        
-            void *platformData;
             int type;
             int type;
         
         
 		protected:
 		protected:
@@ -62,7 +57,5 @@ namespace Polycode {
 			bool createMipmaps;
 			bool createMipmaps;
 			int width;
 			int width;
 			int height;
 			int height;
-			Number scrollOffsetX;
-			Number scrollOffsetY;
 	};
 	};
 }
 }

+ 0 - 1
Core/Contents/Include/Polycode.h

@@ -60,7 +60,6 @@
 #include "PolyMesh.h"
 #include "PolyMesh.h"
 #include "PolyTextMesh.h"
 #include "PolyTextMesh.h"
 #include "PolyShader.h"
 #include "PolyShader.h"
-#include "PolyFixedShader.h"
 #include "PolySceneManager.h"
 #include "PolySceneManager.h"
 #include "PolyCoreServices.h"
 #include "PolyCoreServices.h"
 #include "PolyCamera.h"
 #include "PolyCamera.h"

+ 0 - 56
Core/Contents/Source/PolyFixedShader.cpp

@@ -1,56 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "PolyFixedShader.h"
-
-using namespace Polycode;
-
-FixedShaderBinding::FixedShaderBinding(FixedShader *shader) : ShaderBinding(shader) {
-	fixedShader = shader;
-}
-
-FixedShaderBinding::~FixedShaderBinding() {
-
-}
-
-
-void FixedShaderBinding::addCubemap(const String& name, Cubemap *cubemap) {
-	cubemaps.push_back(cubemap);
-}
-
-void FixedShaderBinding::addTexture(const String& name, Texture *texture) {
-	textures.push_back(texture);
-}
-
-Texture *FixedShaderBinding::getDiffuseTexture() {
-	return textures[0];
-}
-
-FixedShader::FixedShader() : Shader(Shader::FIXED_SHADER) {
-}
-
-FixedShader::~FixedShader() {
-}
-
-ShaderBinding *FixedShader::createBinding() {
-	return new FixedShaderBinding(this);
-}

+ 55 - 35
Core/Contents/Source/PolyMaterialManager.cpp

@@ -26,7 +26,7 @@
 #include "PolyMaterial.h"
 #include "PolyMaterial.h"
 #include "PolyRenderer.h"
 #include "PolyRenderer.h"
 #include "PolyResourceManager.h"
 #include "PolyResourceManager.h"
-#include "PolyFixedShader.h"
+#include "PolyTexture.h"
 
 
 #include "tinyxml.h"
 #include "tinyxml.h"
 
 
@@ -99,23 +99,8 @@ void MaterialManager::loadMaterialLibraryIntoPool(ResourcePool *pool, const Stri
 }
 }
 
 
 ShaderProgram *MaterialManager::createProgramFromFile(String programPath) {
 ShaderProgram *MaterialManager::createProgramFromFile(String programPath) {
-	OSFileEntry entry(programPath, OSFileEntry::TYPE_FILE);
-
-    // RENDERER_TODO
-    /*
-	for(int m=0; m < shaderModules.size(); m++) {
-		PolycodeShaderModule *shaderModule = shaderModules[m];
-		if(shaderModule->acceptsExtension(entry.extension)) {
-			ShaderProgram *newProgram = shaderModule->createProgramFromFile(entry.extension, entry.fullPath);
-			if(newProgram) {
-				newProgram->setResourcePath(programPath);
-				newProgram->setResourceName(programPath);
-			}
-			return newProgram;
-		}
-	}
-     */
-	return NULL;
+    ShaderProgram *program = Services()->getRenderer()->createProgram(programPath);
+    return program;
 }
 }
 
 
 #define DEFAULT_TEXTURE "default/default.png"
 #define DEFAULT_TEXTURE "default/default.png"
@@ -208,8 +193,15 @@ Shader *MaterialManager::getShaderByIndex(unsigned int index) {
 
 
 Shader *MaterialManager::createShader(ResourcePool *resourcePool, String shaderType, String name, String vpName, String fpName, bool screenShader) {
 Shader *MaterialManager::createShader(ResourcePool *resourcePool, String shaderType, String name, String vpName, String fpName, bool screenShader) {
 	Shader *retShader = NULL;
 	Shader *retShader = NULL;
-	
-    // RENDERER_TODO
+    
+    ShaderProgram *vertexProgram = (ShaderProgram*)resourcePool->getResourceByPath(vpName);
+    ShaderProgram *fragmentProgram = (ShaderProgram*)resourcePool->getResourceByPath(fpName);
+    
+    if(vertexProgram != NULL && fragmentProgram != NULL) {
+        retShader = Services()->getRenderer()->createShader(vertexProgram, fragmentProgram);
+        retShader->setName(name);
+        shaders.push_back(retShader);
+    }
 	
 	
 	if(retShader) {
 	if(retShader) {
 		retShader->screenShader = screenShader;
 		retShader->screenShader = screenShader;
@@ -226,8 +218,47 @@ Shader *MaterialManager::createShaderFromXMLNode(ResourcePool *resourcePool, TiX
 	if (!nodeElement) return NULL; // Skip comment nodes
 	if (!nodeElement) return NULL; // Skip comment nodes
 	
 	
 	Shader *retShader = NULL;
 	Shader *retShader = NULL;
-	
-    // RENDERER_TODO
+    TiXmlNode* pChild;
+    ShaderProgram *vp = NULL;
+    ShaderProgram *fp = NULL;
+    
+    for (pChild = node->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
+        TiXmlElement *pChildElement = pChild->ToElement();
+        if (!pChildElement) continue; // Skip comment nodes
+        
+        if(strcmp(pChild->Value(), "vp") == 0) {
+            String vpFileName = String(pChildElement->Attribute("source"));
+            vp = (ShaderProgram*)resourcePool->getResourceByPath(vpFileName);
+            if(!vp) {
+                vp = (ShaderProgram*)CoreServices::getInstance()->getMaterialManager()->createProgramFromFile(vpFileName);
+                if(vp) {
+                    vp->setResourcePath(vpFileName);
+                    OSFileEntry entry = OSFileEntry(vpFileName, OSFileEntry::TYPE_FILE);
+                    vp->setResourceName(entry.name);
+                    resourcePool->addResource(vp);
+                }
+            }
+        }
+        if(strcmp(pChild->Value(), "fp") == 0) {
+            String fpFileName = String(pChildElement->Attribute("source"));
+            fp = (ShaderProgram*)resourcePool->getResourceByPath(fpFileName);
+            if(!fp) {
+                fp = (ShaderProgram*)CoreServices::getInstance()->getMaterialManager()->createProgramFromFile(fpFileName);
+                if(fp) {
+                    fp->setResourcePath(fpFileName);
+                    OSFileEntry entry = OSFileEntry(fpFileName, OSFileEntry::TYPE_FILE);
+                    fp->setResourceName(entry.name);
+                    resourcePool->addResource(fp);				
+                }
+            }			
+        }
+        
+    }
+    if(vp != NULL && fp != NULL) {
+        retShader = Services()->getRenderer()->createShader(vp, fp);
+        retShader->setName(String(nodeElement->Attribute("name")));
+        shaders.push_back(retShader);
+    }
 	
 	
 	if (!retShader)
 	if (!retShader)
 		return NULL;
 		return NULL;
@@ -260,19 +291,8 @@ Shader *MaterialManager::createShaderFromXMLNode(ResourcePool *resourcePool, TiX
 
 
 Shader *MaterialManager::setShaderFromXMLNode(ResourcePool *resourcePool, TiXmlNode *node) {
 Shader *MaterialManager::setShaderFromXMLNode(ResourcePool *resourcePool, TiXmlNode *node) {
 	TiXmlElement *nodeElement = node->ToElement();
 	TiXmlElement *nodeElement = node->ToElement();
-	if (!nodeElement) return NULL; // Skip comment nodes
-	
-	Shader *retShader = NULL;
-	if(nodeElement->Attribute("type")) {
-		String shaderType = nodeElement->Attribute("type");
-		if(shaderType == "fixed") {
-			FixedShader *fShader =  new FixedShader();		
-			retShader = fShader;
-		}
-	} else {
-		retShader = (Shader*)resourcePool->getResource(Resource::RESOURCE_SHADER, nodeElement->Attribute("name"));
-	}
-	return retShader;
+	if (!nodeElement) return NULL; // Skip comment nodes	
+	return (Shader*)resourcePool->getResource(Resource::RESOURCE_SHADER, nodeElement->Attribute("name"));;
 }
 }
 
 
 Cubemap *MaterialManager::cubemapFromXMLNode(TiXmlNode *node) {
 Cubemap *MaterialManager::cubemapFromXMLNode(TiXmlNode *node) {

+ 16 - 16
Core/Contents/Source/PolyMesh.cpp

@@ -33,14 +33,14 @@ using std::vector;
 using namespace Polycode;
 using namespace Polycode;
 
 
 Mesh::Mesh(const String& fileName)
 Mesh::Mesh(const String& fileName)
-: vertexPositionArray(RenderDataArray::VERTEX_DATA_ARRAY),
-vertexColorArray(RenderDataArray::COLOR_DATA_ARRAY),
-vertexNormalArray(RenderDataArray::NORMAL_DATA_ARRAY),
-vertexTexCoordArray(RenderDataArray::TEXCOORD_DATA_ARRAY),
-vertexTexCoord2Array(RenderDataArray::TEXCOORD2_DATA_ARRAY),
-vertexTangentArray(RenderDataArray::TANGENT_DATA_ARRAY),
-vertexBoneWeightArray(RenderDataArray::BONE_WEIGHT_DATA_ARRAY),
-vertexBoneIndexArray(RenderDataArray::BONE_INDEX_DATA_ARRAY),
+: vertexPositionArray(3, RenderDataArray::VERTEX_DATA_ARRAY),
+vertexColorArray(4, RenderDataArray::COLOR_DATA_ARRAY),
+vertexNormalArray(3, RenderDataArray::NORMAL_DATA_ARRAY),
+vertexTexCoordArray(2, RenderDataArray::TEXCOORD_DATA_ARRAY),
+vertexTexCoord2Array(2, RenderDataArray::TEXCOORD2_DATA_ARRAY),
+vertexTangentArray(3, RenderDataArray::TANGENT_DATA_ARRAY),
+vertexBoneWeightArray(4, RenderDataArray::BONE_WEIGHT_DATA_ARRAY),
+vertexBoneIndexArray(4, RenderDataArray::BONE_INDEX_DATA_ARRAY),
 indexArray(RenderDataArray::INDEX_DATA_ARRAY)
 indexArray(RenderDataArray::INDEX_DATA_ARRAY)
 {
 {
 
 
@@ -53,14 +53,14 @@ indexArray(RenderDataArray::INDEX_DATA_ARRAY)
 }
 }
 
 
 Mesh::Mesh(int meshType)
 Mesh::Mesh(int meshType)
-: vertexPositionArray(RenderDataArray::VERTEX_DATA_ARRAY),
-vertexColorArray(RenderDataArray::COLOR_DATA_ARRAY),
-vertexNormalArray(RenderDataArray::NORMAL_DATA_ARRAY),
-vertexTexCoordArray(RenderDataArray::TEXCOORD_DATA_ARRAY),
-vertexTexCoord2Array(RenderDataArray::TEXCOORD2_DATA_ARRAY),
-vertexTangentArray(RenderDataArray::TANGENT_DATA_ARRAY),
-vertexBoneWeightArray(RenderDataArray::BONE_WEIGHT_DATA_ARRAY),
-vertexBoneIndexArray(RenderDataArray::BONE_INDEX_DATA_ARRAY),
+: vertexPositionArray(3, RenderDataArray::VERTEX_DATA_ARRAY),
+vertexColorArray(4, RenderDataArray::COLOR_DATA_ARRAY),
+vertexNormalArray(3, RenderDataArray::NORMAL_DATA_ARRAY),
+vertexTexCoordArray(2, RenderDataArray::TEXCOORD_DATA_ARRAY),
+vertexTexCoord2Array(2, RenderDataArray::TEXCOORD2_DATA_ARRAY),
+vertexTangentArray(3, RenderDataArray::TANGENT_DATA_ARRAY),
+vertexBoneWeightArray(4, RenderDataArray::BONE_WEIGHT_DATA_ARRAY),
+vertexBoneIndexArray(4, RenderDataArray::BONE_INDEX_DATA_ARRAY),
 indexArray(RenderDataArray::INDEX_DATA_ARRAY)
 indexArray(RenderDataArray::INDEX_DATA_ARRAY)
 {
 {
 
 

+ 292 - 3
Core/Contents/Source/PolyOpenGLGraphicsInterface.cpp

@@ -22,8 +22,9 @@
  */
  */
 
 
 #include "PolyOpenGLGraphicsInterface.h"
 #include "PolyOpenGLGraphicsInterface.h"
-
-
+#include "OSBasics.h"
+#include "PolyLogger.h"
+#include "PolyCoreServices.h"
 
 
 using namespace Polycode;
 using namespace Polycode;
 
 
@@ -35,7 +36,80 @@ OpenGLGraphicsInterface::~OpenGLGraphicsInterface() {
     
     
 }
 }
 
 
-void OpenGLGraphicsInterface::executeDrawCall(const GPUDrawCall& drawCall) {
+void OpenGLGraphicsInterface::setUniformMatrix(GLint paramLocation, const Polycode::Matrix4& matrix) {
+#ifdef POLYCODE_NUMBER_IS_SINGLE
+    glUniformMatrix4fv(paramLocation, 1, false, matrix.ml);
+#else
+    // no glUniformMatrix4dv on some systems
+    float copyMatrix[16];
+    for(int i=0; i < 16; i++) {
+        copyMatrix[i] = matrix.ml[i];
+    }
+    glUniformMatrix4fv(paramLocation, 1, false, copyMatrix);
+#endif
+}
+
+void OpenGLGraphicsInterface::setParamInShader(Shader *shader, const ProgramParam &param, LocalShaderParam *localParam) {
+
+    // TODO: ALSO DO NOT LOOK UP BY STRING!
+    
+    GLuint shaderID = *((GLuint*) shader->platformData);
+    int paramLocation = glGetUniformLocation(shaderID, param.name.c_str());
+    
+    switch(param.type) {
+        case ProgramParam::PARAM_NUMBER:
+            if(localParam) {
+                glUniform1f(paramLocation, localParam->getNumber());
+            } else {
+                glUniform1f(paramLocation, 0.0f);
+            }
+            break;
+        case ProgramParam::PARAM_VECTOR2:
+            if(localParam) {
+                Vector2 vec2 = localParam->getVector2();
+                glUniform2f(paramLocation, vec2.x, vec2.y);
+            } else {
+                glUniform2f(paramLocation, 0.0f, 0.0f);
+            }
+            break;
+        case ProgramParam::PARAM_VECTOR3:
+            if(localParam) {
+                Vector3 vec3 = localParam->getVector3();
+                glUniform3f(paramLocation, vec3.x, vec3.y, vec3.z);
+            } else {
+                glUniform3f(paramLocation, 0.0f, 0.0f, 0.0f);
+            }
+            break;
+        case ProgramParam::PARAM_COLOR:
+            if(localParam) {
+                Color color = localParam->getColor();
+                glUniform4f(paramLocation, color.r, color.g, color.b, color.a);
+            } else {
+                glUniform4f(paramLocation, 0.0f, 0.0f, 0.0f, 0.0f);
+            }
+            break;
+        case ProgramParam::PARAM_MATRIX:
+            if(localParam) {
+                if(localParam->arraySize > 0) {
+                    Matrix4 *matPointer = (Matrix4*)localParam->data;
+                    std::vector<float> matrixData;
+                    for(int i=0; i < localParam->arraySize; i++) {
+                        for(int j=0; j < 16; j++) {
+                            matrixData.push_back(matPointer[i].ml[j]);
+                        }
+                    }
+                    
+                    glUniformMatrix4fv(paramLocation, localParam->arraySize, false, &matrixData[0]);
+                    
+                } else {
+                    setUniformMatrix(paramLocation, localParam->getMatrix4());
+                }
+            } else {
+                Matrix4 defaultMatrix;
+                setUniformMatrix(paramLocation, defaultMatrix);
+            }
+            break;
+    }
     
     
 }
 }
 
 
@@ -115,6 +189,141 @@ void OpenGLGraphicsInterface::setViewport(unsigned int x,unsigned  int y,unsigne
     glViewport(x, y, width, height);
     glViewport(x, y, width, height);
 }
 }
 
 
+void OpenGLGraphicsInterface::createProgram(ShaderProgram *program) {
+
+    if(!program->platformData) {
+        program->platformData = (void*) new GLuint;
+    }
+
+    GLuint programID = *((GLuint*)program->platformData);
+    if(programID != 0) {
+        glDeleteShader(programID);
+    }
+    
+    OSFILE *file = OSBasics::open(program->getResourcePath(), "rb");
+    if (!file) {
+        Logger::log("Error: shader file %s not found\n", program->getResourcePath().c_str());
+        *((GLuint*)program->platformData) = -1;
+        return;
+    }
+    
+    OSBasics::seek(file, 0, SEEK_END);
+    long progsize = OSBasics::tell(file);
+    OSBasics::seek(file, 0, SEEK_SET);
+    char *buffer = (char*)malloc(progsize+1);
+    memset(buffer, 0, progsize+1);
+    OSBasics::read(buffer, progsize, 1, file);
+    OSBasics::close(file);
+    
+    if( program->type == ShaderProgram::TYPE_VERT) {
+        programID = glCreateShader(GL_VERTEX_SHADER);
+    } else {
+        programID = glCreateShader(GL_FRAGMENT_SHADER);
+    }
+    
+    glShaderSource(programID, 1, (const GLchar**)&buffer, 0);
+    glCompileShader(programID);
+    
+    GLint compiled = true;
+    glGetShaderiv(programID, GL_COMPILE_STATUS, &compiled);
+    
+    if(!compiled) {
+        GLint length;
+        GLchar* log;
+        glGetShaderiv(programID, GL_INFO_LOG_LENGTH, &length);
+        
+        log = (GLchar*)malloc(length);
+        glGetShaderInfoLog(programID, length, &length, log);
+        
+        Services()->getLogger()->logBroadcast("["+program->getResourcePath()+"] GLSL ERROR:" + String(log));
+        free(log);
+    }	
+    free(buffer);
+    
+    *((GLuint*)program->platformData) = programID;
+}
+
+void OpenGLGraphicsInterface::createShader(Shader *shader) {
+    
+    shader->expectedParams.clear();
+    shader->expectedTextures.clear();
+    shader->expectedCubemaps.clear();
+    shader->expectedAttributes.clear();
+    
+    if(!shader->platformData) {
+        shader->platformData = (void*) new GLuint;
+    }
+    
+    GLuint shaderID = *((GLuint*)shader->platformData);
+    
+    if(shaderID != 0) {
+        glDetachShader(shaderID, *((GLuint*)shader->fragmentProgram->platformData));
+        glDetachShader(shaderID, *((GLuint*)shader->vertexProgram->platformData));
+        glDeleteProgram(shaderID);
+    }
+    
+    shaderID = glCreateProgram();
+    
+    glAttachShader(shaderID, *((GLuint*)shader->fragmentProgram->platformData));
+    glAttachShader(shaderID, *((GLuint*)shader->vertexProgram->platformData));
+    glLinkProgram(shaderID);
+
+
+    GLint result;
+    glGetProgramiv( shaderID, GL_LINK_STATUS, &result);
+    
+    if(result == GL_INVALID_VALUE || result == GL_INVALID_OPERATION) {
+        Services()->getLogger()->logBroadcast("ERROR: Error linking shader. Invalid shader program.");
+    }
+
+    int total = -1;
+    glGetProgramiv( shaderID, GL_ACTIVE_UNIFORMS, &total );
+    for(int i=0; i < total; i++)  {
+        int name_len=-1, num=-1;
+        GLenum type = GL_ZERO;
+        char name[128];
+        glGetActiveUniform(shaderID, GLuint(i), sizeof(name)-1, &name_len, &num, &type, name );
+        name[name_len] = 0;
+        
+        switch(type) {
+            case GL_SAMPLER_2D:
+                shader->expectedTextures.push_back(String(name));
+                break;
+            case GL_SAMPLER_CUBE:
+                shader->expectedCubemaps.push_back(String(name));
+                break;
+            default:
+                ProgramParam param;
+                param.name = String(name);
+                param.type = getPolycodeParamType(type);
+                shader->expectedParams.push_back(param);
+            break;
+        }
+    }
+    
+    total = -1;
+    glGetProgramiv( shaderID, GL_ACTIVE_ATTRIBUTES, &total );
+    
+    for(GLuint i=0; i < total; i++)  {
+        
+        int name_len=-1, num=-1;
+        GLenum type = GL_ZERO;
+        char name[128];
+        
+        glGetActiveAttrib(shaderID, i, sizeof(name)-1, &name_len, &num, &type, name);
+        name[name_len] = 0;
+
+        ProgramAttribute attribute;
+        attribute.name = String(name);
+        attribute.size = getAttributeSize(type);
+        shader->expectedAttributes.push_back(attribute);
+    }
+    
+    
+     *((GLuint*)shader->platformData) = shaderID;
+    
+}
+
 void OpenGLGraphicsInterface::clearBuffers(bool colorBuffer, bool depthBuffer, bool stencilBuffer) {
 void OpenGLGraphicsInterface::clearBuffers(bool colorBuffer, bool depthBuffer, bool stencilBuffer) {
     GLbitfield clearMask = 0;
     GLbitfield clearMask = 0;
     
     
@@ -132,4 +341,84 @@ void OpenGLGraphicsInterface::clearBuffers(bool colorBuffer, bool depthBuffer, b
     
     
     
     
     glClear(clearMask);
     glClear(clearMask);
+}
+
+int OpenGLGraphicsInterface::getAttributeSize(int glType) {
+    switch(glType) {
+        case GL_FLOAT:
+            return 1;
+        break;
+        case GL_FLOAT_VEC2:
+            return 2;
+        break;
+        case GL_FLOAT_VEC3:
+            return 3;
+        break;
+        case GL_FLOAT_VEC4:
+            return 4;
+        break;
+        case GL_FLOAT_MAT2:
+            return 4;
+        break;
+        case GL_FLOAT_MAT3:
+            return 9;
+        break;
+        case GL_FLOAT_MAT4:
+            return 16;
+        break;
+    }
+    return 0;
+}
+
+int OpenGLGraphicsInterface::getPolycodeParamType(int glType) {
+    switch(glType) {
+        case GL_FLOAT:
+            return ProgramParam::PARAM_NUMBER;
+            break;
+        case GL_FLOAT_VEC2:
+            return ProgramParam::PARAM_VECTOR2;
+            break;
+        case GL_FLOAT_VEC3:
+            return ProgramParam::PARAM_VECTOR3;
+            break;
+        case GL_FLOAT_VEC4:
+            return ProgramParam::PARAM_COLOR;
+            break;
+        case GL_INT:
+            return ProgramParam::PARAM_NUMBER;
+            break;
+        case GL_INT_VEC2:
+            return ProgramParam::PARAM_VECTOR2;
+            break;
+        case GL_INT_VEC3:
+            return ProgramParam::PARAM_VECTOR3;
+            break;
+        case GL_INT_VEC4:
+            return ProgramParam::PARAM_COLOR;
+            break;
+        case GL_BOOL:
+            return ProgramParam::PARAM_NUMBER;
+            break;
+        case GL_BOOL_VEC2:
+            return ProgramParam::PARAM_VECTOR2;
+            break;
+        case GL_BOOL_VEC3:
+            return ProgramParam::PARAM_VECTOR3;
+            break;
+        case GL_BOOL_VEC4:
+            return ProgramParam::PARAM_COLOR;
+            break;
+        case GL_FLOAT_MAT2:
+            return ProgramParam::PARAM_MATRIX;
+            break;
+        case GL_FLOAT_MAT3:
+            return ProgramParam::PARAM_MATRIX;		
+            break;
+        case GL_FLOAT_MAT4:
+            return ProgramParam::PARAM_MATRIX;		
+            break;
+        default:
+            return ProgramParam::PARAM_UNKNOWN;
+            break;
+    }
 }
 }

+ 2 - 2
Core/Contents/Source/PolyParticleEmitter.cpp

@@ -497,10 +497,10 @@ void SceneParticleEmitter::updateParticles() {
     setLocalBoundingBox((newBBox + Vector3(particleSize, particleSize, particleSize))* 2.0);
     setLocalBoundingBox((newBBox + Vector3(particleSize, particleSize, particleSize))* 2.0);
 }
 }
 
 
-void SceneParticleEmitter::Render() {
+void SceneParticleEmitter::Render(GPUDrawBuffer *buffer) {
     systemTrasnformMatrix = getConcatenatedMatrix();
     systemTrasnformMatrix = getConcatenatedMatrix();
     rebuildParticles();
     rebuildParticles();
-    SceneMesh::Render();
+    SceneMesh::Render(buffer);
 }
 }
 
 
 void SceneParticleEmitter::fixedUpdate() {
 void SceneParticleEmitter::fixedUpdate() {

+ 4 - 0
Core/Contents/Source/PolyRenderDataArray.cpp

@@ -52,3 +52,7 @@ void *IndexDataArray::getArrayData() {
 unsigned int IndexDataArray::getDataSize() {
 unsigned int IndexDataArray::getDataSize() {
     return data.size();
     return data.size();
 }
 }
+
+unsigned char VertexDataArray::getCountPerVertex() {
+    return countPerVertex;
+}

+ 91 - 3
Core/Contents/Source/PolyRenderer.cpp

@@ -36,7 +36,6 @@ GPUDrawBuffer::~GPUDrawBuffer() {
     
     
 }
 }
 
 
-
 GraphicsInterface::GraphicsInterface() {
 GraphicsInterface::GraphicsInterface() {
 }
 }
 
 
@@ -61,6 +60,61 @@ void RenderThread::runThread() {
     }
     }
 }
 }
 
 
+void RenderThread::processDrawBuffer(GPUDrawBuffer *buffer) {
+    interface->setViewport(buffer->viewport.x, buffer->viewport.y, buffer->viewport.w, buffer->viewport.h);
+    interface->clearBuffers(true, true, true);
+    
+    for(int i=0; i < buffer->drawCalls.size(); i++) {
+        if(buffer->drawCalls[i].material) {
+            
+            ShaderBinding *localShaderBinding = buffer->drawCalls[i].shaderBinding;
+            
+            for(int s=0; s < buffer->drawCalls[i].material->getNumShaders(); s++) {
+                
+                Shader *shader = buffer->drawCalls[i].material->getShader(s);
+                ShaderBinding *materialShaderBinding = buffer->drawCalls[i].material->getShaderBinding(s);
+
+                
+             
+                
+                // !!!!!!!!!!!!!!!!!!!!!!!!
+                // TODO: Don't do string lookups on every frame for all this stuff, find a better way!!
+                // !!!!!!!!!!!!!!!!!!!!!!!!
+                
+                // set shader uniforms
+                
+                for(int p=0; p < shader->expectedParams.size(); p++) {
+                    ProgramParam param = shader->expectedParams[p];
+
+                    LocalShaderParam *localParam = NULL;
+                    localParam = materialShaderBinding->getLocalParamByName(param.name);
+                    
+                    // local options override material options
+                    
+                    LocalShaderParam *localOptionsParam = localShaderBinding->getLocalParamByName(param.name);
+                    if(localOptionsParam) {
+                        localParam = localOptionsParam;
+                    }
+                    
+                    interface->setParamInShader(shader, param, localParam);
+                }
+                
+                 for(int a=0; a < shader->expectedAttributes.size(); a++) {
+                     ProgramAttribute attribute = shader->expectedAttributes[a];
+
+                 }
+                
+                // set shader attributes
+                
+//                glVertexAttribPointer(texCoordAttribute, 2, GL_FLOAT, false, 0, uvs);
+  //              glEnableVertexAttribArray(texCoordAttribute);
+                
+                // render with shader
+            }
+        }
+    }
+}
+
 void RenderThread::processJob(const RendererThreadJob &job) {
 void RenderThread::processJob(const RendererThreadJob &job) {
     switch(job.jobType) {
     switch(job.jobType) {
         case JOB_REQUEST_CONTEXT_CHANGE:
         case JOB_REQUEST_CONTEXT_CHANGE:
@@ -79,8 +133,7 @@ void RenderThread::processJob(const RendererThreadJob &job) {
         case JOB_PROCESS_DRAW_BUFFER:
         case JOB_PROCESS_DRAW_BUFFER:
         {
         {
             GPUDrawBuffer *buffer = (GPUDrawBuffer*) job.data;
             GPUDrawBuffer *buffer = (GPUDrawBuffer*) job.data;
-            interface->setViewport(buffer->viewport.x, buffer->viewport.y, buffer->viewport.w, buffer->viewport.h);
-            interface->clearBuffers(true, true, true);
+            processDrawBuffer(buffer);
             delete buffer;
             delete buffer;
         }
         }
         break;
         break;
@@ -89,6 +142,18 @@ void RenderThread::processJob(const RendererThreadJob &job) {
             core->flushRenderContext();
             core->flushRenderContext();
         }
         }
         break;
         break;
+        case JOB_CREATE_PROGRAM:
+        {
+            ShaderProgram *program = (ShaderProgram*) job.data;
+            interface->createProgram(program);
+        }
+        break;
+        case JOB_CREATE_SHADER:
+        {
+            Shader *shader = (Shader*) job.data;
+            interface->createShader(shader);
+        }
+        break;
     }
     }
 }
 }
 
 
@@ -165,6 +230,29 @@ Texture *Renderer::createTexture(unsigned int width, unsigned int height, char *
     return texture;
     return texture;
 }
 }
 
 
+Shader *Renderer::createShader(ShaderProgram *vertexProgram, ShaderProgram *fragmentProgram) {
+    Shader *shader = new Shader();
+    shader->vertexProgram = vertexProgram;
+    shader->fragmentProgram = fragmentProgram;
+    renderThread->enqueueJob(RenderThread::JOB_CREATE_SHADER, (void*)shader);
+    return shader;
+}
+
+ShaderProgram *Renderer::createProgram(const String &fileName) {
+    ShaderProgram *program = new ShaderProgram(fileName);
+    
+    OSFileEntry fileEntry(program->getResourcePath(), OSFileEntry::TYPE_FILE);
+    
+    if(fileEntry.extension == "vert" ) {
+        program->type = ShaderProgram::TYPE_VERT;
+    } else {
+        program->type = ShaderProgram::TYPE_FRAG;
+    }
+    
+    renderThread->enqueueJob(RenderThread::JOB_CREATE_PROGRAM, (void*)program);
+    return program;
+}
+
 void Renderer::destroyTexture(Texture *texture) {
 void Renderer::destroyTexture(Texture *texture) {
     
     
 }
 }

+ 1 - 0
Core/Contents/Source/PolyResource.cpp

@@ -32,6 +32,7 @@ Resource::Resource(int type) : EventDispatcher() {
 	this->type = type;
 	this->type = type;
 	reloadOnFileModify = defaultReloadOnFileModify;
 	reloadOnFileModify = defaultReloadOnFileModify;
 	resourceFileTime = 0;
 	resourceFileTime = 0;
+    platformData = NULL;
 }
 }
 
 
 Resource::~Resource() {
 Resource::~Resource() {

+ 9 - 7
Core/Contents/Source/PolyResourceManager.cpp

@@ -253,13 +253,15 @@ void ResourceManager::parseProgramsIntoPool(ResourcePool *pool, const String& di
 	for(int i=0; i < resourceDir.size(); i++) {	
 	for(int i=0; i < resourceDir.size(); i++) {	
 		if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
 		if(resourceDir[i].type == OSFileEntry::TYPE_FILE) {
 			MaterialManager *materialManager = CoreServices::getInstance()->getMaterialManager();
 			MaterialManager *materialManager = CoreServices::getInstance()->getMaterialManager();
-			
-			ShaderProgram *newProgram = materialManager->createProgramFromFile(resourceDir[i].fullPath);
-			if(newProgram) {
-				newProgram->setResourceName(resourceDir[i].name);
-				newProgram->setResourcePath(resourceDir[i].fullPath);
-				pool->addResource(newProgram);
-			}			
+            
+            if(resourceDir[i].extension == "vert" || resourceDir[i].extension == "frag") {
+                ShaderProgram *newProgram = materialManager->createProgramFromFile(resourceDir[i].fullPath);
+                if(newProgram) {
+                    newProgram->setResourceName(resourceDir[i].name);
+                    newProgram->setResourcePath(resourceDir[i].fullPath);
+                    pool->addResource(newProgram);
+                }
+            }
 		} else {
 		} else {
 			if(recursive)
 			if(recursive)
 				parseProgramsIntoPool(pool, dirPath+"/"+resourceDir[i].name, true);
 				parseProgramsIntoPool(pool, dirPath+"/"+resourceDir[i].name, true);

+ 4 - 3
Core/Contents/Source/PolySceneMesh.cpp

@@ -43,7 +43,7 @@ SceneMesh *SceneMesh::SceneMeshWithType(int meshType) {
 	return new SceneMesh(meshType);
 	return new SceneMesh(meshType);
 }
 }
 
 
-SceneMesh::SceneMesh(const String& fileName) : Entity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), mesh(NULL), skeletalVertexPositions(RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(RenderDataArray::NORMAL_DATA_ARRAY) {
+SceneMesh::SceneMesh(const String& fileName) : Entity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), mesh(NULL), skeletalVertexPositions(3, RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(3, RenderDataArray::NORMAL_DATA_ARRAY) {
     loadFromFile(fileName);
     loadFromFile(fileName);
 	useVertexBuffer = false;
 	useVertexBuffer = false;
 	lineSmooth = false;
 	lineSmooth = false;
@@ -60,7 +60,7 @@ SceneMesh::SceneMesh(const String& fileName) : Entity(), texture(NULL), material
     sendBoneMatricesToMaterial = false;
     sendBoneMatricesToMaterial = false;
 }
 }
 
 
-SceneMesh::SceneMesh(Mesh *mesh) : Entity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), skeletalVertexPositions(RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(RenderDataArray::NORMAL_DATA_ARRAY) {
+SceneMesh::SceneMesh(Mesh *mesh) : Entity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), skeletalVertexPositions(3, RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(3, RenderDataArray::NORMAL_DATA_ARRAY) {
 	this->mesh = mesh;
 	this->mesh = mesh;
 	setLocalBoundingBox(mesh->calculateBBox());
 	setLocalBoundingBox(mesh->calculateBBox());
 	useVertexBuffer = false;
 	useVertexBuffer = false;
@@ -78,7 +78,7 @@ SceneMesh::SceneMesh(Mesh *mesh) : Entity(), texture(NULL), material(NULL), skel
     sendBoneMatricesToMaterial = false;
     sendBoneMatricesToMaterial = false;
 }
 }
 
 
-SceneMesh::SceneMesh(int meshType) : texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), skeletalVertexPositions(RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(RenderDataArray::NORMAL_DATA_ARRAY) {
+SceneMesh::SceneMesh(int meshType) : texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), skeletalVertexPositions(3, RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(3, RenderDataArray::NORMAL_DATA_ARRAY) {
 	mesh = new Mesh(meshType);
 	mesh = new Mesh(meshType);
 	setLocalBoundingBox(mesh->calculateBBox());
 	setLocalBoundingBox(mesh->calculateBBox());
 	useVertexBuffer = false;	
 	useVertexBuffer = false;	
@@ -361,6 +361,7 @@ void SceneMesh::Render(GPUDrawBuffer *buffer) {
     drawCall.attributeArrays.push_back(&mesh->vertexPositionArray);
     drawCall.attributeArrays.push_back(&mesh->vertexPositionArray);
     drawCall.numVertices = mesh->getVertexCount();
     drawCall.numVertices = mesh->getVertexCount();
     
     
+    
     /*
     /*
    	if(material) {
    	if(material) {
         
         

+ 6 - 6
Core/Contents/Source/PolyShader.cpp

@@ -67,8 +67,9 @@ void *ProgramParam::createParamData(int type) {
 	}
 	}
 }
 }
 
 
-ShaderProgram::ShaderProgram(int type) : Resource(Resource::RESOURCE_PROGRAM) {
-	this->type = type;
+ShaderProgram::ShaderProgram(const String &fileName) : Resource(Resource::RESOURCE_PROGRAM) {
+    setResourcePath(fileName);
+    setResourceName(fileName);
 }
 }
 
 
 ShaderProgram::~ShaderProgram() {
 ShaderProgram::~ShaderProgram() {
@@ -242,12 +243,11 @@ RenderTargetBinding *ShaderBinding::getDepthTargetBinding(unsigned int index) {
 }
 }
 
 
 
 
-Shader::Shader(int type) : Resource(Resource::RESOURCE_SHADER) {
+Shader::Shader() : Resource(Resource::RESOURCE_SHADER) {
 	numSpotLights = 0;
 	numSpotLights = 0;
 	numPointLights = 0;
 	numPointLights = 0;
-	this->type = type;
-	vp = NULL;
-	fp = NULL;
+	vertexProgram = NULL;
+	fragmentProgram = NULL;
 }
 }
 
 
 int Shader::getExpectedParamType(String name) {
 int Shader::getExpectedParamType(String name) {

+ 1 - 6
Core/Contents/Source/PolyTexture.cpp

@@ -53,12 +53,7 @@ Texture::Texture(unsigned int width, unsigned int height, char *textureData,bool
 		memcpy(this->textureData, textureData, width*height*pixelSize);	
 		memcpy(this->textureData, textureData, width*height*pixelSize);	
 	else
 	else
 		memset(this->textureData, 0, width*height*pixelSize);	
 		memset(this->textureData, 0, width*height*pixelSize);	
-	scrollSpeedX = 0;
-	scrollSpeedY = 0;
-	scrollOffsetX = 0;
-	scrollOffsetY = 0;
-    
-    platformData = NULL;
+
 }
 }
 
 
 void Texture::reloadResource() {
 void Texture::reloadResource() {