浏览代码

Improved shader system + cleaned up tests.

Mark Sibly 7 年之前
父节点
当前提交
f9d4ca2e4c
共有 87 个文件被更改,包括 1694 次插入7285 次删除
  1. 0 27
      modules/mojo3d/assets/shaders/copy.glsl
  2. 0 72
      modules/mojo3d/assets/shaders/effect-bloom.glsl
  3. 74 0
      modules/mojo3d/assets/shaders/effects/bloom.glsl
  4. 7 8
      modules/mojo3d/assets/shaders/effects/monochrome.glsl
  5. 147 0
      modules/mojo3d/assets/shaders/effects/reflection.glsl
  6. 0 60
      modules/mojo3d/assets/shaders/fog-deferred.glsl
  7. 192 0
      modules/mojo3d/assets/shaders/imports/pbr.glsl
  8. 344 0
      modules/mojo3d/assets/shaders/imports/std.glsl
  9. 0 223
      modules/mojo3d/assets/shaders/lighting-deferred.glsl
  10. 0 310
      modules/mojo3d/assets/shaders/material-pbr-deferred.glsl
  11. 0 449
      modules/mojo3d/assets/shaders/material-pbr-forward.glsl
  12. 0 75
      modules/mojo3d/assets/shaders/material-sprite.glsl
  13. 0 125
      modules/mojo3d/assets/shaders/material-water.glsl
  14. 6 41
      modules/mojo3d/assets/shaders/materials/particle.glsl
  15. 79 0
      modules/mojo3d/assets/shaders/materials/pbr-default.glsl
  16. 26 0
      modules/mojo3d/assets/shaders/materials/sprite.glsl
  17. 54 0
      modules/mojo3d/assets/shaders/materials/water.glsl
  18. 26 0
      modules/mojo3d/assets/shaders/misc/copy.glsl
  19. 35 0
      modules/mojo3d/assets/shaders/misc/fog-deferred.glsl
  20. 28 0
      modules/mojo3d/assets/shaders/misc/lighting-deferred.glsl
  21. 7 15
      modules/mojo3d/assets/shaders/misc/skybox.glsl
  22. 0 38
      modules/mojo3d/assets/shaders/skybox.glsl
  23. 7 2
      modules/mojo3d/loader/gltf2loader.monkey2
  24. 1 1
      modules/mojo3d/mojo3d.monkey2
  25. 116 67
      modules/mojo3d/render/renderer.monkey2
  26. 26 7
      modules/mojo3d/render/renderqueue.monkey2
  27. 6 0
      modules/mojo3d/render/spritebuffer.monkey2
  28. 26 1
      modules/mojo3d/scene/components/constraint.monkey2
  29. 6 58
      modules/mojo3d/scene/effects/bloomeffect.monkey2
  30. 0 78
      modules/mojo3d/scene/effects/fogeffect.monkey2
  31. 2 23
      modules/mojo3d/scene/effects/monochromeeffect.monkey2
  32. 32 0
      modules/mojo3d/scene/effects/reflectioneffect.monkey2
  33. 2 0
      modules/mojo3d/scene/entities/light.monkey2
  34. 4 19
      modules/mojo3d/scene/entities/particlematerial.monkey2
  35. 99 33
      modules/mojo3d/scene/material.monkey2
  36. 94 121
      modules/mojo3d/scene/materials/pbrmaterial.monkey2
  37. 2 32
      modules/mojo3d/scene/materials/spritematerial.monkey2
  38. 15 48
      modules/mojo3d/scene/materials/watermaterial.monkey2
  39. 19 22
      modules/mojo3d/scene/posteffect.monkey2
  40. 2 2
      modules/mojo3d/tests/alphacubes.monkey2
  41. 0 86
      modules/mojo3d/tests/anisotropic.monkey2
  42. 二进制
      modules/mojo3d/tests/assets/Monkey2logo_64.png
  43. 二进制
      modules/mojo3d/tests/assets/bluspark.png
  44. 二进制
      modules/mojo3d/tests/assets/bouncyball/bouncyball.bin
  45. 0 589
      modules/mojo3d/tests/assets/bouncyball/bouncyball.gltf
  46. 二进制
      modules/mojo3d/tests/assets/heightmap_256.BMP
  47. 0 1
      modules/mojo3d/tests/assets/mossy-ground1.pbr/About these PBR files.txt
  48. 二进制
      modules/mojo3d/tests/assets/mossy-ground1.pbr/color.png
  49. 二进制
      modules/mojo3d/tests/assets/mossy-ground1.pbr/height.png
  50. 二进制
      modules/mojo3d/tests/assets/mossy-ground1.pbr/metalness.png
  51. 二进制
      modules/mojo3d/tests/assets/mossy-ground1.pbr/normal.png
  52. 二进制
      modules/mojo3d/tests/assets/mossy-ground1.pbr/occlusion.png
  53. 二进制
      modules/mojo3d/tests/assets/mossy-ground1.pbr/roughness.png
  54. 二进制
      modules/mojo3d/tests/assets/mossy.pbr/color.png
  55. 二进制
      modules/mojo3d/tests/assets/mossy.pbr/normal.png
  56. 二进制
      modules/mojo3d/tests/assets/mossy.pbr/occlusion.png
  57. 二进制
      modules/mojo3d/tests/assets/platform.glb
  58. 二进制
      modules/mojo3d/tests/assets/terrain_256.png
  59. 二进制
      modules/mojo3d/tests/assets/walker/walk.bin
  60. 0 2470
      modules/mojo3d/tests/assets/walker/walk.gltf
  61. 二进制
      modules/mojo3d/tests/assets/water1.jpg
  62. 0 76
      modules/mojo3d/tests/bouncyball_gltf2.monkey2
  63. 0 324
      modules/mojo3d/tests/bouncyboxes.monkey2
  64. 0 103
      modules/mojo3d/tests/constraints.monkey2
  65. 0 88
      modules/mojo3d/tests/cubes.monkey2
  66. 0 94
      modules/mojo3d/tests/cubeseam.monkey2
  67. 0 78
      modules/mojo3d/tests/donut.monkey2
  68. 0 131
      modules/mojo3d/tests/ducks-scene.monkey2
  69. 5 4
      modules/mojo3d/tests/ducks.monkey2
  70. 12 5
      modules/mojo3d/tests/effects.monkey2
  71. 0 127
      modules/mojo3d/tests/fishes.monkey2
  72. 0 70
      modules/mojo3d/tests/glb_test.monkey2
  73. 0 100
      modules/mojo3d/tests/loadscene.monkey2
  74. 0 86
      modules/mojo3d/tests/makequad.monkey2
  75. 0 160
      modules/mojo3d/tests/morpher.monkey2
  76. 4 6
      modules/mojo3d/tests/particles.monkey2
  77. 3 2
      modules/mojo3d/tests/pbrspheres.monkey2
  78. 52 52
      modules/mojo3d/tests/room.monkey2
  79. 0 181
      modules/mojo3d/tests/shapes-scene.monkey2
  80. 0 110
      modules/mojo3d/tests/sprites-scene.monkey2
  81. 9 7
      modules/mojo3d/tests/sprites.monkey2
  82. 118 0
      modules/mojo3d/tests/terrain.monkey2
  83. 0 118
      modules/mojo3d/tests/terrainmesh.monkey2
  84. 0 84
      modules/mojo3d/tests/test-scene.monkey2
  85. 0 89
      modules/mojo3d/tests/test.monkey2
  86. 0 80
      modules/mojo3d/tests/walker_gltf2.monkey2
  87. 7 7
      modules/mojo3d/tests/water.monkey2

+ 0 - 27
modules/mojo3d/assets/shaders/copy.glsl

@@ -1,27 +0,0 @@
-
-//@renderpasses 0
-
-uniform sampler2D r_AccumBuffer;
-
-uniform vec2 r_BufferCoordScale;
-
-varying vec2 v_TexCoord0;
-
-//@vertex
-
-attribute vec2 a_Position;	//0...1 (1=viewport size)
-attribute vec2 a_TexCoord0;	//0...1 (1=viewport size)
-
-void main(){
-
-	v_TexCoord0=a_TexCoord0 * r_BufferCoordScale;
-
-	gl_Position=vec4( a_Position * 2.0 - 1.0,-1.0,1.0 );
-}
-
-//@fragment
-
-void main(){
-
-	gl_FragColor=vec4( pow( texture2D( r_AccumBuffer,v_TexCoord0 ).rgb,vec3( 1.0/2.2 ) ),1.0 );
-}

+ 0 - 72
modules/mojo3d/assets/shaders/effect-bloom.glsl

@@ -1,72 +0,0 @@
-
-//@renderpasses 0,1,2,3
-
-uniform sampler2D m_SourceTexture;
-uniform vec2 m_SourceTextureSize;
-uniform vec2 m_SourceTextureScale;
-
-varying vec2 v_TexCoord0;
-
-//@vertex
-
-attribute vec2 a_Position;	//0...1 (1=viewport size)
-
-void main(){
-
-	v_TexCoord0=a_Position * m_SourceTextureScale;
-
-	gl_Position=vec4( a_Position * 2.0 - 1.0,-1.0,1.0 );
-}
-
-//@fragment
-
-const float weight0=0.227027,weight1=0.1945946,weight2=0.1216216,weight3=0.054054,weight4=0.016216;
-
-//apparently the same if linear filter enabled in texture...
-//const float weight0=0.2270270270,weight1=0.3162162162,weight2=0.0702702703;
-
-void main(){
-
-#if MX2_RENDERPASS==3
-
-	vec3 result=texture2D( m_SourceTexture,v_TexCoord0 ).rgb;
-
-#else
-
-	vec2 texel_size=1.0/m_SourceTextureSize;
-	
-	vec3 result=texture2D( m_SourceTexture,v_TexCoord0 ).rgb*weight0;
-	
-#if MX2_RENDERPASS==0 || MX2_RENDERPASS==2
-
-	result+=texture2D(m_SourceTexture,v_TexCoord0+vec2(texel_size.x*1.0,0.0)).rgb * weight1;
-	result+=texture2D(m_SourceTexture,v_TexCoord0-vec2(texel_size.x*1.0,0.0)).rgb * weight1;
-	result+=texture2D(m_SourceTexture,v_TexCoord0+vec2(texel_size.x*2.0,0.0)).rgb * weight2;
-	result+=texture2D(m_SourceTexture,v_TexCoord0-vec2(texel_size.x*2.0,0.0)).rgb * weight2;
-	result+=texture2D(m_SourceTexture,v_TexCoord0+vec2(texel_size.x*3.0,0.0)).rgb * weight3;
-	result+=texture2D(m_SourceTexture,v_TexCoord0-vec2(texel_size.x*3.0,0.0)).rgb * weight3;
-	result+=texture2D(m_SourceTexture,v_TexCoord0+vec2(texel_size.x*4.0,0.0)).rgb * weight4;
-	result+=texture2D(m_SourceTexture,v_TexCoord0-vec2(texel_size.x*4.0,0.0)).rgb * weight4;
-	
-#elif MX2_RENDERPASS==1
-
-	result+=texture2D(m_SourceTexture,v_TexCoord0+vec2(0.0,texel_size.y*1.0)).rgb * weight1;
-	result+=texture2D(m_SourceTexture,v_TexCoord0-vec2(0.0,texel_size.y*1.0)).rgb * weight1;
-	result+=texture2D(m_SourceTexture,v_TexCoord0+vec2(0.0,texel_size.y*2.0)).rgb * weight2;
-	result+=texture2D(m_SourceTexture,v_TexCoord0-vec2(0.0,texel_size.y*2.0)).rgb * weight2;
-	result+=texture2D(m_SourceTexture,v_TexCoord0+vec2(0.0,texel_size.y*3.0)).rgb * weight3;
-	result+=texture2D(m_SourceTexture,v_TexCoord0-vec2(0.0,texel_size.y*3.0)).rgb * weight3;
-	result+=texture2D(m_SourceTexture,v_TexCoord0+vec2(0.0,texel_size.y*4.0)).rgb * weight4;
-	result+=texture2D(m_SourceTexture,v_TexCoord0-vec2(0.0,texel_size.y*4.0)).rgb * weight4;
-
-#endif
-
-#if MX2_RENDERPASS==0
-	result=max( result-1.0,0.0 );
-#endif
-
-#endif
-	
-	gl_FragColor=vec4( result,1.0 );
-	
-}

+ 74 - 0
modules/mojo3d/assets/shaders/effects/bloom.glsl

@@ -0,0 +1,74 @@
+
+//@renderpasses 0,1,2,3
+
+uniform sampler2D r_SourceBuffer;
+uniform vec2 r_SourceBufferSize;
+uniform vec2 r_SourceBufferScale;
+
+varying vec2 v_TexCoord0;
+
+//@vertex
+
+attribute vec2 a_Position;	//0...1 (1=viewport size)
+
+void main(){
+
+	v_TexCoord0=a_Position * r_SourceBufferScale;
+
+	gl_Position=vec4( a_Position * 2.0 - 1.0,-1.0,1.0 );
+}
+
+//@fragment
+
+const float weight0=0.227027,weight1=0.1945946,weight2=0.1216216,weight3=0.054054,weight4=0.016216;
+
+//apparently the same if linear filter enabled in texture...
+//const float weight0=0.2270270270,weight1=0.3162162162,weight2=0.0702702703;
+
+void main(){
+
+#if MX2_RENDERPASS==3
+
+	vec3 result=texture2D( r_SourceBuffer,v_TexCoord0 ).rgb;
+
+#else
+
+	vec2 texel_size=1.0/r_SourceBufferSize;
+	
+	vec3 result=texture2D( r_SourceBuffer,v_TexCoord0 ).rgb*weight0;
+	
+#if MX2_RENDERPASS==0 || MX2_RENDERPASS==2
+
+	result+=texture2D(r_SourceBuffer,v_TexCoord0+vec2(texel_size.x*1.0,0.0)).rgb * weight1;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0-vec2(texel_size.x*1.0,0.0)).rgb * weight1;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0+vec2(texel_size.x*2.0,0.0)).rgb * weight2;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0-vec2(texel_size.x*2.0,0.0)).rgb * weight2;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0+vec2(texel_size.x*3.0,0.0)).rgb * weight3;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0-vec2(texel_size.x*3.0,0.0)).rgb * weight3;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0+vec2(texel_size.x*4.0,0.0)).rgb * weight4;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0-vec2(texel_size.x*4.0,0.0)).rgb * weight4;
+	
+#elif MX2_RENDERPASS==1
+
+	result+=texture2D(r_SourceBuffer,v_TexCoord0+vec2(0.0,texel_size.y*1.0)).rgb * weight1;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0-vec2(0.0,texel_size.y*1.0)).rgb * weight1;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0+vec2(0.0,texel_size.y*2.0)).rgb * weight2;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0-vec2(0.0,texel_size.y*2.0)).rgb * weight2;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0+vec2(0.0,texel_size.y*3.0)).rgb * weight3;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0-vec2(0.0,texel_size.y*3.0)).rgb * weight3;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0+vec2(0.0,texel_size.y*4.0)).rgb * weight4;
+	result+=texture2D(r_SourceBuffer,v_TexCoord0-vec2(0.0,texel_size.y*4.0)).rgb * weight4;
+
+#endif
+
+#if MX2_RENDERPASS==0
+
+	result=max( result-1.0,0.0 );
+	
+#endif
+
+#endif
+	
+	gl_FragColor=vec4( result,1.0 );
+	
+}

+ 7 - 8
modules/mojo3d/assets/shaders/effect-monochrome.glsl → modules/mojo3d/assets/shaders/effects/monochrome.glsl

@@ -1,29 +1,28 @@
 //@renderpasses 0
 
-uniform vec2 m_SourceCoordScale;
+uniform sampler2D r_SourceBuffer;
+uniform vec2 r_SourceBufferScale;
 
-varying vec2 v_TexCoord0;
+varying vec2 v_SourceBufferCoords;
 
 //@vertex
 
-attribute vec2 a_Position;	//0...1 (1=viewport size)
-
+attribute vec2 a_Position;
+	
 void main(){
 
-	v_TexCoord0=a_Position * m_SourceCoordScale;
+	v_SourceBufferCoords=a_Position * r_SourceBufferScale;
 
 	gl_Position=vec4( a_Position * 2.0 - 1.0,-1.0,1.0 );
 }
 
 //@fragment
 
-uniform sampler2D m_SourceTexture;
-
 uniform float m_Level;
 
 void main(){
 
-	vec4 color=texture2D( m_SourceTexture,v_TexCoord0 );
+	vec4 color=texture2D( r_SourceBuffer,v_SourceBufferCoords );
 
 	float i=(color.r+color.g+color.b)/3.0;
 	

+ 147 - 0
modules/mojo3d/assets/shaders/effects/reflection.glsl

@@ -0,0 +1,147 @@
+
+TODO
+
+//@renderpasses 0
+
+//based on code by 'cireneikual' found at www.opengl.org - thanks!
+
+//current accum buffer
+uniform sampler2D r_SourceBuffer;
+uniform vec2 r_SourceBufferSize;
+uniform vec2 r_SourceBufferScale;
+
+//deferred buffers
+uniform sampler2D r_ColorBuffer;
+uniform sampler2D r_NormalBuffer;
+uniform sampler2D r_DepthBuffer;
+uniform vec2 r_BufferCoordScale;
+
+varying vec2 v_SourceCoords;
+varying vec2 v_BufferCoords;
+
+//@vertex
+
+attribute vec2 a_Position;
+
+void main(){
+
+	v_SourceCoords=a_Position * r_SourceBufferScale;
+	v_BufferCoords=a_Position * r_BufferCoordScale;
+
+	gl_Position=vec4( a_Position * 2.0 - 1.0,-1.0,1.0 );
+}
+
+//@fragment
+
+// Consts should help improve performance
+const float rayStep = 0.25;
+const float minRayStep = 0.1;
+const float searchDist = 5.0;
+const float searchDistInv = 0.2;
+
+const float maxDDepth = 1.0;
+const float maxDDepthInv = 1.0;
+
+const float reflectionSpecularFalloffExponent = 3.0;
+
+const int maxSteps = 20;
+const int numBinarySearchSteps = 5;
+  
+float fragmentDepth( vec2 projCoord ){
+
+	float dbdepth=texture2D( r_DepthBuffer,projCoord * r_BufferCoordScale ).r;
+        
+	return viewDepth( dbdepth );
+}
+
+vec2 projectedCoord( vec3 hitCoord ){
+
+	vec4 projCoord = r_ProjectonMatrix * vec4( hitCoord,1.0 );
+	
+	projCoord.xy = projCoord.xy / projCoord.w * 0.5 + 0.5;
+	
+	return projCoord.xy;
+}
+ 
+vec3 binarySearch( vec3 dir,inout vec3 hitCoord,out float dDepth ){
+
+	float depth;
+ 
+    for( int i=0;i<numBinarySearchSteps; ++i ){
+    
+    	vec2 projCoord=projectedCoord( hitCoord );
+        
+        depth=fragmentDepth( projCoord );
+ 
+        dDepth=hitCoord.z-depth;
+        
+        if( dDepth>0.0 ) hitCoord+=dir;
+	        
+        dir*=0.5;
+        
+        hitCoord-=dir;
+    }
+ 
+	vec2 projCoord=projectedCoord( hitCoord );
+ 
+	return vec3( projCoord.xy,depth );
+}
+ 
+ 
+vec4 rayCast( vec3 dir,inout vec3 hitCoord,out float dDepth ){
+
+    dir*=rayStep;
+ 
+    for( int i=0;i<maxSteps;++i ){
+    
+    	hitCoord+=dir;
+    	
+        vec2 projCoord=projectedCoord( hitCoord );
+        
+        float depth=fragmentDepth( projCoord );
+        
+        dDepth=hitCoord.z-depth;
+        
+        if( dDepth<0.0 ) return vec4( binarySearch( dir,hitCoord,dDepth ),1.0 );
+    }
+ 
+    return vec4( 0.0 );
+}
+ 
+ 
+void main(){
+
+	vec4 normal_r=texture2D( r_NormalBuffer,v_BufferCoords );
+	
+	if( normal_r.a==1.0 ){
+		gl_FragColor=vec4( 0.0 );
+		return;
+	}
+	
+	vec3 position=fragmentPosition();
+	
+	vec3 reflected=normalize( reflect( normalize( position ),normalize( normal_r.rgb ) ) );
+	
+  // Ray cast
+  
+    vec3 hitPos=viewPos;
+    float dDepth;
+ 
+    vec4 coords=rayCast( reflected * max(minRayStep, -viewPos.z), hitPos, dDepth );
+ 
+    vec2 dCoords = abs( vec2(0.5, 0.5)-coords.xy );
+ 
+    float screenEdgefactor = clamp( 1.0-( dCoords.x + dCoords.y ),0.0,1.0 );
+    
+    vec3  color=texture2D( r_ColorBuffer,coords.xy * r_BufferCoordScale ).rgb;
+    
+	float alpha=
+	
+	pow( specular, reflectionSpecularFalloffExponent ) *
+	screenEdgefactor * 
+	clamp( -reflected.z, 0.0, 1.0 ) *
+	clamp( ( searchDist-length( viewPos-hitPos )) * searchDistInv,0.0,1.0) *
+	coords.w );
+ 
+    gl_FragColor=vec4( color*alpha,alpha );
+}

+ 0 - 60
modules/mojo3d/assets/shaders/fog-deferred.glsl

@@ -1,60 +0,0 @@
-
-//@renderpasses 0
-
-varying vec2 v_ClipPosition;
-
-varying vec2 v_TexCoord0;
-
-//@vertex
-
-uniform vec2 r_BufferCoordScale;
-
-attribute vec2 a_Position;	//0...1 (1=viewport size)
-
-void main(){
-
-	v_ClipPosition=a_Position * 2.0 - 1.0;
-	
-	v_TexCoord0=a_Position * r_BufferCoordScale;
-	
-	gl_Position=vec4( v_ClipPosition,-1.0,1.0 );
-}
-
-//@fragment
-
-uniform mat4 r_InverseProjectionMatrix;
-
-uniform sampler2D r_DepthBuffer;
-uniform float r_DepthNear;
-uniform float r_DepthFar;
-
-uniform vec4 r_FogColor;
-uniform float r_FogNear;
-uniform float r_FogFar;
-
-float viewDepth( float depth ){
-
-	return r_DepthFar * r_DepthNear / ( r_DepthFar + depth * ( r_DepthNear - r_DepthFar ) );
-}
-
-void main(){
-
-	float fog=0.0;
-
-	float depth=texture2D( r_DepthBuffer,v_TexCoord0 ).r;
-	
-	if( depth<1.0 ){
-
-		depth=viewDepth( depth );
-		
-		vec4 vpos4=r_InverseProjectionMatrix * vec4( v_ClipPosition,-1.0,1.0 );
-		
-		vec3 vpos=vpos4.xyz/vpos4.w;
-		
-		vec3 v_Position=vpos/vpos.z*depth;
-		
-		fog=clamp( (length( v_Position )-r_FogNear)/(r_FogFar-r_FogNear),0.0,1.0 ) * r_FogColor.a;
-	}
-	
-	gl_FragColor=vec4( r_FogColor.rgb * fog,fog );
-}

+ 192 - 0
modules/mojo3d/assets/shaders/imports/pbr.glsl

@@ -0,0 +1,192 @@
+
+//@import "std"
+
+//@vertex
+
+//@fragment
+
+#if MX2_QUADPASS && MX2_LIGHTINGPASS
+
+void emitPbrFragment( vec3 color,float metalness,float roughness,vec3 position,vec3 normal ){
+
+	float glosiness=1.0-roughness;
+	vec3 color0=vec3( 0.04,0.04,0.04 );
+	vec3 diffuse=color * (1.0-metalness);
+	vec3 specular=(color-color0) * metalness + color0;
+	
+#if MX2_DIRECTIONALLIGHT
+	vec3 lvec=normalize( -r_LightViewMatrix[2].xyz );
+	float atten=1.0;
+#else
+	// TODO: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/
+	vec3 lvec=r_LightViewMatrix[3].xyz-position;
+	float atten=max( 1.0-length( lvec )/r_LightRange,0.0 );
+	lvec=normalize( lvec );
+#endif
+
+	vec3 vvec=normalize( -position );
+	vec3 hvec=normalize( lvec+vvec );
+
+	float hdotl=max( dot( hvec,lvec ),0.0 );
+	float ndotl=max( dot( normal,lvec ),0.0 );
+	float ndoth=max( dot( normal,hvec ),0.0 );
+	
+	float spow=pow( 2.0,glosiness * 12.0 );
+//	float spow=pow( 2048.0,glosiness );
+	
+	float fnorm=(spow+2.0)/8.0;
+	
+	vec3 fschlick=specular + (1.0-specular) * pow( 1.0-hdotl,5.0 ) * glosiness;
+	
+	specular=fschlick * pow( ndoth,spow ) * fnorm;
+
+	vec3 light=r_LightColor.rgb * ndotl * atten;
+	
+#if MX2_SHADOWTYPE
+	light*=shadowColor( position );
+#endif
+
+	vec3 frag=(diffuse+specular) * light;
+		
+	gl_FragColor=vec4( min( frag,8.0 ),1.0 );
+}
+
+#endif
+
+#if MX2_COLORPASS && MX2_DEFERREDPASS
+
+//deferred PBR lighting
+//
+void emitPbrFragment( vec4 color,vec3 ambient,vec3 emissive,float metalness,float roughness,float occlusion,vec3 normal ){
+
+	color*=v_Color;
+
+	float glosiness=1.0-roughness;
+	vec3 color0=vec3( 0.04,0.04,0.04 );
+	vec3 diffuse=color.rgb * (1.0-metalness);
+	vec3 specular=(color.rgb-color0) * metalness + color0;
+	
+	vec3 vvec=normalize( -v_Position );
+	float ndotv=max( dot( normal,vvec ),0.0 );
+	
+	vec3 rvec=r_EnvMatrix * reflect( v_Position,normal );
+
+	float lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
+	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
+
+//	float lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
+//	if( lod==0.0 ) lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
+
+	vec3 ambEnv=pow( textureCube( r_EnvTexture,rvec,max( roughness*r_EnvTextureMaxLod-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
+
+	vec3 fschlick0=specular + (1.0-specular) * pow( 1.0-ndotv,5.0 ) * glosiness;
+
+	vec3 ambDiffuse=diffuse * (r_AmbientDiffuse.rgb+ambient);
+		
+	vec3 ambSpecular=fschlick0 * ambEnv;
+	
+	vec3 frag=(ambDiffuse + ambSpecular) * occlusion + emissive;
+	
+	//write ambient
+	gl_FragData[0]=vec4( min( frag,8.0 ),1.0 );
+	
+	//write color/metalness
+	gl_FragData[1]=vec4( color.rgb,metalness );
+	
+	//write normal/roughness
+	gl_FragData[2]=vec4( normal * 0.5 + 0.5,roughness );
+}
+
+#endif
+
+#if MX2_COLORPASS && MX2_FORWARDPASS
+
+//forward PBR lighting
+//
+void emitPbrFragment( vec4 color,vec3 ambient,vec3 emissive,float metalness,float roughness,float occlusion,vec3 normal ){
+
+	color*=v_Color;
+
+	const vec3 color0=vec3( 0.04,0.04,0.04 );
+	
+	float glosiness=1.0-roughness;
+	vec3 diffuse=color.rgb * (1.0-metalness);
+	vec3 specular=(color.rgb-color0) * metalness + color0;
+	
+	vec3 vvec=normalize( -v_Position );
+	float ndotv=dot( normal,vvec );
+	
+	vec3 frag=vec3( 0.0 );
+	
+#if MX2_AMBIENTPASS
+	//ambient color
+	vec3 rvec=r_EnvMatrix * reflect( v_Position,normal );
+	
+	float lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
+	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
+		
+//	float lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
+//	if( lod==0.0 ) lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
+
+	vec3 ambEnv=pow( textureCube( r_EnvTexture,rvec,max( roughness*r_EnvTextureMaxLod-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
+	
+	vec3 fschlick0=specular + (1.0-specular) * pow( 1.0-ndotv,5.0 ) * glosiness;
+	
+	vec3 ambDiffuse=diffuse * (r_AmbientDiffuse.rgb+ambient);
+	
+	vec3 ambSpecular=fschlick0 * ambEnv;
+
+	frag+=( ambDiffuse + ambSpecular ) * occlusion + emissive;
+#endif
+
+#if MX2_LIGHTINGPASS
+	//lighting color
+	float spow=pow( 2.0,glosiness * 12.0 );				//specular power
+//	float spow=pow( 4096.0,glosiness );
+	float fnorm=(spow+2.0)/8.0;							//normalization factor
+	
+#if MX2_DIRECTIONALLIGHT
+	vec3 lvec=normalize( -r_LightViewMatrix[2].xyz );
+	float atten=1.0;
+#else
+	vec3 lvec=r_LightViewMatrix[3].xyz-v_Position;
+	float atten=max( 1.0-length( lvec )/r_LightRange,0.0 );
+	lvec=normalize( lvec );
+#endif
+	vec3 hvec=normalize( lvec+vvec );
+
+	float ndotl=max( dot( normal,lvec ),0.0 );
+	float ndoth=max( dot( normal,hvec ),0.0 );
+	float hdotl=max( dot( hvec,lvec ),0.0 );
+	
+	vec3 fschlick=specular + (1.0-specular) * pow( 1.0-hdotl,5.0 ) * glosiness;
+	
+	vec3 fspecular=fschlick * pow( ndoth,spow ) * fnorm;
+	
+	vec3 light=r_LightColor.rgb * ndotl * atten;
+	
+	light=(diffuse+fspecular) * light;
+
+#if MX2_SHADOWTYPE
+	light*=shadowColor( v_Position );
+#endif
+
+	frag+=light;
+	
+#endif	//MX2_LIGHTINGPASS
+
+	color.rgb=frag;
+	
+	emitColorFragment( color );
+}
+
+#endif
+
+#if MX2_SHADOWPASS
+
+void main(){
+
+	emitShadowFragment();
+}
+
+#endif

+ 344 - 0
modules/mojo3d/assets/shaders/imports/std.glsl

@@ -0,0 +1,344 @@
+
+// **** MX2_RENDERPASS *****
+//
+// PASSTYPE		'mask=3,  0=quad, 1=deferred, 2=forward, 3=shadow
+// LIGHTTYPE	'mask=12, 0=none, 1=directional, 2=point
+// SHADOWTYPE	'mask=16, 0=no shadows, 1=shadows
+//
+#ifndef MX2_RENDERPASS
+#define MX2_RENDERPASS 0
+#endif
+#define MX2_PASSTYPE			((MX2_RENDERPASS & 3))
+#define MX2_LIGHTTYPE			((MX2_RENDERPASS & 12)>>2)
+#define MX2_SHADOWTYPE			((MX2_RENDERPASS & 16)>>4)
+
+#define MX2_DIRECTIONALLIGHT	(MX2_LIGHTTYPE==1)
+#define MX2_POINTLIGHT			(MX2_LIGHTTYPE==2)
+
+#define MX2_QUADPASS			(MX2_PASSTYPE==0)
+#define MX2_DEFERREDPASS		(MX2_PASSTYPE==1)
+#define MX2_FORWARDPASS			(MX2_PASSTYPE==2)
+#define MX2_SHADOWPASS			(MX2_PASSTYPE==3)
+
+#define MX2_AMBIENTPASS			(MX2_PASSTYPE==1 || MX2_PASSTYPE==2)
+#define MX2_LIGHTINGPASS		(MX2_LIGHTTYPE!=0 && !MX2_SHADOWPASS)
+#define MX2_COLORPASS			(MX2_AMBIENTPASS || MX2_LIGHTINGPASS)
+
+// ***** MX2_ATTRIBMASK *****
+//
+// Position		1
+// Normal		2
+// Color		4
+// TexCoord0	8
+// TexCoord1	16
+// Tangent		32
+// Weights		64
+// Bones		128
+
+#ifndef MX2_ATTRIBMASK
+#define MX2_ATTRIBMASK 0
+#endif
+#define MX2_TEXTURED			((MX2_ATTRIBMASK & 24)!=0)
+#define MX2_BUMPMAPPED			((MX2_ATTRIBMASK & 32)==32)
+#define MX2_BONED				((MX2_ATTRIBMASK & 192)==192)
+
+//***** RENDER *****
+//
+uniform float r_Time;
+uniform vec4 r_AmbientDiffuse;
+uniform samplerCube r_SkyTexture;
+uniform samplerCube r_EnvTexture;
+uniform float r_EnvTextureMaxLod;
+uniform vec4 r_EnvColor;
+uniform mat3 r_EnvMatrix;
+uniform float r_DepthNear;
+uniform float r_DepthFar;
+uniform float r_FogNear;
+uniform float r_FogFar;
+uniform vec4 r_FogColor;
+uniform mat4 r_InverseProjectionMatrix;
+uniform mat4 r_ProjectionMatrix;
+uniform mat4 r_ViewMatrix;
+
+// These available in deferred renderer!
+uniform sampler2D r_AccumBuffer;
+uniform sampler2D r_ColorBuffer;
+uniform sampler2D r_NormalBuffer;
+uniform sampler2D r_DepthBuffer;
+uniform vec2 r_BufferCoordScale;
+
+//***** LIGHTING *****
+//
+uniform mat4 r_LightViewMatrix;
+uniform vec4 r_LightColor;
+uniform float r_LightRange;
+uniform float r_ShadowAlpha;
+uniform sampler2D r_ShadowCSMTexture;
+uniform vec4 r_ShadowCSMSplits;
+uniform samplerCube r_ShadowCubeTexture;
+uniform mat4 r_ShadowMatrix0;
+uniform mat4 r_ShadowMatrix1;
+uniform mat4 r_ShadowMatrix2;
+uniform mat4 r_ShadowMatrix3;
+
+//***** INSTANCE *****
+//
+uniform mat4 i_ModelMatrix;
+uniform mat4 i_ModelViewMatrix;
+uniform mat4 i_ModelViewProjectionMatrix;
+uniform mat3 i_ModelViewNormalMatrix;
+uniform mat4 i_ModelBoneMatrices[96];
+uniform vec4  i_Color;
+uniform float i_Alpha;
+
+//***** MATERIAL *****
+//
+uniform mat3 m_TextureMatrix;
+
+//***** VARYINGS *****
+//
+varying vec2 v_ClipPosition;
+varying vec2 v_BufferCoords;
+varying vec3 v_Position;
+varying vec3 v_Normal;
+varying vec4 v_Color;
+varying vec2 v_TexCoord0;
+varying vec2 v_TexCoord1;
+varying mat3 v_TanMatrix;
+
+//@vertex
+
+//***** ATTRIBUTES *****
+//
+attribute vec4 a_Position;	//mask=1
+attribute vec3 a_Normal;	//mask=2
+attribute vec4 a_Color;		//mask=4
+attribute vec2 a_TexCoord0;	//mask=8
+attribute vec2 a_TexCoord1;	//mask=16
+attribute vec4 a_Tangent;	//mask=32
+attribute vec4 a_Weights;	//mask=64
+attribute vec4 a_Bones;		//mask=128
+
+void transformQuadVertex(){
+
+	v_ClipPosition=a_Position.xy * 2.0 - 1.0;
+	
+	v_BufferCoords=a_Position.xy * r_BufferCoordScale;
+	
+	gl_Position=vec4( v_ClipPosition,-1.0,1.0 );
+}
+
+void transformSpriteVertex(){
+
+	v_Position=(i_ModelViewMatrix * a_Position).xyz;
+
+	v_TexCoord0=(m_TextureMatrix * vec3(a_TexCoord0,1.0)).st;
+	
+	gl_Position=i_ModelViewProjectionMatrix * a_Position;
+}
+
+void transformVertex(){
+ 
+#if MX2_BONED
+	mat4 m0=i_ModelBoneMatrices[ int( a_Bones.x ) ];
+	mat4 m1=i_ModelBoneMatrices[ int( a_Bones.y ) ];
+	mat4 m2=i_ModelBoneMatrices[ int( a_Bones.z ) ];
+	mat4 m3=i_ModelBoneMatrices[ int( a_Bones.a ) ];
+	
+	vec4 position=
+		m0 * a_Position * a_Weights.x +
+		m1 * a_Position * a_Weights.y +
+		m2 * a_Position * a_Weights.z +
+		m3 * a_Position * a_Weights.a;
+#if MX2_COLORPASS
+	mat3 n0=mat3( m0[0].xyz,m0[1].xyz,m0[2].xyz );
+	mat3 n1=mat3( m1[0].xyz,m1[1].xyz,m1[2].xyz );
+	mat3 n2=mat3( m2[0].xyz,m2[1].xyz,m2[2].xyz );
+	mat3 n3=mat3( m3[0].xyz,m3[1].xyz,m3[2].xyz );
+
+	vec3 normal=normalize( 
+		n0 * a_Normal * a_Weights.x +
+		n1 * a_Normal * a_Weights.y +
+		n2 * a_Normal * a_Weights.z +
+		n3 * a_Normal * a_Weights.a );
+#if MX2_BUMPMAPPED
+	vec4 tangent=vec4( normalize( 
+		n0 * a_Tangent.xyz * a_Weights.x +
+		n1 * a_Tangent.xyz * a_Weights.y +
+		n2 * a_Tangent.xyz * a_Weights.z +
+		n3 * a_Tangent.xyz * a_Weights.a ),a_Tangent.w );
+#endif
+#endif
+#else	//MX2_BONED
+	vec4 position=a_Position;
+#if MX2_COLORPASS
+	vec3 normal=a_Normal;
+#if MX2_BUMPMAPPED	
+	vec4 tangent=a_Tangent;
+#endif
+#endif
+#endif
+
+	// view space position
+	v_Position=( i_ModelViewMatrix * position ).xyz;
+
+#if MX2_COLORPASS
+	// viewspace normal
+	v_Normal=i_ModelViewNormalMatrix * normal;
+	// vertex color
+	v_Color=a_Color * i_Color;
+	v_Color.a*=i_Alpha;
+#if MX2_TEXTURED
+	// texture coord0
+	v_TexCoord0=(m_TextureMatrix * vec3(a_TexCoord0,1.0)).st;
+	v_TexCoord1=a_TexCoord1;//(m_TextureMatrix * vec3(a_TexCoord1,1.0)).st;
+#if MX2_BUMPMAPPED
+	// viewspace tangent matrix
+	v_TanMatrix[2]=normalize( v_Normal );
+	v_TanMatrix[0]=normalize( i_ModelViewNormalMatrix * tangent.xyz );
+	v_TanMatrix[1]=cross( v_TanMatrix[0],v_TanMatrix[2] ) * tangent.a;
+#endif
+#endif
+#endif	//MX2_COLORPASS
+	
+	gl_Position=i_ModelViewProjectionMatrix * position;
+}
+
+//@fragment
+
+vec4 FloatToRGBA( float value ){
+
+	const float MaxFloat=0.9999999;
+	value=clamp( value,0.0,MaxFloat );
+	vec4 rgba=fract( vec4( 1.0, 255.0, 65025.0, 16581375.0 ) * value );
+	return rgba-rgba.yzww * vec4( 1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0 );
+}
+
+float RGBAToFloat( vec4 rgba ){
+
+	return dot( rgba,vec4( 1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0 ) );
+}
+
+float viewDepth( float depthBufferDepth ){
+
+	return r_DepthFar * r_DepthNear / ( r_DepthFar + depthBufferDepth * ( r_DepthNear - r_DepthFar ) );
+}
+
+#if MX2_QUADPASS
+
+vec3 fragmentPosition(){
+
+	float depth=viewDepth( texture2D( r_DepthBuffer,v_BufferCoords ).r );
+
+	vec4 vpos4=r_InverseProjectionMatrix * vec4( v_ClipPosition,-1.0,1.0 );
+	
+	vec3 vpos=vpos4.xyz/vpos4.w;
+	
+	//debug z coord...
+	//
+	if( abs( vpos.z-r_DepthNear)>0.00001 ){
+//		gl_FragColor=vec4( 1.0,0.0,0.0,1.0 );
+//		return vec3( 0.0 );
+	}
+	
+	vec3 position=vpos/vpos.z*depth;
+	
+	return position;
+}
+
+#else
+
+vec3 fragmentPosition(){
+
+	return v_Position;
+}
+
+#endif
+
+#if MX2_LIGHTINGPASS && MX2_SHADOWTYPE
+
+float shadowColor( vec3 position ){
+
+#if MX2_DIRECTIONALLIGHT
+
+	if( position.z>=r_ShadowCSMSplits.w ) return 1.0;//(1.0-r_ShadowAlpha)*0.5;
+	
+	vec4 vpos=vec4( position,1.0 );
+	vec2 off;
+	
+	if( vpos.z<r_ShadowCSMSplits.x ){
+		vpos=r_ShadowMatrix0 * vpos;
+		off=vec2( 0.0,0.0 );
+	}else if( vpos.z<r_ShadowCSMSplits.y ){
+		vpos=r_ShadowMatrix1 * vpos;
+		off=vec2( 0.5,0.0 );
+	}else if( vpos.z<r_ShadowCSMSplits.z ){
+		vpos=r_ShadowMatrix2 * vpos;
+		off=vec2( 0.0,0.5 );
+	}else{
+		vpos=r_ShadowMatrix3 * vpos;
+		off=vec2( 0.5,0.5 );
+	}
+	
+	vec3 spos=vpos.xyz/vpos.w * vec3( 0.25,0.25,0.5 ) + vec3( 0.25,0.25,0.5 );
+	
+	float d=texture2D( r_ShadowCSMTexture,spos.xy+off ).r;
+	
+	if( spos.z>d ) return 1.0-r_ShadowAlpha;
+	
+	return 1.0;
+	
+#else
+
+	vec4 vpos=vec4( position,1.0 );
+	
+	vec3 lpos=(r_ShadowMatrix0 * vpos).xyz;
+	
+	float d=RGBAToFloat( textureCube( r_ShadowCubeTexture,lpos ) );
+	
+	if( length(lpos) > d * r_LightRange ) return 1.0-r_ShadowAlpha;
+	
+	return 1.0;
+	
+#endif
+}
+
+#endif
+
+
+#if MX2_FORWARDPASS
+
+void emitLinearFragment( vec4 color ){
+
+#if defined( MX2_SRGBOUTPUT )
+	gl_FragColor=vec4( pow( color.rgb*color.a,vec3( 1.0/2.2 ) ),color.a );
+#else
+	gl_FragColor=vec4( color.rgb*color.a,color.a );
+#endif
+}
+
+void emitColorFragment( vec4 color ){
+
+	float fog=clamp( (length( v_Position )-r_FogNear)/(r_FogFar-r_FogNear),0.0,1.0 ) * r_FogColor.a;
+	
+	color.rgb=mix( color.rgb,r_FogColor.rgb,fog );
+	
+	emitLinearFragment( color );
+}
+
+#endif
+
+#if MX2_SHADOWPASS
+
+void emitShadowFragment(){
+
+#if MX2_DIRECTIONALLIGHT
+	gl_FragColor=vec4( vec3( gl_FragCoord.z ),1.0 );
+#else
+	gl_FragColor=FloatToRGBA( min( length( v_Position )/r_LightRange,1.0 ) );
+#endif
+}
+
+#endif
+
+

+ 0 - 223
modules/mojo3d/assets/shaders/lighting-deferred.glsl

@@ -1,223 +0,0 @@
-
-//@renderpasses 2,6,10,14
-
-//renderpasses:
-//
-// 2=directional without shadows
-// 6=directional with  shadows
-// 10=point without shadows
-// 14=point with shadows
- 
-uniform mat4 r_InverseProjectionMatrix;
-
-#define MX2_POINT_LIGHT ((MX2_RENDERPASS&8)!=0)
-#define MX2_DIRECTIONAL_LIGHT ((MX2_RENDERPASS&8)==0)
-#define MX2_SHADOWED_LIGHT ((MX2_RENDERPASS&4)!=0)
-
-uniform vec2 r_BufferCoordScale;
-uniform sampler2D r_ColorBuffer;
-uniform sampler2D r_NormalBuffer;
-uniform sampler2D r_DepthBuffer;
-
-uniform float r_DepthNear;
-uniform float r_DepthFar;
-
-uniform mat4 r_LightViewMatrix;
-uniform float r_LightRange;
-uniform vec4 r_LightColor;
-
-#if MX2_SHADOWED_LIGHT
-
-uniform float r_ShadowAlpha;
-
-#if MX2_DIRECTIONAL_LIGHT
-uniform sampler2D r_ShadowCSMTexture;
-uniform vec4 r_ShadowCSMSplits;
-uniform mat4 r_ShadowMatrix0;
-uniform mat4 r_ShadowMatrix1;
-uniform mat4 r_ShadowMatrix2;
-uniform mat4 r_ShadowMatrix3;
-#else
-uniform samplerCube r_ShadowCubeTexture;
-uniform mat4 r_ShadowMatrix0;
-#endif
-
-#endif
-
-varying vec2 v_ClipPosition;
-varying vec2 v_TexCoord0;
-
-//@vertex
-
-attribute vec2 a_Position;	//0...1 (1=viewport size)
-
-void main(){
-
-	v_ClipPosition=a_Position * 2.0 - 1.0;
-	
-	v_TexCoord0=a_Position * r_BufferCoordScale;
-	
-	gl_Position=vec4( v_ClipPosition,-1.0,1.0 );
-}
-
-//@fragment
-
-vec3 v_Position;
-vec3 v_Normal;
-
-//can't handle 1!
-vec4 FloatToRGBA( float value ){
-
-	const float MaxFloat=0.9999999;
-
-	value=clamp( value,0.0,MaxFloat );
-
-	vec4 rgba=fract( vec4( 1.0, 255.0, 65025.0, 16581375.0 ) * value );
-	
-	return rgba-rgba.yzww * vec4( 1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0 );
-}
-
-float RGBAToFloat( vec4 rgba ){
-
-	return dot( rgba,vec4( 1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0 ) );
-}
-
-float viewDepth( float depth ){
-
-	return r_DepthFar * r_DepthNear / ( r_DepthFar + depth * ( r_DepthNear - r_DepthFar ) );
-}
-
-#if MX2_SHADOWED_LIGHT
-
-#if MX2_DIRECTIONAL_LIGHT
-
-float shadowColor(){
-
-//	vec3 dx=dFdx( v_Position );
-//	vec3 dy=dFdy( v_Position );
-//	vec3 vn=vec4( cross( dx,dy ),0.0 );
-//	vec4 vpos=vec4( v_Position + v_Normal*0.01,1.0 );
-
-	if( v_Position.z>=r_ShadowCSMSplits.w ) return 1.0;//(1.0-r_ShadowAlpha)*0.5;
-	
-	vec4 vpos=vec4( v_Position,1.0 );
-	vec2 off;
-	
-	if( vpos.z<r_ShadowCSMSplits.x ){
-		vpos=r_ShadowMatrix0 * vpos;
-		off=vec2( 0.0,0.0 );
-	}else if( vpos.z<r_ShadowCSMSplits.y ){
-		vpos=r_ShadowMatrix1 * vpos;
-		off=vec2( 0.5,0.0 );
-	}else if( vpos.z<r_ShadowCSMSplits.z ){
-		vpos=r_ShadowMatrix2 * vpos;
-		off=vec2( 0.0,0.5 );
-	}else{
-		vpos=r_ShadowMatrix3 * vpos;
-		off=vec2( 0.5,0.5 );
-	}
-	
-	vec3 spos=vpos.xyz/vpos.w * vec3( 0.25,0.25,0.5 ) + vec3( 0.25,0.25,0.5 );
-	
-#if defined( MX2_RGBADEPTHTEXTURES )
-	float d=RGBAToFloat( texture2D( r_ShadowCSMTexture,spos.xy+off ) );
-#else
-	float d=texture2D( r_ShadowCSMTexture,spos.xy+off ).r;
-#endif
-	
-	if( spos.z>d ) return 1.0-r_ShadowAlpha;
-	
-	return 1.0;
-}
-
-#else
-
-float shadowColor(){
-
-	vec4 vpos=vec4( v_Position,1.0 );
-	
-	vec3 lpos=(r_ShadowMatrix0 * vpos).xyz;
-	
-	float d=RGBAToFloat( textureCube( r_ShadowCubeTexture,lpos ) );
-	
-	if( length(lpos) > d * r_LightRange ) return 1.0-r_ShadowAlpha;
-	
-	return 1.0;
-}
-
-#endif
-
-#endif
-
-vec3 lightColor( vec3 color,float metalness,float roughness ){
-
-	vec3 normal=v_Normal;
-	float glosiness=1.0-roughness;
-	vec3 color0=vec3( 0.04,0.04,0.04 );
-	vec3 diffuse=color * (1.0-metalness);
-	vec3 specular=(color-color0) * metalness + color0;
-	
-#if MX2_DIRECTIONAL_LIGHT
-	vec3 lvec=normalize( -r_LightViewMatrix[2].xyz );
-	float atten=1.0;
-#else
-	// TODO: https://imdoingitwrong.wordpress.com/2011/01/31/light-attenuation/
-	vec3 lvec=r_LightViewMatrix[3].xyz-v_Position;
-	float atten=max( 1.0-length( lvec )/r_LightRange,0.0 );
-	lvec=normalize( lvec );
-#endif
-
-	vec3 vvec=normalize( -v_Position );
-	vec3 hvec=normalize( lvec+vvec );
-
-	float hdotl=max( dot( hvec,lvec ),0.0 );
-	float ndotl=max( dot( normal,lvec ),0.0 );
-	float ndoth=max( dot( normal,hvec ),0.0 );
-	
-	float spow=pow( 2.0,glosiness * 12.0 );
-//	float spow=pow( 2048.0,glosiness );
-	
-	float fnorm=(spow+2.0)/8.0;
-	
-	vec3 fschlick=specular + (1.0-specular) * pow( 1.0-hdotl,5.0 ) * glosiness;
-	
-	specular=fschlick * pow( ndoth,spow ) * fnorm;
-
-	vec3 light=r_LightColor.rgb * ndotl * atten;
-	
-#if MX2_SHADOWED_LIGHT
-
-	light*=shadowColor();
-	
-#endif
-	
-	return (diffuse+specular) * light;
-}
-
-void main(){
-
-	vec4 color_m=texture2D( r_ColorBuffer,v_TexCoord0 );
-	
-	vec4 normal_r=texture2D( r_NormalBuffer,v_TexCoord0 );
-	
-	float depth=viewDepth( texture2D( r_DepthBuffer,v_TexCoord0 ).r );
-
-	vec4 vpos4=r_InverseProjectionMatrix * vec4( v_ClipPosition,-1.0,1.0 );
-	
-	vec3 vpos=vpos4.xyz/vpos4.w;
-	
-	//debug z coord...
-	//
-	if( abs( vpos.z-r_DepthNear)>0.00001 ){
-		gl_FragColor=vec4( 1.0,0.0,0.0,1.0 );
-		return;
-	}
-	
-	v_Position=vpos/vpos.z*depth;
-	
-	v_Normal=normalize( normal_r.xyz * 2.0 - 1.0 );
-	
-	vec3 frag=lightColor( color_m.rgb,color_m.a,normal_r.a );
-	
-	gl_FragColor=vec4( min( frag,8.0 ),1.0 );
-}

+ 0 - 310
modules/mojo3d/assets/shaders/material-pbr-deferred.glsl

@@ -1,310 +0,0 @@
-//@renderpasses 1,4,12
-
-//renderpasses:
-//
-// 1 = ambient
-// 4 = directional shadows
-// 12 = point shadows
-
-#define MX2_COLORPASS ((MX2_RENDERPASS&3)!=0)
-#define MX2_POINT_LIGHT ((MX2_RENDERPASS&8)!=0)
-#define MX2_DIRECTIONAL_LIGHT ((MX2_RENDERPASS&8)==0)
- 
-//material uniforms
-
-#ifdef MX2_TEXTURED
-uniform mat3 m_TextureMatrix;
-#endif
-
-//renderer uniforms...
-
-uniform mat4 i_ModelViewMatrix;
-uniform mat4 i_ModelViewProjectionMatrix;
-uniform mat3 i_ModelViewNormalMatrix;
-
-#if MX2_COLORPASS
-
-uniform vec4  i_Color;
-uniform float i_Alpha;
-
-uniform vec4 r_AmbientDiffuse;
-uniform samplerCube r_EnvTexture;
-uniform float r_EnvTextureMaxLod;
-uniform vec4 r_EnvColor;
-uniform mat3 r_EnvMatrix;
-
-//pbr varyings...
-
-varying vec3 v_Position;
-varying vec3 v_Normal;
-varying vec4 v_Color;
-#ifdef MX2_TEXTURED
-varying vec2 v_TexCoord0;
-#ifdef MX2_BUMPMAPPED
-varying mat3 v_TanMatrix;
-#endif
-#endif
-
-#else	//MX2_COLORPASS
-
-#if MX2_POINT_LIGHT
-uniform float r_LightRange;
-#endif
-
-varying vec3 v_Position;
-
-#endif	//MX2_COLORPASS
-
-//@vertex
-
-#ifdef MX2_BONED
-uniform mat4 i_ModelBoneMatrices[96];
-#endif
-
-//vertex attribs....
-
-attribute vec4 a_Position;
-#ifdef MX2_BONED
-attribute vec4 a_Weights;
-attribute vec4 a_Bones;
-#endif
-
-#if MX2_COLORPASS
-
-attribute vec3 a_Normal;
-attribute vec4 a_Color;
-#ifdef MX2_TEXTURED
-attribute vec2 a_TexCoord0;
-#ifdef MX2_BUMPMAPPED
-attribute vec4 a_Tangent;
-#endif
-#endif
-
-#endif	//MX2_COLORPASS
-
-#ifdef MX2_BONED
-
-void main(){
-
-	mat4 m0=i_ModelBoneMatrices[ int( a_Bones.x ) ];
-	mat4 m1=i_ModelBoneMatrices[ int( a_Bones.y ) ];
-	mat4 m2=i_ModelBoneMatrices[ int( a_Bones.z ) ];
-	mat4 m3=i_ModelBoneMatrices[ int( a_Bones.a ) ];
-	
-	vec4 b_Position=
-		m0 * a_Position * a_Weights.x +
-		m1 * a_Position * a_Weights.y +
-		m2 * a_Position * a_Weights.z +
-		m3 * a_Position * a_Weights.a;
-		
-	// view space position
-	v_Position=( i_ModelViewMatrix * b_Position ).xyz;
-
-#if MX2_COLORPASS
-
-	mat3 n0=mat3( m0[0].xyz,m0[1].xyz,m0[2].xyz );
-	mat3 n1=mat3( m1[0].xyz,m1[1].xyz,m1[2].xyz );
-	mat3 n2=mat3( m2[0].xyz,m2[1].xyz,m2[2].xyz );
-	mat3 n3=mat3( m3[0].xyz,m3[1].xyz,m3[2].xyz );
-
-	vec3 b_Normal=normalize( 
-		n0 * a_Normal * a_Weights.x +
-		n1 * a_Normal * a_Weights.y +
-		n2 * a_Normal * a_Weights.z +
-		n3 * a_Normal * a_Weights.a );
-		
-#ifdef MX2_BUMPMAPPED
-	vec4 b_Tangent=vec4( normalize( 
-		n0 * a_Tangent.xyz * a_Weights.x +
-		n1 * a_Tangent.xyz * a_Weights.y +
-		n2 * a_Tangent.xyz * a_Weights.z +
-		n3 * a_Tangent.xyz * a_Weights.a ),a_Tangent.w );
-#endif
-
-	// viewspace normal
-	v_Normal=i_ModelViewNormalMatrix * b_Normal;
-	
-	// vertex color
-	v_Color=a_Color * i_Color;
-	v_Color.a*=i_Alpha;
-	
-#ifdef MX2_TEXTURED
-	// texture coord0
-	v_TexCoord0=(m_TextureMatrix * vec3(a_TexCoord0,1.0)).st;
-#ifdef MX2_BUMPMAPPED
-	// viewspace tangent matrix
-	v_TanMatrix[2]=normalize( v_Normal );
-	v_TanMatrix[0]=normalize( i_ModelViewNormalMatrix * b_Tangent.xyz );
-	v_TanMatrix[1]=cross( v_TanMatrix[0],v_TanMatrix[2] ) * b_Tangent.a;
-#endif
-#endif
-	
-#endif	//MX2_COLORPASS
-	
-	gl_Position=i_ModelViewProjectionMatrix * b_Position;
-}
-
-#else	//MX2_BONED
-
-void main(){
-
-	// view space position
-	v_Position=( i_ModelViewMatrix * a_Position ).xyz;
-
-#if MX2_COLORPASS
-
-	// viewspace normal
-	v_Normal=i_ModelViewNormalMatrix * a_Normal;
-	
-	// vertex color
-	v_Color=a_Color * i_Color;
-	v_Color.a*=i_Alpha;
-	
-#ifdef MX2_TEXTURED
-	// texture coord0
-	v_TexCoord0=(m_TextureMatrix * vec3(a_TexCoord0,1.0)).st;
-#ifdef MX2_BUMPMAPPED
-	// viewspace tangent matrix
-	v_TanMatrix[2]=normalize( v_Normal );
-	v_TanMatrix[0]=normalize( i_ModelViewNormalMatrix * a_Tangent.xyz );
-	v_TanMatrix[1]=cross( v_TanMatrix[0],v_TanMatrix[2] ) * a_Tangent.a;
-#endif
-#endif
-
-#endif	//MX2_COLORPASS
-	
-	gl_Position=i_ModelViewProjectionMatrix * a_Position;
-}
-
-#endif	//MX2_BONED
-
-//@fragment
-
-vec4 FloatToRGBA( float value ){
-
-	const float MaxFloat=0.9999999;
-
-	value=clamp( value,0.0,MaxFloat );
-
-	vec4 rgba=fract( vec4( 1.0, 255.0, 65025.0, 16581375.0 ) * value );
-	
-	return rgba-rgba.yzww * vec4( 1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0 );
-}
-
-float RGBAToFloat( vec4 rgba ){
-
-	return dot( rgba,vec4( 1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0 ) );
-}
-
-#if MX2_COLORPASS
-
-void pbrWriteFragData( vec3 color,vec3 emissive,float metalness,float roughness,float occlusion,vec3 normal ){
-
-	float glosiness=1.0-roughness;
-	vec3 color0=vec3( 0.04,0.04,0.04 );
-	vec3 diffuse=color * (1.0-metalness);
-	vec3 specular=(color-color0) * metalness + color0;
-	
-	vec3 vvec=normalize( -v_Position );
-	float ndotv=max( dot( normal,vvec ),0.0 );
-	
-	vec3 rvec=r_EnvMatrix * reflect( v_Position,normal );
-
-	float lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
-	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
-
-//	float lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
-//	if( lod==0.0 ) lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
-
-	vec3 ambEnv=pow( textureCube( r_EnvTexture,rvec,max( roughness*r_EnvTextureMaxLod-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
-
-	vec3 fschlick0=specular + (1.0-specular) * pow( 1.0-ndotv,5.0 ) * glosiness;
-
-	vec3 ambDiffuse=diffuse * r_AmbientDiffuse.rgb;
-		
-	vec3 ambSpecular=fschlick0 * ambEnv;
-	
-	vec3 frag=(ambDiffuse + ambSpecular) * occlusion + emissive;
-	
-	//write ambient
-	gl_FragData[0]=vec4( min( frag,8.0 ),1.0 );
-	
-	//write color/metalness
-	gl_FragData[1]=vec4( color,metalness );
-	
-	//write normal/roughness
-	gl_FragData[2]=vec4( normal * 0.5 + 0.5,roughness );
-}
-
-#endif
-
-#if MX2_COLORPASS
-
-#ifdef MX2_TEXTURED
-uniform sampler2D m_ColorTexture;
-uniform sampler2D m_EmissiveTexture;
-uniform sampler2D m_MetalnessTexture;
-uniform sampler2D m_RoughnessTexture;
-uniform sampler2D m_OcclusionTexture;
-#ifdef MX2_BUMPMAPPED
-uniform sampler2D m_NormalTexture;
-#endif
-#endif
-
-uniform vec4 m_ColorFactor;
-uniform vec4 m_EmissiveFactor;
-uniform float m_MetalnessFactor;
-uniform float m_RoughnessFactor;
-
-void main(){
-
-#ifdef MX2_TEXTURED
-
-	vec3 color=pow( texture2D( m_ColorTexture,v_TexCoord0 ).rgb,vec3( 2.2 ) ) * m_ColorFactor.rgb;
-	vec3 emissive=pow( texture2D( m_EmissiveTexture,v_TexCoord0 ).rgb,vec3( 2.2 ) ) * m_EmissiveFactor.rgb;
-	float metalness=texture2D( m_MetalnessTexture,v_TexCoord0 ).b * m_MetalnessFactor;
-	float roughness=texture2D( m_RoughnessTexture,v_TexCoord0 ).g * m_RoughnessFactor;
-	float occlusion=texture2D( m_OcclusionTexture,v_TexCoord0 ).r;
-	
-#ifdef MX2_BUMPMAPPED
-	vec3 normal=texture2D( m_NormalTexture,v_TexCoord0 ).xyz * 2.0 - 1.0;
-	normal=normalize( v_TanMatrix * normal );
-#else
-	vec3 normal=normalize( v_Normal );
-#endif
-
-#else
-
-	vec3 color=m_ColorFactor.rgb;
-	vec3 emissive=m_EmissiveFactor.rgb;
-	float metalness=m_MetalnessFactor;
-	float roughness=m_RoughnessFactor;
-	float occlusion=1.0;
-	vec3 normal=normalize( v_Normal );
-
-#endif
-
-	pbrWriteFragData( color*v_Color.rgb,emissive,metalness,roughness,occlusion,normal );
-}
-	
-#else	//MX2_COLORPASS
-
-void main(){
-
-#if MX2_POINT_LIGHT
-
-	gl_FragColor=FloatToRGBA( length( v_Position )/r_LightRange );
-	
-#elif defined( MX2_RGBADEPTHTEXTURES )
-
-	gl_FragColor=FloatToRGBA( gl_FragCoord.z );
-
-#else
-
-	gl_FragColor=vec4( vec3( gl_FragCoord.z ),1.0 );
-	
-#endif
-
-}
-
-#endif

+ 0 - 449
modules/mojo3d/assets/shaders/material-pbr-forward.glsl

@@ -1,449 +0,0 @@
-//@renderpasses 1, 2,3,6,7, 10,11,14,15, 4,12
-
-//render passes:
-//
-// 1  = ambient.
-// 2  = lighting.
-// 4  = shadowed.
-// 8  = light type - 0=directional, 1=point
-
-#define MX2_COLORPASS ((MX2_RENDERPASS&3)!=0)
-
-#define MX2_AMBIENTPASS (MX2_RENDERPASS&1)
-#define MX2_LIGHTINGPASS (MX2_RENDERPASS&2)
-#define MX2_SHADOWEDPASS (MX2_RENDERPASS&4)
-
-#define MX2_POINT_LIGHT ((MX2_RENDERPASS&8)!=0)
-#define MX2_DIRECTIONAL_LIGHT ((MX2_RENDERPASS&8)==0)
- 
-//instance uniforms
-//
-uniform mat4 i_ModelViewMatrix;
-uniform mat4 i_ModelViewProjectionMatrix;
-uniform mat3 i_ModelViewNormalMatrix;
-
-#if defined( MX2_BONED )
-uniform mat4 i_ModelBoneMatrices[96];
-#endif
-
-#if MX2_COLORPASS
-uniform vec4  i_Color;
-uniform float i_Alpha;
-#endif
-
-//material uniforms
-//
-#if MX2_COLORPASS && defined( MX2_TEXTURED )
-uniform mat3 m_TextureMatrix;
-#endif
-
-#if MX2_AMBIENTPASS
-
-//renderer uniforms
-//
-uniform vec4 r_AmbientDiffuse;
-uniform samplerCube r_EnvTexture;
-uniform float r_EnvTextureMaxLod;
-uniform vec4 r_EnvColor;
-uniform mat3 r_EnvMatrix;
-
-#endif
-
-#if MX2_LIGHTINGPASS
-
-uniform mat4 r_LightViewMatrix;
-uniform vec4 r_LightColor;
-uniform float r_LightRange;
-
-#if MX2_SHADOWEDPASS
-
-uniform float r_ShadowAlpha;
-
-#if MX2_DIRECTIONAL_LIGHT
-uniform sampler2D r_ShadowCSMTexture;
-uniform vec4 r_ShadowCSMSplits;
-uniform mat4 r_ShadowMatrix0;
-uniform mat4 r_ShadowMatrix1;
-uniform mat4 r_ShadowMatrix2;
-uniform mat4 r_ShadowMatrix3;
-#else
-uniform samplerCube r_ShadowCubeTexture;
-uniform mat4 r_ShadowMatrix0;
-#endif
-
-#endif	//MX2_SHADOWEDPASS
-
-#endif	//MX2_LIGHTINGPASS
-
-#if !MX2_COLORPASS && MX2_POINT_LIGHT
-uniform float r_LightRange;
-#endif
-
-//pbr varyings...
-//
-varying vec3 v_Position;
-varying vec3 v_Normal;
-varying vec4 v_Color;
-#if MX2_COLORPASS && defined( MX2_TEXTURED )
-varying vec2 v_TexCoord0;
-#if defined( MX2_BUMPMAPPED )
-varying mat3 v_TanMatrix;
-#endif
-#endif
-
-//@vertex
-
-attribute vec4 a_Position;
-
-#if MX2_COLORPASS
-attribute vec3 a_Normal;
-attribute vec4 a_Color;
-#if defined( MX2_TEXTURED )
-attribute vec2 a_TexCoord0;
-#if defined( MX2_BUMPMAPPED )
-attribute vec4 a_Tangent;
-#endif
-#endif
-#endif
-	
-#if defined( MX2_BONED )
-
-attribute vec4 a_Weights;
-attribute vec4 a_Bones;
-
-void main(){
-
-	mat4 m0=i_ModelBoneMatrices[ int( a_Bones.x ) ];
-	mat4 m1=i_ModelBoneMatrices[ int( a_Bones.y ) ];
-	mat4 m2=i_ModelBoneMatrices[ int( a_Bones.z ) ];
-	mat4 m3=i_ModelBoneMatrices[ int( a_Bones.a ) ];
-	
-	vec4 b_Position=
-		m0 * a_Position * a_Weights.x +
-		m1 * a_Position * a_Weights.y +
-		m2 * a_Position * a_Weights.z +
-		m3 * a_Position * a_Weights.a;
-		
-	// view space position
-	v_Position=( i_ModelViewMatrix * b_Position ).xyz;
-
-#if MX2_COLORPASS
-
-	mat3 n0=mat3( m0[0].xyz,m0[1].xyz,m0[2].xyz );
-	mat3 n1=mat3( m1[0].xyz,m1[1].xyz,m1[2].xyz );
-	mat3 n2=mat3( m2[0].xyz,m2[1].xyz,m2[2].xyz );
-	mat3 n3=mat3( m3[0].xyz,m3[1].xyz,m3[2].xyz );
-
-	vec3 b_Normal=normalize( 
-		n0 * a_Normal * a_Weights.x +
-		n1 * a_Normal * a_Weights.y +
-		n2 * a_Normal * a_Weights.z +
-		n3 * a_Normal * a_Weights.a );
-		
-#if defined( MX2_BUMPMAPPED )
-	vec4 b_Tangent=vec4( normalize( 
-		n0 * a_Tangent.xyz * a_Weights.x +
-		n1 * a_Tangent.xyz * a_Weights.y +
-		n2 * a_Tangent.xyz * a_Weights.z +
-		n3 * a_Tangent.xyz * a_Weights.a ),a_Tangent.w );
-#endif
-
-	// viewspace normal
-	v_Normal=i_ModelViewNormalMatrix * b_Normal;
-	
-	// vertex color
-	v_Color=a_Color * i_Color;
-	v_Color.a*=i_Alpha;
-	
-#if MX2_COLORPASS && defined( MX2_TEXTURED )
-	// texture coord0
-	v_TexCoord0=(m_TextureMatrix * vec3(a_TexCoord0,1.0)).st;
-#if defined( MX2_BUMPMAPPED )
-	// viewspace tangent matrix
-	v_TanMatrix[2]=v_Normal;
-	v_TanMatrix[0]=i_ModelViewNormalMatrix * b_Tangent.xyz;
-	v_TanMatrix[1]=cross( v_TanMatrix[0],v_TanMatrix[2] ) * b_Tangent.a;
-#endif
-#endif
-	
-#endif	//MX2_COLORPASS
-	
-	gl_Position=i_ModelViewProjectionMatrix * b_Position;
-}
-
-#else	//MX2_BONED
-
-void main(){
-
-	// view space position
-	v_Position=(i_ModelViewMatrix * a_Position).xyz;
-
-#if MX2_COLORPASS
-
-	// viewspace normal
-	v_Normal=i_ModelViewNormalMatrix * a_Normal;
-	
-	// vertex color
-	v_Color=a_Color * i_Color;
-	v_Color.a*=i_Alpha;
-	
-#if defined( MX2_TEXTURED )
-	// texture coord0
-	v_TexCoord0=(m_TextureMatrix * vec3(a_TexCoord0,1.0)).st;
-#if defined( MX2_BUMPMAPPED )
-	// viewspace tangent matrix
-	v_TanMatrix[2]=v_Normal;
-	v_TanMatrix[0]=i_ModelViewNormalMatrix * a_Tangent.xyz;
-	v_TanMatrix[1]=cross( v_TanMatrix[0],v_TanMatrix[2] ) * a_Tangent.a;
-#endif
-#endif
-
-#endif	//MX2_COLORPASS
-	
-	gl_Position=i_ModelViewProjectionMatrix * a_Position;
-}
-
-#endif	//MX2_BONED
-
-//@fragment
-
-vec4 FloatToRGBA( float value ){
-
-	const float MaxFloat=0.9999999;
-
-	value=clamp( value,0.0,MaxFloat );
-
-	vec4 rgba=fract( vec4( 1.0, 255.0, 65025.0, 16581375.0 ) * value );
-	
-	return rgba-rgba.yzww * vec4( 1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0 );
-}
-
-float RGBAToFloat( vec4 rgba ){
-
-	return dot( rgba,vec4( 1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0 ) );
-}
-
-#if MX2_COLORPASS
-
-uniform float r_FogNear;
-uniform float r_FogFar;
-uniform vec4 r_FogColor;
-
-#if MX2_SHADOWEDPASS
-
-#if MX2_DIRECTIONAL_LIGHT
-
-float shadowColor(){
-
-	if( v_Position.z>=r_ShadowCSMSplits.w ) return 1.0;//(1.0-r_ShadowAlpha)*0.5;
-
-	vec4 vpos=vec4( v_Position,1.0 );
-	vec2 off;
-	
-	if( vpos.z<r_ShadowCSMSplits.x ){
-		vpos=r_ShadowMatrix0 * vpos;
-		off=vec2( 0.0,0.0 );
-	}else if( vpos.z<r_ShadowCSMSplits.y ){
-		vpos=r_ShadowMatrix1 * vpos;
-		off=vec2( 0.5,0.0 );
-	}else if( vpos.z<r_ShadowCSMSplits.z ){
-		vpos=r_ShadowMatrix2 * vpos;
-		off=vec2( 0.0,0.5 );
-	}else{
-		vpos=r_ShadowMatrix3 * vpos;
-		off=vec2( 0.5,0.5 );
-	}
-	
-	vec3 spos=vpos.xyz/vpos.w * vec3( 0.25,0.25,0.5 ) + vec3( 0.25,0.25,0.5 );
-
-#if defined( MX2_RGBADEPTHTEXTURES )
-	float d=RGBAToFloat( texture2D( r_ShadowCSMTexture,spos.xy+off ) );
-#else
-	float d=texture2D( r_ShadowCSMTexture,spos.xy+off ).r;
-#endif
-	
-	if( spos.z>d ) return 1.0-r_ShadowAlpha;
-	
-	return 1.0;
-}
-
-#else	//MX2_DIRECTIONAL_LIGHT
-
-float shadowColor(){
-
-	vec4 vpos=vec4( v_Position,1.0 );
-	
-	vec3 lpos=(r_ShadowMatrix0 * vpos).xyz;
-	
-	float d=RGBAToFloat( textureCube( r_ShadowCubeTexture,lpos ) );
-	
-	if( length(lpos) > d * r_LightRange ) return 1.0-r_ShadowAlpha;
-	
-	return 1.0;
-}
-
-#endif	//MX2_DIRECTIONAL_LIGHT
-
-#endif	//MX2_SHADOWEDPASS
-
-vec3 lighting( vec3 color,vec3 emissive,float metalness,float roughness,float occlusion,vec3 normal ){
-
-	const vec3 color0=vec3( 0.04,0.04,0.04 );
-	
-	float glosiness=1.0-roughness;
-	vec3 diffuse=color * (1.0-metalness);
-	vec3 specular=(color-color0) * metalness + color0;
-	
-	vec3 vvec=normalize( -v_Position );
-	float ndotv=dot( normal,vvec );
-	
-	vec3 frag=vec3( 0.0 );
-	
-#if MX2_AMBIENTPASS
-
-	//ambient color
-	vec3 rvec=r_EnvMatrix * reflect( v_Position,normal );
-	
-	float lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
-	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
-//	float lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
-//	if( lod==0.0 ) lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
-
-	vec3 ambEnv=pow( textureCube( r_EnvTexture,rvec,max( roughness*r_EnvTextureMaxLod-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
-	
-	vec3 fschlick0=specular + (1.0-specular) * pow( 1.0-ndotv,5.0 ) * glosiness;
-	
-	vec3 ambDiffuse=diffuse * r_AmbientDiffuse.rgb;
-	
-	vec3 ambSpecular=fschlick0 * ambEnv;
-
-	frag+=( ambDiffuse + ambSpecular ) * occlusion + emissive;
-
-#endif
-
-#if MX2_LIGHTINGPASS
-
-	//lighting color
-	float spow=pow( 2.0,glosiness * 12.0 );				//specular power
-//	float spow=pow( 4096.0,glosiness );
-	float fnorm=(spow+2.0)/8.0;							//normalization factor
-	
-#if MX2_DIRECTIONAL_LIGHT
-	vec3 lvec=normalize( -r_LightViewMatrix[2].xyz );
-	float atten=1.0;
-#else
-	vec3 lvec=r_LightViewMatrix[3].xyz-v_Position;
-	float atten=max( 1.0-length( lvec )/r_LightRange,0.0 );
-	lvec=normalize( lvec );
-#endif
-
-	vec3 hvec=normalize( lvec+vvec );
-
-	float ndotl=max( dot( normal,lvec ),0.0 );
-	float ndoth=max( dot( normal,hvec ),0.0 );
-	float hdotl=max( dot( hvec,lvec ),0.0 );
-	
-	vec3 fschlick=specular + (1.0-specular) * pow( 1.0-hdotl,5.0 ) * glosiness;
-	
-	vec3 fspecular=fschlick * pow( ndoth,spow ) * fnorm;
-	
-	vec3 light=r_LightColor.rgb * ndotl * atten;
-	
-	light=(diffuse+fspecular) * light;
-
-#if MX2_SHADOWEDPASS
-
-	light*=shadowColor();
-	
-#endif
-
-	frag+=light;
-
-#endif	//MX2_LIGHTINGPASS
-
-	return frag;
-}
-
-#if defined( MX2_TEXTURED )
-uniform sampler2D m_ColorTexture;
-uniform sampler2D m_EmissiveTexture;
-uniform sampler2D m_MetalnessTexture;
-uniform sampler2D m_RoughnessTexture;
-uniform sampler2D m_OcclusionTexture;
-uniform sampler2D m_NormalTexture;
-#endif
-
-uniform vec4 m_ColorFactor;
-uniform vec4 m_EmissiveFactor;
-uniform float m_MetalnessFactor;
-uniform float m_RoughnessFactor;
-
-void main(){
-
-#if defined( MX2_TEXTURED )
-	vec4 rgba=texture2D( m_ColorTexture,v_TexCoord0 );
-	vec3 color=pow( rgba.rgb,vec3( 2.2 ) ) * m_ColorFactor.rgb;
-	vec3 emissive=pow( texture2D( m_EmissiveTexture,v_TexCoord0 ).rgb,vec3( 2.2 ) ) * m_EmissiveFactor.rgb;
-	float metalness=texture2D( m_MetalnessTexture,v_TexCoord0 ).b * m_MetalnessFactor;
-	float roughness=texture2D( m_RoughnessTexture,v_TexCoord0 ).g * m_RoughnessFactor;
-	float occlusion=texture2D( m_OcclusionTexture,v_TexCoord0 ).r;
-	float alpha=rgba.a * m_ColorFactor.a;
-	
-#if defined( MX2_BUMPMAPPED )
-	vec3 normal=texture2D( m_NormalTexture,v_TexCoord0 ).xyz * 2.0 - 1.0;
-	normal=normalize( v_TanMatrix * normal );
-#else
-	vec3 normal=normalize( v_Normal );
-#endif
-	
-#else
-	vec3 color=m_ColorFactor.rgb;
-	vec3 emissive=m_EmissiveFactor.rgb;
-	float metalness=m_MetalnessFactor;
-	float roughness=m_RoughnessFactor;
-	float occlusion=1.0;
-	float alpha=m_ColorFactor.a;
-	
-	vec3 normal=normalize( v_Normal );
-#endif
-
-	//perform lighting
-	vec3 frag=lighting( color*v_Color.rgb,emissive,metalness,roughness,occlusion,normal );
-	
-	alpha*=v_Color.a;
-	
-	frag*alpha;
-	
-	//apply fog
-	float fog=clamp( (length( v_Position )-r_FogNear)/(r_FogFar-r_FogNear),0.0,1.0 ) * r_FogColor.a;
-
-#if MX2_AMBIENTPASS
-	frag=mix( frag,r_FogColor.rgb,fog );
-#else
-	frag=mix( frag,vec3(0.0),fog );
-#endif
-	alpha=mix( alpha,1.0,fog );
-
-#if defined( MX2_SRGBOUTPUT )
-	gl_FragColor=vec4( pow( frag,vec3( 1.0/2.2 ) ),alpha );
-#else
-	gl_FragColor=vec4( frag,alpha );
-#endif
-
-}
-
-#else	//MX2_COLORPASS
-
-void main(){
-
-#if MX2_POINT_LIGHT
-	gl_FragColor=FloatToRGBA( min( length( v_Position )/r_LightRange,1.0 ) );
-#elif defined( MX2_RGBADEPTHTEXTURES )
-	gl_FragColor=FloatToRGBA( gl_FragCoord.z ),1.0 );
-#else
-	gl_FragColor=vec4( vec3( gl_FragCoord.z ),1.0 );
-#endif
-
-}
-
-#endif	//MX2_COLORPASS

+ 0 - 75
modules/mojo3d/assets/shaders/material-sprite.glsl

@@ -1,75 +0,0 @@
-
-//@renderpasses 1,3
-
-//render uniforms
-
-uniform vec4 r_FogColor;
-
-uniform float r_FogNear;
-
-uniform float r_FogFar;
-
-//material uniforms
-
-uniform mat3 m_TextureMatrix;
-
-//instance uniforms...
-
-uniform mat4 i_ModelViewProjectionMatrix;
-
-uniform mat4 i_ModelViewMatrix;
-
-uniform float i_Alpha;
-
-//varyings...
-
-varying vec3 v_Position;
-varying vec2 v_TexCoord0;
-
-//@vertex
-
-attribute vec4 a_Position;
-
-attribute vec2 a_TexCoord0;
-
-void main(){
-
-	v_Position=(i_ModelViewMatrix * a_Position).xyz;
-
-	v_TexCoord0=(m_TextureMatrix * vec3(a_TexCoord0,1.0)).st;
-	
-	gl_Position=i_ModelViewProjectionMatrix * a_Position;
-}
-
-//@fragment
-
-uniform sampler2D m_ColorTexture;
-
-uniform vec4 m_ColorFactor;
-
-uniform float m_AlphaDiscard;
-
-void main(){
-
-	vec4 color=texture2D( m_ColorTexture,v_TexCoord0 );
-
-	float alpha=color.a * m_ColorFactor.a * i_Alpha;
-	
-	if( alpha<m_AlphaDiscard ) discard;
-
-	vec3 frag=pow( color.rgb,vec3( 2.2 ) ) * m_ColorFactor.rgb;
-	
-	float fog=clamp( (length( v_Position )-r_FogNear)/(r_FogFar-r_FogNear),0.0,1.0 ) * r_FogColor.a;
-	
-	frag=mix( frag,r_FogColor.rgb,fog );
-	
-	alpha*=1.0-fog;
-	
-	frag*=alpha;
-	
-#if defined( MX2_SRGBOUTPUT )
-	gl_FragColor=vec4( pow( frag,vec3( 1.0/2.2 ) ),alpha );
-#else
-	gl_FragColor=vec4( frag,alpha );
-#endif
-}

+ 0 - 125
modules/mojo3d/assets/shaders/material-water.glsl

@@ -1,125 +0,0 @@
-//@renderpasses 1
-
-//material uniforms
-
-uniform mat3 m_TextureMatrix;
-
-//renderer uniforms
-
-uniform mat4 i_ModelViewMatrix;
-uniform mat4 i_ModelViewProjectionMatrix;
-uniform mat3 i_ModelViewNormalMatrix;
-
-uniform vec4 r_AmbientDiffuse;
-uniform samplerCube r_EnvTexture;
-uniform mat3 r_EnvMatrix;
-
-//pbr varyings...
-
-varying vec3 v_Position;
-varying vec2 v_TexCoord0;
-varying vec3 v_Normal;
-varying mat3 v_TanMatrix;
-
-//@vertex
-
-//vertex attribs....
-
-attribute vec4 a_Position;
-
-attribute vec2 a_TexCoord0;
-attribute vec3 a_Normal;
-attribute vec4 a_Tangent;
-
-void main(){
-
-	// texture coord0
-	v_TexCoord0=(m_TextureMatrix * vec3(a_TexCoord0,1.0)).st;
-
-	// view space position
-	v_Position=( i_ModelViewMatrix * a_Position ).xyz;
-
-	// viewspace normal
-	v_Normal=i_ModelViewNormalMatrix * a_Normal;
-	
-	// viewspace tangent matrix
-	v_TanMatrix[2]=v_Normal;
-	v_TanMatrix[0]=i_ModelViewNormalMatrix * a_Tangent.xyz;
-	v_TanMatrix[1]=cross( v_TanMatrix[0],v_TanMatrix[2] ) * a_Tangent.a;
-	
-	gl_Position=i_ModelViewProjectionMatrix * a_Position;
-}
-
-//@fragment
-
-void main0( vec3 color,vec3 emissive,float metalness,float roughness,float occlusion,vec3 normal ){
-
-	normal=normalize( v_TanMatrix * normal );
-
-	vec3 color0=vec3( 0.04,0.04,0.04 );
-	
-	vec3 diffuse=color * (1.0-metalness);
-	
-	vec3 specular=(color-color0) * metalness + color0;
-	
-	vec3 rvec=r_EnvMatrix * reflect( v_Position,normal );
-	
-	float lod=textureCube( r_EnvTexture,rvec,10.0 ).a * 255.0 - 10.0;
-	
-	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
-	
-	vec3 env=pow( textureCube( r_EnvTexture,rvec,max( roughness*10.0-lod,0.0 ) ).rgb,vec3( 2.2 ) );
-
-	vec3 vvec=normalize( -v_Position );
-	
-	float ndotv=max( dot( normal,vvec ),0.0 );
-	
-	vec3 fschlick=specular + (1.0-specular) * pow( 1.0-ndotv,5.0 ) * (1.0-roughness);
-
-	vec3 ambdiff=diffuse * r_AmbientDiffuse.rgb;
-		
-	vec3 ambspec=env * fschlick;
-	
-	vec3 frag=(ambdiff+ambspec) * occlusion + emissive;
-	
-	gl_FragData[0]=vec4( min( frag,8.0 ),1.0 );
-	
-	gl_FragData[1]=vec4( color,metalness );
-	
-	gl_FragData[2]=vec4( normal * 0.5 + 0.5,roughness );
-}
-
-uniform float r_Time;
-
-uniform sampler2D m_ColorTexture;
-uniform vec4 m_ColorFactor;
-
-uniform float m_Metalness;
-uniform float m_Roughness;
-
-uniform sampler2D m_NormalTexture0;
-uniform sampler2D m_NormalTexture1;
-
-uniform vec2 m_Velocity0;
-uniform vec2 m_Velocity1;
-
-void main(){
-
-	vec3 color=pow( texture2D( m_ColorTexture,v_TexCoord0 ).rgb,vec3( 2.2 ) ) * m_ColorFactor.rgb;
-
-	vec3 normal0=texture2D( m_NormalTexture0,v_TexCoord0 + m_Velocity0 * r_Time ).xyz * 2.0 - 1.0;
-	
-	vec3 normal1=texture2D( m_NormalTexture1,v_TexCoord0 + m_Velocity1 * r_Time ).xyz * 2.0 - 1.0;
-	
-	vec3 normal=normalize( normal0+normal1 );
-	
-	vec3 emissive=vec3( 0.0 );
-	
-	float metalness=m_Metalness;
-	
-	float roughness=m_Roughness;
-	
-	float occlusion=1.0;
-
-	main0( color,emissive,metalness,roughness,occlusion,normal );
-}

+ 6 - 41
modules/mojo3d/assets/shaders/material-particle.glsl → modules/mojo3d/assets/shaders/materials/particle.glsl

@@ -1,56 +1,21 @@
 
-//@renderpasses 1,3
+//@renderpasses 2,6,10
 
-//renderer uniforms
-
-uniform float r_Time;
-
-uniform mat4 r_ProjectionMatrix;
-
-uniform mat4 r_ViewMatrix;
-
-uniform vec4 r_FogColor;
-
-uniform float r_FogNear;
-
-uniform float r_FogFar;
-
-//instance uniforms
-
-uniform mat4 i_ModelViewMatrix;
-
-uniform mat4 i_ModelMatrix;
-
-uniform float i_Alpha;
+//@import "std"
 
 //material uniforms
-
+//
 uniform sampler2D m_ColorTexture;
-
 uniform vec4 m_ColorFactor;
 
-//pbuffer uniforms
-
+//buffer uniforms
+//
 uniform vec3 x_Gravity;		//gravity of particle
-
 uniform float x_Duration;	//duration of particle
-
 uniform float x_Fade;		//start fade out time
 
-//varyings...
-
-varying vec3 v_Position;
-
-varying vec4 v_Color;
-
 //@vertex
 
-attribute vec3 a_Position;		//velocity
-
-attribute vec2 a_TexCoord0;		//s=time, t=size
-
-attribute vec4 a_Tangent;		//color
-
 void main(){
 
 	float t=(r_Time-a_TexCoord0.s);
@@ -59,7 +24,7 @@ void main(){
 
 	v_Color=m_ColorFactor * vec4( a_Tangent.rgb,a_Tangent.a * a * i_Alpha );
 	
-	vec4 position=i_ModelMatrix * vec4( a_Position * t,1.0 );
+	vec4 position=i_ModelMatrix * vec4( a_Position.xyz * t,1.0 );
 	
 	position.xyz+=x_Gravity * t * t * .5;
 	

+ 79 - 0
modules/mojo3d/assets/shaders/materials/pbr-default.glsl

@@ -0,0 +1,79 @@
+
+//@renderpasses 1,7,11,2,6,10
+
+//@import "pbr"
+
+//@vertex
+
+void main(){
+
+	transformVertex();
+}
+
+//@fragment
+
+#if MX2_COLORPASS
+
+#if MX2_TEXTURED
+uniform sampler2D m_ColorTexture;
+uniform sampler2D m_AmbientTexture;
+uniform sampler2D m_EmissiveTexture;
+uniform sampler2D m_MetalnessTexture;
+uniform sampler2D m_RoughnessTexture;
+uniform sampler2D m_OcclusionTexture;
+#if MX2_BUMPMAPPED
+uniform sampler2D m_NormalTexture;
+#endif
+#endif
+
+uniform vec4 m_ColorFactor;
+uniform vec4 m_AmbientFactor;
+uniform vec4 m_EmissiveFactor;
+uniform float m_MetalnessFactor;
+uniform float m_RoughnessFactor;
+
+void main(){
+
+#if MX2_TEXTURED
+	vec4 color=texture2D( m_ColorTexture,v_TexCoord0 );
+	color.rgb=pow( color.rgb,vec3( 2.2 ) );
+	color*=m_ColorFactor;
+	
+	vec3 ambient=pow( texture2D( m_AmbientTexture,v_TexCoord1 ).rgb,vec3( 2.2 ) ) * m_AmbientFactor.rgb;
+	
+	vec3 emissive=pow( texture2D( m_EmissiveTexture,v_TexCoord0 ).rgb,vec3( 2.2 ) ) * m_EmissiveFactor.rgb;
+	
+	float metalness=texture2D( m_MetalnessTexture,v_TexCoord0 ).b * m_MetalnessFactor;
+	
+	float roughness=texture2D( m_RoughnessTexture,v_TexCoord0 ).g * m_RoughnessFactor;
+	
+	float occlusion=texture2D( m_OcclusionTexture,v_TexCoord0 ).r;
+	
+#if MX2_BUMPMAPPED
+	vec3 normal=texture2D( m_NormalTexture,v_TexCoord0 ).xyz * 2.0 - 1.0;
+	normal=normalize( v_TanMatrix * normal );
+#else
+	vec3 normal=normalize( v_Normal );
+#endif
+
+#else	//untextured...
+
+	vec4 color=m_ColorFactor;
+	
+	vec3 ambient=m_AmbientFactor.rgb;
+	
+	vec3 emissive=m_EmissiveFactor.rgb;
+	
+	float metalness=m_MetalnessFactor;
+	
+	float roughness=m_RoughnessFactor;
+	
+	float occlusion=1.0;
+	
+	vec3 normal=normalize( v_Normal );
+#endif
+
+	emitPbrFragment( color,ambient,emissive,metalness,roughness,occlusion,normal );
+}
+
+#endif

+ 26 - 0
modules/mojo3d/assets/shaders/materials/sprite.glsl

@@ -0,0 +1,26 @@
+
+//@renderpasses 2,6,10
+
+//@import "std"
+
+//@vertex
+
+void main(){
+
+	transformSpriteVertex();
+}
+
+//@fragment
+
+uniform sampler2D m_ColorTexture;
+uniform vec4 m_ColorFactor;
+uniform float m_AlphaDiscard;
+
+void main(){
+
+	vec4 color=texture2D( m_ColorTexture,v_TexCoord0 ) * m_ColorFactor;
+	
+	if( color.a<m_AlphaDiscard ) discard;
+		
+	emitColorFragment( color );
+}

+ 54 - 0
modules/mojo3d/assets/shaders/materials/water.glsl

@@ -0,0 +1,54 @@
+
+//@renderpasses 1
+
+//@import "pbr"
+
+//@vertex
+
+void main(){
+
+	transformVertex();
+}
+
+//@fragment
+
+#if MX2_COLORPASS
+
+uniform sampler2D m_ColorTexture;
+uniform vec4 m_ColorFactor;
+
+uniform float m_Metalness;
+uniform float m_Roughness;
+
+uniform sampler2D m_NormalTexture0;
+uniform sampler2D m_NormalTexture1;
+
+uniform vec2 m_Velocity0;
+uniform vec2 m_Velocity1;
+
+void main(){
+
+	vec4 color=texture2D( m_ColorTexture,v_TexCoord0 );
+	color.rgb=pow( color.rgb,vec3( 2.2 ) );
+	color*=m_ColorFactor;
+
+	vec3 normal0=texture2D( m_NormalTexture0,v_TexCoord0 + m_Velocity0 * r_Time ).xyz * 2.0 - 1.0;
+	
+	vec3 normal1=texture2D( m_NormalTexture1,v_TexCoord0 + m_Velocity1 * r_Time ).xyz * 2.0 - 1.0;
+	
+	vec3 normal=normalize( v_TanMatrix * vec3( normal0+normal1 ) );
+	
+	vec3 ambient=vec3( 0.0 );
+	
+	vec3 emissive=vec3( 0.0 );
+	
+	float metalness=0.0;
+	
+	float roughness=0.0;
+	
+	float occlusion=1.0;
+
+	emitPbrFragment( color,ambient,emissive,metalness,roughness,occlusion,normal );
+}
+
+#endif

+ 26 - 0
modules/mojo3d/assets/shaders/misc/copy.glsl

@@ -0,0 +1,26 @@
+
+//@renderpasses 0
+
+uniform sampler2D r_SourceBuffer;
+uniform vec2 r_SourceBufferScale;
+
+varying vec2 v_SourceBufferCoords;
+
+//@vertex
+
+attribute vec2 a_Position;
+attribute vec2 a_TexCoord0;
+
+void main(){
+
+	v_SourceBufferCoords=a_TexCoord0 * r_SourceBufferScale;
+
+	gl_Position=vec4( a_Position*2.0-1.0,-1.0,1.0 );
+}
+
+//@fragment
+
+void main(){
+
+	gl_FragColor=vec4( pow( texture2D( r_SourceBuffer,v_SourceBufferCoords ).rgb,vec3( 1.0/2.2 ) ),1.0 );
+}

+ 35 - 0
modules/mojo3d/assets/shaders/misc/fog-deferred.glsl

@@ -0,0 +1,35 @@
+
+//@renderpasses 0
+
+//@import "std"
+
+//@vertex
+
+void main(){
+
+	transformQuadVertex();
+}
+
+//@fragment
+
+void main(){
+
+	float fog=0.0;
+
+	float depth=texture2D( r_DepthBuffer,v_BufferCoords ).r;
+	
+	if( depth<1.0 ){
+
+		depth=viewDepth( depth );
+		
+		vec4 vpos4=r_InverseProjectionMatrix * vec4( v_ClipPosition,-1.0,1.0 );
+		
+		vec3 vpos=vpos4.xyz/vpos4.w;
+		
+		vec3 position=vpos/vpos.z*depth;
+		
+		fog=clamp( (length( position )-r_FogNear)/(r_FogFar-r_FogNear),0.0,1.0 ) * r_FogColor.a;
+	}
+	
+	gl_FragColor=vec4( r_FogColor.rgb * fog,fog );
+}

+ 28 - 0
modules/mojo3d/assets/shaders/misc/lighting-deferred.glsl

@@ -0,0 +1,28 @@
+
+//@renderpasses 4,8,20,24
+
+//@import "pbr"
+
+//@vertex
+
+void main(){
+
+	transformQuadVertex();
+}
+
+//@fragment
+
+void main(){
+
+	vec4 color_m=texture2D( r_ColorBuffer,v_BufferCoords );
+	
+	vec4 normal_r=texture2D( r_NormalBuffer,v_BufferCoords );
+	
+	vec3 position=fragmentPosition();
+
+	vec3 normal=normalize( normal_r.xyz * 2.0 - 1.0 );
+	
+	emitPbrFragment( color_m.rgb,color_m.a,normal_r.a,position,normal );
+}
+
+

+ 7 - 15
modules/mojo3d/assets/shaders/skybox-deferred.glsl → modules/mojo3d/assets/shaders/misc/skybox.glsl

@@ -1,27 +1,17 @@
 
 //@renderpasses 0
 
-varying vec2 v_ClipPosition;
+//@import "std"
 
 //@vertex
 
-attribute vec2 a_Position;	//0...1
-
 void main(){
 
-	v_ClipPosition=a_Position * 2.0 - 1.0;
-
-	gl_Position=vec4( v_ClipPosition,1.0,1.0 );
+	transformQuadVertex();
 }
 
 //@fragment
 
-uniform mat3 r_EnvMatrix;
-
-uniform samplerCube r_SkyTexture;
-
-uniform mat4 r_InverseProjectionMatrix;
-
 void main(){
 
 	vec4 clip=r_InverseProjectionMatrix * vec4( v_ClipPosition,1.0,1.0 );
@@ -30,9 +20,11 @@ void main(){
 	
 	vec3 frag=pow( textureCube( r_SkyTexture,tv ).rgb,vec3( 2.2 ) );
 	
+#if MX2_DEFERREDRENDERER
 	gl_FragData[0]=vec4( frag,1.0 );					//accum
-	
 	gl_FragData[1]=vec4( 0.0,0.0,0.0,1.0 );				//color_m
-	
-	gl_FragData[2]=vec4( 0.5,0.5,1.0,1.0 );				//normal_r
+	gl_FragData[2]=vec4( 0.5,0.5,0.5,1.0 );				//normal_r
+#else
+	emitLinearFragment( frag,1.0 );
+#endif
 }

+ 0 - 38
modules/mojo3d/assets/shaders/skybox.glsl

@@ -1,38 +0,0 @@
-
-//@renderpasses 0
-
-varying vec2 v_ClipPosition;
-
-//@vertex
-
-attribute vec2 a_Position;	//0...1
-
-void main(){
-
-	v_ClipPosition=a_Position * 2.0 - 1.0;
-
-	gl_Position=vec4( v_ClipPosition,1.0,1.0 );
-}
-
-//@fragment
-
-uniform mat3 r_EnvMatrix;
-
-uniform samplerCube r_SkyTexture;
-
-uniform mat4 r_InverseProjectionMatrix;
-
-void main(){
-
-	vec4 clip=r_InverseProjectionMatrix * vec4( v_ClipPosition,1.0,1.0 );
-
-	vec3 tv=r_EnvMatrix * (clip.xyz/clip.w);
-	
-	vec3 color=textureCube( r_SkyTexture,tv ).rgb;
-	
-#if defined( MX2_LINEAROUTPUT )
-	gl_FragColor=vec4( pow( color,vec3( 2.2 ) ),1.0 );
-#else
-	gl_FragColor=vec4( color,1.0 );
-#endif
-}

+ 7 - 2
modules/mojo3d/loader/gltf2loader.monkey2

@@ -162,7 +162,11 @@ Class Gltf2Loader
 	
 	Method GetMaterial:Material( material:Gltf2Material,textured:Bool,boned:Bool )
 		
-		If Not material Return New PbrMaterial( Color.Magenta,0,1,boned )
+		If Not material
+			Local mat:=New PbrMaterial( Color.Magenta,0,1 )
+			mat.Boned=boned
+			Return mat
+		Endif
 		
 		If _materialCache.Contains( material ) Return _materialCache[material]
 		
@@ -180,7 +184,8 @@ Class Gltf2Loader
 			normalTexture=GetTexture( material.normalTexture )
 		Endif
 			
-		Local mat:=New PbrMaterial( boned )
+		Local mat:=New PbrMaterial
+		mat.Boned=boned
 		
 		mat.Name=material.name
 		

+ 1 - 1
modules/mojo3d/mojo3d.monkey2

@@ -51,6 +51,7 @@ Using reflection..
 
 #Import "scene/effects/bloomeffect"
 #Import "scene/effects/monochromeeffect"
+#Import "scene/effects/reflectioneffect"
 
 #Import "scene/jsonifier/jsonifier"
 #Import "scene/jsonifier/invocation"
@@ -60,7 +61,6 @@ Using reflection..
 #Import "scene/mesh"
 #Import "scene/meshprims"
 #Import "scene/bttypeconvs"
-'#Import "scene/util3d"
 
 #Import "render/renderer"
 #Import "render/renderqueue"

+ 116 - 67
modules/mojo3d/render/renderer.monkey2

@@ -14,20 +14,14 @@ Class Renderer
 		
 		Select GetConfig( "MOJO3D_RENDERER" )
 		Case "deferred"
-			
 			_deferred=True
-			
 		Case "forward"
-			
 			_deferred=False
-		
 		Default
 			
 #If __DESKTOP_TARGET__ Or __WEB_TARGET__
-
 			_deferred=True
 #else
-
 			_deferred=False
 #endif
 		End
@@ -39,6 +33,10 @@ Class Renderer
 		Else
 			Print "Renderer is using forward rendering"
 		Endif
+		
+		If _deferred _defs="MX2_DEFERREDRENDERER" Else _defs="MX2_FORWARDRENDERER"
+		
+		_defs+=";MX2_LINEAROUTPUT"
 	End
 	
 	#rem monkeydoc True if renderer is using deferred rendering.
@@ -52,7 +50,7 @@ Class Renderer
 	#end
 	Property ShaderDefs:String()
 		
-		Return "MX2_LINEAROUTPUT=1~n"'MX2_RGBADEPTHTEXTURES=1~n"
+		Return _defs
 	End
 	
 	#rem monkeydoc Size of the cascaded shadow map texture.
@@ -156,13 +154,14 @@ Class Renderer
 	
 	Method RenderDeferredLighting( light:Light )
 		
-		Local renderPass:=2
+		Local renderPass:=0
 		
 		Select light.Type
 		Case LightType.Directional
-			If light.CastsShadow RenderCSMShadows( light ) ; renderPass|=4
+			If light.CastsShadow RenderCSMShadows( light ) ; renderPass|=16
+			renderPass|=4
 		Case LightType.Point
-			If light.CastsShadow RenderPSMShadows( light ) ; renderPass|=4
+			If light.CastsShadow RenderPSMShadows( light ) ; renderPass|=16
 			renderPass|=8
 		End
 		
@@ -211,13 +210,14 @@ Class Renderer
 		
 		For Local light:=Eachin _scene.Lights
 			
-			Local renderPass:=first ? 3 Else 2
+			Local renderPass:=2
 			
 			Select light.Type
 			Case LightType.Directional			
-				If light.CastsShadow RenderCSMShadows( light ) ; renderPass|=4
+				If light.CastsShadow RenderCSMShadows( light ) ; renderPass|=16
+				renderPass|=4
 			Case LightType.Point
-				If light.CastsShadow RenderPSMShadows( light ) ; renderPass|=4
+				If light.CastsShadow RenderPSMShadows( light ) ; renderPass|=16
 				renderPass|=8
 			End
 			
@@ -241,7 +241,7 @@ Class Renderer
 			_gdevice.DepthMask=True
 			_gdevice.DepthFunc=DepthFunc.LessEqual
 			_gdevice.BlendMode=BlendMode.Opaque
-			_gdevice.RenderPass=1
+			_gdevice.RenderPass=2
 			
 			RenderOpaqueOps()
 		Endif
@@ -276,6 +276,16 @@ Class Renderer
 			RenderOpaqueForward()
 		Endif
 	End
+	
+	Method RenderSelfIlluminated()
+		
+		_gdevice.ColorMask=ColorMask.All
+		_gdevice.DepthMask=True
+		_gdevice.DepthFunc=DepthFunc.LessEqual
+		_gdevice.RenderPass=1
+		
+		RenderSelfIlluminatedOps()
+	End
 
 	Method RenderTransparent()
 
@@ -283,13 +293,14 @@ Class Renderer
 		
 		For Local light:=Eachin _scene.Lights
 			
-			Local renderPass:=first ? 3 Else 2	'amgient+light or just light
+			Local renderPass:=2
 			
 			Select light.Type
 			Case LightType.Directional			
-	'			If light.CastsShadow RenderCSMShadows( light ) ; renderPass|=4
+	'			If light.CastsShadow RenderCSMShadows( light ) ; renderPass|=16
+				renderPass|=4
 			Case LightType.Point
-	'			If light.CastsShadow RenderPSMShadows( light ) ; renderPass|=4
+	'			If light.CastsShadow RenderPSMShadows( light ) ; renderPass|=16
 				renderPass|=8
 			End
 			
@@ -313,7 +324,7 @@ Class Renderer
 			_gdevice.ColorMask=ColorMask.All
 			_gdevice.DepthMask=False
 			_gdevice.DepthFunc=DepthFunc.LessEqual
-			_gdevice.RenderPass=1
+			_gdevice.RenderPass=2
 			
 			RenderTransparentOps()
 		Endif
@@ -339,7 +350,7 @@ Class Renderer
 		_gdevice.DepthFunc=DepthFunc.LessEqual
 		_gdevice.BlendMode=BlendMode.Opaque
 		_gdevice.CullMode=CullMode.Front
-		_gdevice.RenderPass=4
+		_gdevice.RenderPass=3|4
 
 		Local invLightMatrix:=light.InverseMatrix
 		
@@ -411,7 +422,7 @@ Class Renderer
 		_gdevice.DepthFunc=DepthFunc.LessEqual
 		_gdevice.BlendMode=BlendMode.Opaque
 		_gdevice.CullMode=CullMode.Back'Front
-		_gdevice.RenderPass=12
+		_gdevice.RenderPass=3|8
 		
 		Local lnear:=0.1
 		
@@ -440,37 +451,63 @@ Class Renderer
 		_gdevice.Scissor=t_scissor
 	End
 	
+	Method FlipEffectBuffers()
+		
+		If _direct Return
+		
+		Local rsize:=_gdevice.Viewport.Size
+		Local rtarget:=_gdevice.RenderTarget
+		Local rtexture:=rtarget.GetColorTexture( 0 )
+		_runiforms.SetTexture( "SourceBuffer",rtexture )
+		_runiforms.SetVec2f( "SourceBufferSize",Cast<Vec2f>( rsize ) )
+		_runiforms.SetVec2f( "SourceBufferScale",Cast<Vec2f>( rsize )/Cast<Vec2f>( rtexture.Size ) )
+		
+		If Not _effectBuffer Or rsize.x>_effectBuffer.Size.x Or rsize.y>_effectBuffer.Size.y
+			_effectTarget?.Discard()
+			_effectBuffer?.Discard()
+			_effectBuffer=New Texture( rsize.x,rsize.y,rtexture.Format,TextureFlags.Dynamic|TextureFlags.Filter )
+			_effectTarget=New RenderTarget( New Texture[]( _effectBuffer ),Null )
+		Endif
+		
+		rtarget=rtarget<>_effectTarget ? _effectTarget Else _renderTarget1
+		
+		_gdevice.RenderTarget=rtarget
+	End
+	
 	Method RenderPostEffects()
 		
-		_gdevice.ColorMask=ColorMask.All
-		_gdevice.DepthMask=False
-		_gdevice.DepthFunc=DepthFunc.Always
-		_gdevice.CullMode=CullMode.None
-
+		PostEffect.BeginRendering( _gdevice,Self )
+		
 		For Local effect:=Eachin _scene.PostEffects
 			
 			If Not effect.Enabled Continue
 			
+			FlipEffectBuffers()
+
+			_gdevice.ColorMask=ColorMask.All
+			_gdevice.DepthMask=False
+			_gdevice.DepthFunc=DepthFunc.Always
+			_gdevice.CullMode=CullMode.None
 			_gdevice.BlendMode=BlendMode.Opaque
 			_gdevice.RenderPass=0
 			
-			effect.Render( _gdevice )
+			effect.Render()
 		Next
-		
-	End
-	
-	Method RenderCopyQuad() Virtual
-		If _outputRenderTarget
-			RenderInvertedQuad()
-		Else
-			RenderQuad()
-		Endif
+
+		PostEffect.EndRendering()
 	End
 	
 	Method RenderCopy()
 		
 		If _direct Return
 		
+		Local rsize:=_gdevice.Viewport.Size
+		Local rtarget:=_gdevice.RenderTarget
+		Local rtexture:=rtarget.GetColorTexture( 0 )
+		_runiforms.SetTexture( "SourceBuffer",rtexture )
+		_runiforms.SetVec2f( "SourceBufferSize",Cast<Vec2f>( rsize ) )
+		_runiforms.SetVec2f( "SourceBufferScale",Cast<Vec2f>( rsize )/Cast<Vec2f>( rtexture.Size ) )
+
 		_gdevice.RenderTarget=_outputRenderTarget
 		_gdevice.Resize( _outputRenderTargetSize )
 		_gdevice.Viewport=_outputViewport
@@ -489,27 +526,36 @@ Class Renderer
 		_gdevice.RenderTarget=Null
 		_gdevice.Resize( Null )
 	End
+	
+	Method RenderCopyQuad() Virtual	'So VRRenderer can override, ie: cheeze it for now!
 
-	Method RenderQuad()
+		If _outputRenderTarget
+			RenderInvertedQuad()
+		Else
+			RenderQuad()
+		Endif
+	End
+	
+	Method RenderInvertedQuad()
 
 		Global _vertices:=New VertexBuffer( New Vertex3f[](
-			New Vertex3f( 0,1,0,0,1 ),
-			New Vertex3f( 1,1,0,1,1 ),
-			New Vertex3f( 1,0,0,1,0 ),
-			New Vertex3f( 0,0,0,0,0 ) ) )
+			New Vertex3f( 0,1,0,0,0 ),
+			New Vertex3f( 1,1,0,1,0, ),
+			New Vertex3f( 1,0,0,1,1 ),
+			New Vertex3f( 0,0,0,0,1 ) ) )
 			
 		_gdevice.VertexBuffer=_vertices
 		
 		_gdevice.Render( 4,1 )
 	End
 	
-	Method RenderInvertedQuad()
+	Method RenderQuad()
 
 		Global _vertices:=New VertexBuffer( New Vertex3f[](
-			New Vertex3f( 0,1,0,0,0 ),
-			New Vertex3f( 1,1,0,1,0, ),
-			New Vertex3f( 1,0,0,1,1 ),
-			New Vertex3f( 0,0,0,0,1 ) ) )
+			New Vertex3f( 0,1,0,0,1 ),
+			New Vertex3f( 1,1,0,1,1 ),
+			New Vertex3f( 1,0,0,1,0 ),
+			New Vertex3f( 0,0,0,0,0 ) ) )
 			
 		_gdevice.VertexBuffer=_vertices
 		
@@ -541,6 +587,11 @@ Class Renderer
 		RenderRenderOps( _renderQueue.OpaqueOps,_viewMatrix,_projMatrix )
 	End
 	
+	Method RenderSelfIlluminatedOps()
+		
+		RenderRenderOps( _renderQueue.SelfIlluminatedOps,_viewMatrix,_projMatrix )
+	End
+	
 	Method RenderTransparentOps()
 		
 		RenderRenderOps( _renderQueue.TransparentOps,_viewMatrix,_projMatrix )
@@ -554,7 +605,7 @@ Class Renderer
 		_runiforms.SetMat4f( "ProjectionMatrix",projMatrix )
 		_runiforms.SetMat4f( "ViewProjectionMatrix",viewProjMatrix )
 		_runiforms.SetMat4f( "InverseProjectionMatrix",-projMatrix )
-		
+
 		Local instance:Entity=Null,first:=True
 		Local material:Material
 		Local bones:Mat4f[]
@@ -578,26 +629,21 @@ Class Renderer
 				_iuniforms.SetMat4f( "ModelViewProjectionMatrix",modelViewProjMat )
 				_iuniforms.SetColor( "Color",instance ? instance.Color Else Color.White )
 				_iuniforms.SetFloat( "Alpha",instance ? instance.Alpha Else 1.0 )
-				
 			Endif
 				
-			If op.bones _iuniforms.SetMat4fArray( "ModelBoneMatrices",op.bones )
+			If op.bones
+				_iuniforms.SetMat4fArray( "ModelBoneMatrices",op.bones )
+			Endif
 				
-			If op.uniforms _gdevice.BindUniformBlock( op.uniforms )
+			If op.uniforms 
+				_gdevice.BindUniformBlock( op.uniforms )
+			Endif
 						
 			If op.material<>material
-				
 				material=op.material
-				
-				If op.blendMode=BlendMode.Opaque
-					_gdevice.Shader=material.GetOpaqueShader()
-				Else
-					_gdevice.Shader=material.GetTransparentShader()
-				Endif
-				
+				_gdevice.Shader=op.shader
 				_gdevice.BindUniformBlock( material.Uniforms )
 				_gdevice.CullMode=material.CullMode
-				
 			Endif
 
 			_gdevice.BlendMode=op.blendMode
@@ -650,7 +696,7 @@ Class Renderer
 						
 			If op.material<>material
 				material=op.material
-				_gdevice.Shader=material.GetShadowShader()
+				_gdevice.Shader=material.GetRenderShader()
 				_gdevice.BindUniformBlock( material.Uniforms )
 			Endif
 			
@@ -671,6 +717,7 @@ Class Renderer
 	
 	Field _direct:Bool=False
 	Field _deferred:Bool=True
+	Field _defs:String
 	
 	Field _gdevice:GraphicsDevice
 	
@@ -696,6 +743,9 @@ Class Renderer
 
 	Field _renderTarget0:RenderTarget	'all buffers
 	Field _renderTarget1:RenderTarget	'accum buffer only
+
+	Field _effectBuffer:Texture
+	Field _effectTarget:RenderTarget
 	
 	Field _csmSize:=2048
 	Field _csmSplits:Float[]
@@ -744,16 +794,15 @@ Class Renderer
 		
 		_defaultEnv=Texture.Load( "asset::textures/env_default.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )
 		
-		_copyShader=Shader.Open( "copy" )
+		_skyboxShader=Shader.Open( "misc/skybox",ShaderDefs )
+
+		_copyShader=Shader.Open( "misc/copy" )
 		
 		If _deferred 
-			_skyboxShader=Shader.Open( "skybox-deferred",ShaderDefs )
-			_deferredLightingShader=Shader.Open( "lighting-deferred",ShaderDefs )
-			_deferredFogShader=Shader.Open( "fog-deferred",ShaderDefs )
-		Else
-			_skyboxShader=Shader.Open( "skybox",ShaderDefs )
+			_deferredLightingShader=Shader.Open( "misc/lighting-deferred",ShaderDefs )
+			_deferredFogShader=Shader.Open( "misc/fog-deferred",ShaderDefs )
 		Endif
-		
+
 		_renderQueue=New RenderQueue
 		
 		_psmFaceTransforms=New Mat3f[]( 
@@ -766,7 +815,7 @@ Class Renderer
 			
 		ValidateSize( New Vec2i( 1920,1080 ) )
 	End
-
+	
 	Method ValidateSize( size:Vec2i )
 		
 		If _direct Return

+ 26 - 7
modules/mojo3d/render/renderqueue.monkey2

@@ -22,6 +22,7 @@ Class RenderOp
 	
 	Field blendMode:BlendMode
 	Field distance:Float
+	Field shader:Shader
 End
 
 Public
@@ -61,6 +62,11 @@ Class RenderQueue
 		Return _opaqueOps
 	End
 	
+	Property SelfIlluminatedOps:Stack<RenderOp>()
+		
+		Return _selfillumOps
+	End
+	
 	Property TransparentOps:Stack<RenderOp>()
 	
 		Return _transparentOps
@@ -78,6 +84,7 @@ Class RenderQueue
 
 	Method Clear()
 		_opaqueOps.Clear()
+		_selfillumOps.Clear()
 		_transparentOps.Clear()
 		_shadowOps.Clear()
 		_spriteOps.Clear()	
@@ -88,16 +95,27 @@ Class RenderQueue
 		op.blendMode=op.material.BlendMode
 		If op.instance And op.instance.Alpha<1 And op.blendMode=BlendMode.Opaque op.blendMode=BlendMode.Alpha
 			
+		Local stack:Stack<RenderOp>
+		
 		If op.blendMode=BlendMode.Opaque
-			DebugAssert( op.material.GetOpaqueShader(),"Material has no opaque shader" )
-			_opaqueOps.Push( op )
+			stack=_opaqueOps
+			op.shader=op.material.GetRenderShader()
 		Else
-			DebugAssert( op.material.GetTransparentShader(),"Material has no transparent shader" )
+			stack=_transparentOps
+			op.shader=op.material.GetRenderShader()
 			op.distance=op.instance ? op.instance.Position.Distance( _eyePos ) Else _eyeLen
-			_transparentOps.Push( op )
 		Endif
-			
-		If _castsShadow And op.material.GetShadowShader() _shadowOps.Push( op )
+		
+		If op.material.SelfIlluminated
+			Assert( False )
+			stack=_selfillumOps
+		Endif
+		
+		If Not op.shader Return
+
+		stack.Add( op )
+		
+		If _castsShadow And op.material.GetRenderShader() _shadowOps.Push( op )
 	End
 	
 	Method AddSpriteOp( op:SpriteOp )
@@ -154,7 +172,7 @@ Class RenderQueue
 	End
 	
 	Method AddSpriteOp( sprite:Sprite )
-		DebugAssert( sprite.Material.GetTransparentShader(),"Sprites must be transparent!" )
+		DebugAssert( sprite.Material.GetRenderShader(),"Sprites must be transparent!" )
 		Local op:=New SpriteOp
 		op.sprite=sprite
 		AddSpriteOp( op )
@@ -169,6 +187,7 @@ Class RenderQueue
 	Field _castsShadow:Bool
 	
 	Field _opaqueOps:=New Stack<RenderOp>
+	Field _selfillumOps:=New Stack<RenderOp>
 	Field _transparentOps:=New Stack<RenderOp>
 	Field _shadowOps:=New Stack<RenderOp>
 	

+ 6 - 0
modules/mojo3d/render/spritebuffer.monkey2

@@ -20,6 +20,7 @@ Class SpriteBuffer
 		Local n:=spriteOps.Length
 		
 		If n*4>_vbuffer.Length
+			Local len:=_vbuffer.Length
 			_vbuffer.Resize( Max( _vbuffer.Length*3/2,n*4 ) )
 		Endif
 		
@@ -119,15 +120,19 @@ Class SpriteBuffer
 			
 			vp[0].position=matrix * New Vec3f( -handle.x,1-handle.y,0 )
 			vp[0].texCoord0=New Vec2f( texrect.min.x,texrect.min.y )
+			vp[0].color=~0
 			
 			vp[1].position=matrix * New Vec3f( 1-handle.x,1-handle.y,0 )
 			vp[1].texCoord0=New Vec2f( texrect.max.x,texrect.min.y )
+			vp[1].color=~0
 
 			vp[2].position=matrix * New Vec3f( 1-handle.x,-handle.y,0 )
 			vp[2].texCoord0=New Vec2f( texrect.max.x,texrect.max.y )
+			vp[2].color=~0
 			
 			vp[3].position=matrix * New Vec3f( -handle.x,-handle.y,0 )
 			vp[3].texCoord0=New Vec2f( texrect.min.x,texrect.max.y )
+			vp[3].color=~0
 			
 			'bump vertex/index
 			vp+=4
@@ -170,6 +175,7 @@ Class SpriteBuffer
 		
 		op.blendMode=_material.BlendMode
 		op.distance=_distance
+		op.shader=_material.GetRenderShader()
 		
 		_renderOps.Add( op )
 	End

+ 26 - 1
modules/mojo3d/scene/components/constraint.monkey2

@@ -2,6 +2,11 @@ Namespace mojo3d
 
 Class Constraint Extends Component
 	
+	Const ERP:=0		'error reduction parameter - http://bulletphysics.org/mediawiki-1.5.8/index.php/Definitions
+	Const STOP_ERP:=1
+	Const CFM:=2
+	Const STOP_CFM:=3	'constraint force mixing
+	
 	Const Type:=New ComponentType( "Constraint",-20,ComponentTypeFlags.Singleton )
 	
 	Method New( entity:Entity )
@@ -13,10 +18,24 @@ Class Constraint Extends Component
 		
 		Super.New( entity,Type )
 	End
+
+	Method SetParam( param:Int,value:Float )
+		
+		If _btconstraint _btconstraint.setParam( param+1,value )
+		
+		_params[param]=value
+	End
+	
+	Method GetParam:Float( param:Int )
+		
+		Return _params[param]
+	End
 	
 Protected
 
 	Field _rvisible:Bool
+	
+	Field _params:=New Float[4]
 
 	Field _btconstraint:btTypedConstraint
 	
@@ -43,7 +62,13 @@ Protected
 		If rvisible=_rvisible Return
 		
 		If rvisible
-			If Not _btconstraint OnCreate()
+			If Not _btconstraint 
+				OnCreate()
+'				_btconstraint.setParam( ERP+1,_params[ERP] )
+'				_btconstraint.setParam( STOP_ERP+1,_params[STOP_ERP] )
+'				_btconstraint.setParam( CFM+1,_params[CFM] )
+'				_btconstraint.setParam( STOP_CFM+1,_params[STOP_CFM] )
+			Endif
 			Entity.Scene.World.btWorld.addConstraint( _btconstraint )
 		Else
 			If _btconstraint Entity.Scene.World.btWorld.removeConstraint( _btconstraint )

+ 6 - 58
modules/mojo3d/scene/effects/bloomeffect.monkey2

@@ -12,7 +12,7 @@ Class BloomEffect Extends PostEffect
 	#end
 	Method New( passes:Int=2 )
 		
-		_shader=Shader.Open( "effect-bloom" )
+		_shader=Shader.Open( "effects/bloom" )
 		
 		_uniforms=New UniformBlock( 3 )
 		
@@ -36,78 +36,26 @@ Class BloomEffect Extends PostEffect
 	
 	Protected
 	
-	#rem monkeydoc @hidden
-	#end
 	Method OnRender() Override
 		
-		Local rsize:=Device.Viewport.Size
-		Local rtarget:=Device.RenderTarget
-		Local rtexture:=rtarget.GetColorTexture( 0 )
-		
-		If Not _target0 Or rsize.x>_target0.Size.x Or rsize.y>_target0.Size.y
-		
-			_texture0?.Discard()
-			_texture1?.Discard()
-			
-			_target0?.Discard()
-			_target1?.Discard()
-			
-			_texture0=New Texture( rsize.x,rsize.y,rtexture.Format,TextureFlags.Dynamic|TextureFlags.Filter )
-			_texture1=New Texture( rsize.x,rsize.y,rtexture.Format,TextureFlags.Dynamic|TextureFlags.Filter )
-
-			_target0=New RenderTarget( New Texture[]( _texture0 ),Null )
-			_target1=New RenderTarget( New Texture[]( _texture1 ),Null )
-		Endif
-
 		Device.Shader=_shader
+		
 		Device.BindUniformBlock( _uniforms )
-
-		Local target:=_target0
-		Local source:=rtexture
 		
 		For Local i:=0 Until _passes
-
-			_uniforms.SetTexture( "SourceTexture",source )
-			_uniforms.SetVec2f( "SourceTextureSize",source.Size )
-			_uniforms.SetVec2f( "SourceTextureScale",Cast<Vec2f>( rsize )/Cast<Vec2f>( source.Size ) )
-
-			Device.RenderTarget=target
-			Device.RenderPass=i ? 2-(i&1) Else 0	'0,1,2,1,2,1,2...
 			
-			RenderQuad()
+			If i Flip()
 			
-			If target=_target0
-				source=_texture0
-				target=_target1
-			Else
-				source=_texture1
-				target=_target0
-			Endif
+			Device.RenderPass=i ? 2-(i&1) Else 0	'0,1,2,1,2,1,2...
 			
-		Next
-		
-		_uniforms.SetTexture( "SourceTexture",source )
-		_uniforms.SetVec2f( "SourceTextureSize",source.Size )
-		_uniforms.SetVec2f( "SourceTextureScale",Cast<Vec2f>( rsize )/Cast<Vec2f>( source.Size ) )
-		
-		Device.RenderTarget=rtarget
-		Device.BlendMode=BlendMode.Additive
-		Device.RenderPass=3
-		
-		RenderQuad()
+			RenderQuad()
+		End
 	End
 	
 	Private
 	
 	Field _shader:Shader
 	Field _uniforms:UniformBlock
-	
 	Field _passes:Int=4
 	
-	Field _texture0:Texture
-	Field _texture1:Texture
-	
-	Field _target0:RenderTarget
-	Field _target1:RenderTarget
-	
 End

+ 0 - 78
modules/mojo3d/scene/effects/fogeffect.monkey2

@@ -1,78 +0,0 @@
-
-Namespace mojo3d
-
-#rem The FogEffect class.
-
-This class implements a 'fog' post processing effect.
-
-#end
-Class FogEffect Extends PostEffect
-
-	#rem monkeydoc Creates a new fog effect.
-	#end	
-	Method New( color:Color=std.graphics.Color.Sky,near:Float=0,far:Float=1000 )
-
-		_shader=Shader.Open( "effect-fog" )
-		
-		_uniforms=New UniformBlock( 3 )
-		
-		Color=color
-		Near=near
-		Far=far
-	End
-
-	#rem monkeydoc Color of the fog.
-	#end
-	Property Color:Color()
-		
-		Return _uniforms.GetColor( "Color" )
-	
-	Setter( color:Color )
-		
-		_uniforms.SetColor( "Color",color )
-	End
-
-	#rem monkeydoc Near distance of the fog.
-	#end	
-	Property Near:Float()
-		
-		Return _uniforms.GetFloat( "Near" )
-	
-	Setter( near:Float )
-		
-		_uniforms.SetFloat( "Near",near )
-	End
-	
-	#rem monkeydoc Far distance of the fog.
-	#end	
-	Property Far:Float()
-		
-		Return _uniforms.GetFloat( "Far" )
-	
-	Setter( far:Float )
-		
-		_uniforms.SetFloat( "Far",far )
-	End
-	
-	Protected
-	
-	#rem monkeydoc @hidden
-	#end
-	Method OnRender() Override
-		
-		Device.Shader=_shader
-		
-		Device.BindUniformBlock( _uniforms )
-
-		Device.BlendMode=BlendMode.Alpha
-		
-		RenderQuad()
-	End
-	
-	Private
-	
-	Field _shader:Shader
-	
-	Field _uniforms:UniformBlock
-	
-End

+ 2 - 23
modules/mojo3d/scene/effects/monochromeeffect.monkey2

@@ -9,7 +9,7 @@ Class MonochromeEffect Extends PostEffect
 	#end
 	Method New( level:Float=1.0 )
 		
-		_shader=Shader.Open( "effect-monochrome" )
+		_shader=Shader.Open( "effects/monochrome" )
 		
 		_uniforms=New UniformBlock( 3 )
 		
@@ -32,29 +32,10 @@ Class MonochromeEffect Extends PostEffect
 
 	Protected
 	
-	#rem monkeydoc @hidden
-	#end	
 	Method OnRender() Override
 		
-		Local rsize:=Device.Viewport.Size
-		Local rtarget:=Device.RenderTarget
-		Local rtexture:=rtarget.GetColorTexture( 0 )
-		
-		If Not _target Or rsize.x>_target.Size.x Or rsize.y>_target.Size.y
-			
-			_target?.Discard()
-			_texture?.Discard()
-			
-			_texture=New Texture( rsize.x,rsize.y,rtexture.Format,Null )
-			_target=New RenderTarget( New Texture[]( _texture ),Null )
-		End
-					
-		_uniforms.SetTexture( "SourceTexture",rtexture )
-		_uniforms.SetVec2f( "SourceTextureSize",rsize )
-		_uniforms.SetVec2f( "SourceCoordScale",Cast<Vec2f>( rsize )/Cast<Vec2f>( rtexture.Size ) )
-		
-		Device.RenderTarget=_target
 		Device.Shader=_shader
+		
 		Device.BindUniformBlock( _uniforms )
 		
 		RenderQuad()
@@ -64,7 +45,5 @@ Class MonochromeEffect Extends PostEffect
 	
 	Field _shader:Shader
 	Field _uniforms:UniformBlock
-	Field _target:RenderTarget
-	Field _texture:Texture
 	
 End

+ 32 - 0
modules/mojo3d/scene/effects/reflectioneffect.monkey2

@@ -0,0 +1,32 @@
+
+Namespace mojo3d
+
+#rem monkeydoc The ReflectionEffect class.
+#end
+Class ReflectionEffect Extends PostEffect
+
+	#rem monkeydoc Creates a new monochrome effect shader.
+	#end
+	Method New()
+		
+		_shader=Shader.Open( "effects/reflection" )
+		
+		_uniforms=New UniformBlock( 3 )
+	End
+	
+	Protected
+	
+	Method OnRender() Override
+		
+		Device.Shader=_shader
+		
+		Device.BindUniformBlock( _uniforms )
+		
+		RenderQuad()
+	End
+	
+	Private
+	
+	Field _shader:Shader
+	Field _uniforms:UniformBlock
+End

+ 2 - 0
modules/mojo3d/scene/entities/light.monkey2

@@ -120,5 +120,7 @@ Class Light Extends Entity
 	Field _range:Float
 	
 	Field _castsShadow:bool
+	
+	Field _dynamic:Bool
 
 End

+ 4 - 19
modules/mojo3d/scene/entities/particlematerial.monkey2

@@ -8,7 +8,9 @@ Class ParticleMaterial Extends Material
 	#rem monkeydoc Creates a new particle material.
 	#end	
 	Method New()
-
+		
+		ShaderName="materials/particle"
+		AttribMask=1|8|32
 		BlendMode=BlendMode.Additive
 		CullMode=CullMode.None
 		
@@ -31,23 +33,6 @@ Class ParticleMaterial Extends Material
 		Return New ParticleMaterial( Self )
 	End
 	
-	Method GetTransparentShader:Shader() Override
-		
-		Global _shader:Shader
-		
-		If Not _shader
-			
-			Local shader:="material-particle"
-			Local defs:=Renderer.GetCurrent().ShaderDefs
-				
-			_shader=Shader.Open( shader,defs )
-		
-		Endif
-		
-		Return _shader
-		
-	End
-	
 	Property ColorTexture:Texture()
 		
 		Return Uniforms.GetTexture( "ColorTexture" )
@@ -94,7 +79,7 @@ Class ParticleMaterial Extends Material
 	
 		Uniforms.SetFloat( "Fade",fade )
 	End
-
+	
 	Private
 	
 	Field _duration:Float

+ 99 - 33
modules/mojo3d/scene/material.monkey2

@@ -5,6 +5,18 @@ Namespace mojo3d
 #end
 Class Material Extends Resource
 	
+	enum Attrib
+		Position=1
+		Normal=2
+		Color=4
+		TexCoord0=8
+		TexCoord1=16
+		Tangent=32
+		Weights=64
+		Bones=128
+	End
+		
+	
 	#rem monkeydoc Creates a copy of the material.
 	#end
 	Method Copy:Material() abstract
@@ -20,14 +32,41 @@ Class Material Extends Resource
 		_name=name
 	End
 	
-	#Rem monkeydoc @hidden The material uniforms.
+	Property ShaderName:String()
+		
+		Return _shaderName
 	
-	TODO: Should really be protected...
+	Setter( name:String )
+		
+		If name=_shaderName Return
+		
+		_shaderName=name
+		
+		Invalidate()
+	End
+	
+	Property AttribMask:Int()
+		
+		Return _attribMask
 
-	#End
-	Property Uniforms:UniformBlock()
+	Setter( mask:Int )
+		
+		If mask=_attribMask Return
+		
+		_attribMask=mask
+		
+		Invalidate()
+	End
 	
-		Return _uniforms
+	Property SelfIlluminated:Bool()
+		
+		Return _selfillum
+	
+	Setter( selfillum:Bool )
+		
+		If selfillum=_selfillum Return
+		
+		_selfillum=selfillum
 	End
 	
 	#Rem monkeydoc The material blendmode.
@@ -93,33 +132,24 @@ Class Material Extends Resource
 		
 		TextureMatrix=TextureMatrix.Scale( sx,sy )
 	End
+	
+	#Rem monkeydoc @hidden The material uniforms.
+	
+	TODO: Should really be protected...
 
-	#rem monkeydoc Gets material's opaque shader.
-	#end
-	Method GetOpaqueShader:Shader() Virtual
+	#End
+	Property Uniforms:UniformBlock()
 	
-		Return Null
+		Return _uniforms
 	End
-	
-	#rem monkeydoc Gets material's transparent shader.
+
+	#rem monkeydoc Gets material's shader for rendering.
 	#end
-	Method GetTransparentShader:Shader() Virtual
+	Method GetRenderShader:Shader()
 		
-		Return Null
-	End
-	
-	#rem monkeydoc Gets material's sprite shader.
-	#end
-	Method GetSpriteShader:Shader() Virtual
+		Validate()
 		
-		Return GetTransparentShader()
-	End
-	
-	#rem monkeydoc Gets material's shadow shader.
-	#end
-	Method GetShadowShader:Shader() Virtual
-	
-		Return GetOpaqueShader()
+		Return _shader
 	End
 	
 	Function LoadTexture:Texture( path:String,textureFlags:TextureFlags,flipy:Bool=False )
@@ -142,21 +172,39 @@ Class Material Extends Resource
 	
 	Protected
 	
-	Method New()
+	Method OnValidate() Virtual
+	End
+	
+	Method Invalidate()
 		
-		_uniforms=New UniformBlock( 3,True )
+		_shader=Null
+	End
+	
+	Method New()
+
+		_name="Material"
+		_attribMask=1
 		_blendMode=BlendMode.Opaque
 		_cullMode=CullMode.Back
+		_selfillum=False
+
+		_uniforms=New UniformBlock( 3,True )
 		
 		TextureMatrix=New AffineMat3f
 	End		
 	
 	Method New( material:Material )
 		
-		_uniforms=New UniformBlock( material._uniforms )
-
+		_name=material._name
+		_shaderName=material._shaderName
+		_attribMask=material._attribMask
 		_blendMode=material._blendMode
 		_cullMode=material._cullMode
+		_selfillum=material._selfillum
+		_shader=material._shader
+		_dirty=material._dirty
+
+		_uniforms=New UniformBlock( material._uniforms )
 
 		TextureMatrix=material.TextureMatrix
 	End
@@ -183,10 +231,28 @@ Class Material Extends Resource
 	End
 	
 	Private
-	
+
 	Field _name:String
-	Field _uniforms:UniformBlock
-	Field _blendMode:BlendMode
+	Field _shaderName:String
+	Field _attribMask:Int
+	Field _selfillum:Bool
 	Field _cullMode:CullMode
+	Field _blendMode:BlendMode
+	Field _uniforms:UniformBlock
+	Field _shader:Shader
+	Field _dirty:Bool=True
+	
+	Method Validate()
+		
+		If _shader Return
 
+		Local defs:=Renderer.GetCurrent().ShaderDefs
+		
+		defs+=";MX2_ATTRIBMASK "+_attribMask
+		
+		Local shaderName:=_shaderName ?Else "materials/default"
+			
+		_shader=mojo.graphics.Shader.Open( shaderName,defs )
+	End
+	
 End

+ 94 - 121
modules/mojo3d/scene/materials/pbrmaterial.monkey2

@@ -1,59 +1,10 @@
 
 Namespace mojo3d
 
-Private
-
-Function MakeColor:Color( jobj:JsonObject )
-	
-	Local r:=jobj.Contains( "r" ) ? jobj.GetNumber( "r" ) Else 1.0
-	Local g:=jobj.Contains( "g" ) ? jobj.GetNumber( "g" ) Else 1.0
-	Local b:=jobj.Contains( "b" ) ? jobj.GetNumber( "b" ) Else 1.0
-	Local a:=jobj.Contains( "a" ) ? jobj.GetNumber( "a" ) Else 1.0
-	
-	Return New Color( r,g,b,a )
-End
-
-Class JsonObject Extension
-
-	Method GetColor:Color( key:String )
-		
-		Local jobj:=GetObject( key )
-		If Not jobj Return Color.White
-		
-		Return MakeColor( jobj )
-	End
-End
-
-Public
-
 #rem monkeydoc The PbrMaterial class.
 #end
 Class PbrMaterial Extends Material
 	
-	Private
-	
-	Method Init( boned:Bool )
-		
-		_boned=boned
-
-		Uniforms.DefaultTexture=Texture.ColorTexture( Color.White )
-		
-		ColorTexture=Null
-		EmissiveTexture=Null
-		MetalnessTexture=Null
-		RoughnessTexture=Null
-		OcclusionTexture=Null
-		NormalTexture=Null
-		
-		ColorFactor=Color.White
-		EmissiveFactor=Color.Black
-		MetalnessFactor=1.0
-		RoughnessFactor=1.0
-	End
-	
-	Public
-	
-	
 	#rem monkeydoc Creates a new pbr material.
 	
 	All properties default to white or '1' except for emissive factor which defaults to black. 
@@ -69,32 +20,28 @@ Class PbrMaterial Extends Material
 	The above last 3 rules allow you to pack metalness, roughness and occlusion into a single texture.
 	
 	#end
-	Method New( boned:Bool=False )
+	Method New()
 		
-		Init( boned )
+		Init()
 		
-		AddInstance( New Variant[]( boned ) )
+		AddInstance()
 	End
 	
-	Method New( color:Color,metalness:Float=1.0,roughness:Float=1.0,boned:Bool=False )
+	Method New( color:Color,metalness:Float=1.0,roughness:Float=1.0 )
 		
-		Init( boned )
+		Init()
 		
 		ColorFactor=color
 		MetalnessFactor=metalness
 		RoughnessFactor=roughness
 		
-		AddInstance( New Variant[]( color,metalness,roughness,boned ) )
+		AddInstance( New Variant[]( color,metalness,roughness ) )
 	End
 	
 	Method New( material:PbrMaterial )
 		
 		Super.New( material )
 		
-		_textured=material._textured
-		_bumpmapped=material._bumpmapped
-		_boned=material._boned
-		
 		AddInstance( material )
 	End
 	
@@ -105,22 +52,17 @@ Class PbrMaterial Extends Material
 		Return New PbrMaterial( Self )
 	End
 	
-	Method GetOpaqueShader:Shader() Override
-		
-		ValidateShaders()
-		
-		Return _opaqueShader
-	End
+	'***** textures *****
 	
-	Method GetTransparentShader:Shader() Override
+	Property Boned:Bool()
 		
-		ValidateShaders()
+		Return (AttribMask & 192)=192
 		
-		Return _transparentShader
+	Setter( boned:Bool )
+		
+		If boned AttribMask|=192 Else AttribMask&=~192
 	End
 	
-	'***** textures *****
-	
 	Property ColorTexture:Texture()
 	
 		Return Uniforms.GetTexture( "ColorTexture" )
@@ -129,7 +71,18 @@ Class PbrMaterial Extends Material
 	
 		Uniforms.SetTexture( "ColorTexture",texture )
 		
-		If (Uniforms.NumTextures<>0)<>_textured _dirty=True
+		UpdateAttribMask()
+	End
+	
+	Property AmbientTexture:Texture()
+		
+		Return Uniforms.GetTexture( "AmbientTexture" )
+	
+	Setter( texture:Texture )
+		
+		Uniforms.SetTexture( "AmbientTexture",texture )
+
+		UpdateAttribMask()
 	End
 	
 	Property EmissiveTexture:Texture()
@@ -140,7 +93,7 @@ Class PbrMaterial Extends Material
 	
 		Uniforms.SetTexture( "EmissiveTexture",texture )
 		
-		If (Uniforms.NumTextures<>0)<>_textured _dirty=True
+		UpdateAttribMask()
 	End
 	
 	Property MetalnessTexture:Texture()
@@ -151,7 +104,7 @@ Class PbrMaterial Extends Material
 	
 		Uniforms.SetTexture( "MetalnessTexture",texture )
 		
-		If (Uniforms.NumTextures<>0)<>_textured _dirty=true
+		UpdateAttribMask()
 	End
 
 	Property RoughnessTexture:Texture()
@@ -162,7 +115,7 @@ Class PbrMaterial Extends Material
 	
 		Uniforms.SetTexture( "RoughnessTexture",texture )
 		
-		If (Uniforms.NumTextures<>0)<>_textured _dirty=true
+		UpdateAttribMask()
 	End
 	
 	Property OcclusionTexture:Texture()
@@ -173,7 +126,7 @@ Class PbrMaterial Extends Material
 	
 		Uniforms.SetTexture( "OcclusionTexture",texture )
 		
-		If (Uniforms.NumTextures<>0)<>_textured _dirty=true
+		UpdateAttribMask()
 	End
 	
 	Property NormalTexture:Texture()
@@ -184,7 +137,9 @@ Class PbrMaterial Extends Material
 	
 		Uniforms.SetTexture( "NormalTexture",texture )
 		
-		If (texture<>null)<>_bumpmapped _dirty=true
+		If texture AttribMask|=32 Else AttribMask&=~32
+			
+		UpdateAttribMask()
 	End
 	
 	'***** factors *****
@@ -198,6 +153,16 @@ Class PbrMaterial Extends Material
 		Uniforms.SetColor( "ColorFactor",color )
 	End
 	
+	[jsonify=1]
+	Property AmbientFactor:Color()
+	
+		Return Uniforms.GetColor( "AmbientFactor" )
+		
+	Setter( color:Color )
+	
+		Uniforms.SetColor( "AmbientFactor",color )
+	End
+	
 	[jsonify=1]
 	Property EmissiveFactor:Color()
 	
@@ -227,7 +192,7 @@ Class PbrMaterial Extends Material
 	
 		Uniforms.SetFloat( "RoughnessFactor",factor )
 	End
-
+	
 	#rem monkeydoc Loads a PbrMaterial from a 'file'.
 	
 	A .pbr file is actually a directory containing a number of textures in png format. These textures are:
@@ -250,12 +215,18 @@ Class PbrMaterial Extends Material
 
 		Local material:=New PbrMaterial
 		
-		Local texture:=LoadTexture( path,"color",textureFlags )
+		Local texture:=scene.LoadTexture( path,textureFlags )
+		If texture
+			material.ColorTexture=texture
+			Return material
+		Endif
+		
+		texture=LoadTexture( path,"color",textureFlags )
 		If texture
 			material.ColorTexture=texture
 		Endif
 		
-		texture=LoadTexture(path,"emissive",textureFlags )
+		texture=LoadTexture( path,"emissive",textureFlags )
 		If texture
 			material.EmissiveTexture=texture
 			material.EmissiveFactor=Color.White
@@ -298,57 +269,59 @@ Class PbrMaterial Extends Material
 		Return material
 	End
 	
-	Protected
+	Private
 	
-	Field _textured:Bool
-	Field _bumpmapped:Bool
 	Field _boned:Bool
 	
-	Field _opaqueShader:Shader
-	Field _transparentShader:Shader
-	Field _shadowShader:Shader
-	
-	Field _dirty:=True
-	
-	Method ValidateShaders()
-		
-		If Not _dirty Return
-		
-		_textured=True'False
-		_bumpmapped=False
+	Method Init()
 		
-		If Uniforms.NumTextures
-			_textured=True
-			_bumpmapped=(Uniforms.GetTexture( "NormalTexture" )<>null)
-		Endif
-		
-		Local defs:=Renderer.GetCurrent().ShaderDefs
-		
-		If _textured
-			defs+="MX2_TEXTURED~n"
-			If _bumpmapped
-				defs+="MX2_BUMPMAPPED~n"
-			Endif
-		Endif
+		Uniforms.DefaultTexture=Texture.ColorTexture( Color.White )
 		
-		If _boned defs+="MX2_BONED~n"
-			
-		_transparentShader=Shader.Open( "material-pbr-forward",defs )
+		ShaderName="materials/pbr-default"
+		AttribMask=1|2|4
 		
-		If Renderer.GetCurrent().Deferred
-			
-			_opaqueShader=Shader.Open( "material-pbr-deferred",defs )
+		ColorTexture=Null
+		AmbientTexture=Null
+		EmissiveTexture=Null
+		MetalnessTexture=Null
+		RoughnessTexture=Null
+		OcclusionTexture=Null
+		NormalTexture=Null
 		
-		Else
-			
-			_opaqueShader=_transparentShader
-			
-		Endif
+		ColorFactor=Color.White
+		AmbientFactor=Color.Black
+		EmissiveFactor=Color.Black
+		MetalnessFactor=1.0
+		RoughnessFactor=1.0
+	End
+	
+	Method UpdateAttribMask()
 		
-		_shadowShader=_opaqueShader
+		If Uniforms.NumTextures<>0 AttribMask|=24 Else AttribMask&=~24
+	End
+	
+End
+
+Private
+
+Function MakeColor:Color( jobj:JsonObject )
+	
+	Local r:=jobj.Contains( "r" ) ? jobj.GetNumber( "r" ) Else 1.0
+	Local g:=jobj.Contains( "g" ) ? jobj.GetNumber( "g" ) Else 1.0
+	Local b:=jobj.Contains( "b" ) ? jobj.GetNumber( "b" ) Else 1.0
+	Local a:=jobj.Contains( "a" ) ? jobj.GetNumber( "a" ) Else 1.0
+	
+	Return New Color( r,g,b,a )
+End
+
+Class JsonObject Extension
+
+	Method GetColor:Color( key:String )
 		
-		_dirty=False
+		Local jobj:=GetObject( key )
+		If Not jobj Return Color.White
 		
+		Return MakeColor( jobj )
 	End
-	
 End
+

+ 2 - 32
modules/mojo3d/scene/materials/spritematerial.monkey2

@@ -9,12 +9,13 @@ Class SpriteMaterial Extends Material
 	#end	
 	Method New()
 		
+		ShaderName="materials/sprite"
+		AttribMask=1|8
 		BlendMode=BlendMode.Alpha
 		CullMode=CullMode.None
 		
 		ColorTexture=Texture.ColorTexture( Color.White )
 		ColorFactor=Color.White
-		
 		AlphaDiscard=.5
 		
 		AddInstance()
@@ -34,37 +35,6 @@ Class SpriteMaterial Extends Material
 		Return New SpriteMaterial( Self )
 	End
 	
-	Method GetOpaqueShader:Shader() Override
-		
-		Global _shader:Shader
-		
-		If Not _shader
-			
-			Local shader:="material-sprite"
-			
-			Local defs:=Renderer.GetCurrent().ShaderDefs
-				
-			_shader=Shader.Open( shader,defs )
-		Endif
-		
-		Return _shader
-	End
-	
-	Method GetTransparentShader:Shader() Override
-		
-		Return GetOpaqueShader()
-	End
-	
-	Method GetSpriteShader:Shader() Override
-		
-		Return GetOpaqueShader()
-	End
-	
-	Method GetShadowShader:Shader() Override
-		
-		Return GetOpaqueShader()
-	End
-	
 	[jsonify=1]
 	Property ColorTexture:Texture()
 		

+ 15 - 48
modules/mojo3d/scene/materials/watermaterial.monkey2

@@ -8,17 +8,15 @@ Class WaterMaterial Extends Material
 	#rem monkeydoc Creates a new water material.
 	#end
 	Method New()
+
+		ShaderName="materials/water"
+		AttribMask=1|4|8|32
+		BlendMode=BlendMode.Opaque
+		CullMode=CullMode.None
 		
 		ColorTexture=Texture.ColorTexture( Color.White )
 		ColorFactor=Color.SeaGreen
-		
-		Metalness=0
-		Roughness=0
-		
-		Local normal:=Texture.ColorTexture( New Color( .5,.5,1 ) )
-		
-		NormalTextures=New Texture[]( normal,normal )
-		
+		NormalTextures=New Texture[]( Texture.FlatNormal(),Texture.FlatNormal() )
 		Velocities=New Vec2f[]( New Vec2f( 0,0 ),New Vec2f( 0,0 ) )
 	End
 	
@@ -34,54 +32,22 @@ Class WaterMaterial Extends Material
 		Return New WaterMaterial( Self )
 	End
 	
-	Method GetOpaqueShader:Shader() Override
-		
-		Global _shader:=Shader.Open( "material-water" )
-		
-		Assert( _shader )
-
-		Return _shader
-	End
-	
-	Method GetShadowShader:Shader() Override
-		
-		Return Null
-	End
-	
 	Property ColorTexture:Texture()
-		
-		Return Uniforms.GetTexture( "ColorTexture" )
 	
-	Setter( texture:Texture )
+		Return Uniforms.GetTexture( "ColorTexture" )
 		
+	Setter( texture:Texture )
+	
 		Uniforms.SetTexture( "ColorTexture",texture )
 	End
-	
+
 	Property ColorFactor:Color()
-		
-		Return Uniforms.GetColor( "ColorFactor" )
-	
-	Setter( factor:Color )
-	
-		Uniforms.SetColor( "ColorFactor",factor )
-	End
-	
-	Property Metalness:Float()
-		
-		Return Uniforms.GetFloat( "Metalness" )
-	
-	Setter( metalness:Float )
-		
-		Uniforms.SetFloat( "Metalness",metalness )
-	End
 	
-	property Roughness:Float()
+		Return Uniforms.GetColor( "ColorFactor" )
 		
-		Return Uniforms.GetFloat( "Roughness" )
+	Setter( color:Color )
 	
-	Setter( roughness:Float )
-		
-		Uniforms.SetFloat( "Roughness",roughness )
+		Uniforms.SetColor( "ColorFactor",color )
 	End
 	
 	Property NormalTextures:Texture[]()
@@ -89,8 +55,9 @@ Class WaterMaterial Extends Material
 		Return New Texture[]( Uniforms.GetTexture( "NormalTexture0" ),Uniforms.GetTexture( "NormalTexture1" ) )
 	
 	Setter( textures:Texture[] )
-		Assert( textures.Length=2,"NormalTextures array must havre length 2" )
+		Assert( textures.Length=2,"NormalTextures array must have length 2" )
 		
+		Uniforms.SetTexture( "NormalTexture",textures[0] )
 		Uniforms.SetTexture( "NormalTexture0",textures[0] )
 		Uniforms.SetTexture( "NormalTexture1",textures[1] )
 	End

+ 19 - 22
modules/mojo3d/scene/posteffect.monkey2

@@ -18,46 +18,39 @@ Class PostEffect
 		
 		_enabled=enabled
 	End
-
+	
+	
 	#rem monkeydoc @hidden
 	#end	
-	Method Render( device:GraphicsDevice ) Virtual
-		
-		_device=device
+	Method Render()
 		
 		OnRender()
 	End
+	
+	Function BeginRendering( device:GraphicsDevice,renderer:Renderer )
+		_device=device
+		_renderer=renderer
+	End
+	
+	Function EndRendering()
+	End
 
 	Protected
 	
 	#rem monkeydoc @hidden
 	#end	
-	Method OnRender() Virtual
-	End
+	Method OnRender() Abstract
 	
-	#rem monkeydoc @hidden
-	#end	
 	Property Device:GraphicsDevice()
 		
 		Return _device
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
-	Property SourceRect:Recti()
+	Method Flip()
 		
-		Return _device.Viewport
+		_renderer.FlipEffectBuffers()
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
-	Property SourceTexture:Texture()
-		
-		Return _device.RenderTarget.GetColorTexture( 0 )
-	End
-	
-	#rem monkeydoc @hidden
-	#end	
 	Method RenderQuad()
 
 		Global _vertices:VertexBuffer
@@ -71,12 +64,16 @@ Class PostEffect
 		Endif
 			
 		_device.VertexBuffer=_vertices
+		
 		_device.Render( 4,1 )
 	End
-		
+	
+	#rem monkeydoc @hidden
+	#end	
 	Private
 	
 	Global _device:GraphicsDevice
+	Global _renderer:Renderer
 	
 	Field _enabled:Bool=True
 	

+ 2 - 2
modules/mojo3d/tests/alphacubes.monkey2

@@ -70,9 +70,9 @@ Class MyWindow Extends Window
 		
 		_scene.Update()
 		
-		_camera.Render( canvas )
+		_scene.Render( canvas )
 		
-		canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )
+		canvas.DrawText( "FPS="+App.FPS,0,0 )
 	End
 	
 End

+ 0 - 86
modules/mojo3d/tests/anisotropic.monkey2

@@ -1,86 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Const MaxAnisotropy:=16
-			
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _ground:Model
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		SetConfig( "MOJO_TEXTURE_MAX_ANISOTROPY",MaxAnisotropy )
-		
-		'create scene
-		'		
-		_scene=New Scene
-		
-		'for a totally 'black' scene
-		_scene.ClearColor=Color.Black		'clears screen to black
-		_scene.AmbientLight=Color.Black		'disables all ambient light
-		_scene.EnvColor=Color.Black			'disables all environmental reflections
-
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Move( 0,2,0 )
-		New FlyBehaviour( _camera )
-
-		'createa simple 'grid' texture
-		'
-		Local pixmap:=New Pixmap( 16,16 )
-		pixmap.Clear( Color.Black )
-		For Local i:=0 Until 16
-			pixmap.SetPixelARGB( i,0,~0 )
-			pixmap.SetPixelARGB( 0,i,~0 )
-		Next
-		Local texture:=New Texture( pixmap,TextureFlags.FilterMipmap|TextureFlags.WrapST )
-		
-		'create material
-		'
-		Local material:=New PbrMaterial( Color.Black )
-		material.EmissiveTexture=texture
-		material.EmissiveFactor=Color.Red
-
-		material.ScaleTextureMatrix( 500,500 )
-		
-		'create ground
-		'		
-		_ground=Model.CreateBox( New Boxf( -500,-1,-500,500,0,500 ),10,10,10,material )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-		
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-	End
-	
-End
-
-Function Main()
-	
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

二进制
modules/mojo3d/tests/assets/Monkey2logo_64.png


二进制
modules/mojo3d/tests/assets/bluspark.png


二进制
modules/mojo3d/tests/assets/bouncyball/bouncyball.bin


+ 0 - 589
modules/mojo3d/tests/assets/bouncyball/bouncyball.gltf

@@ -1,589 +0,0 @@
-{
-  "accessors": [
-    {
-      "bufferView": 0,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 50,
-      "max": [
-        0.129409536719322,
-        0.5,
-        0.129409536719322
-      ],
-      "min": [
-        -0.129409536719322,
-        -0.5,
-        -0.129409536719322
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 600,
-      "componentType": 5126,
-      "count": 50,
-      "max": [
-        0.268908590078354,
-        1,
-        0.268908590078354
-      ],
-      "min": [
-        -0.268908590078354,
-        -1,
-        -0.268908560276031
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 0,
-      "componentType": 5123,
-      "count": 144,
-      "max": [
-        49
-      ],
-      "min": [
-        0
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 1200,
-      "componentType": 5126,
-      "count": 204,
-      "max": [
-        0.5,
-        0.482962906360626,
-        0.5
-      ],
-      "min": [
-        -0.5,
-        -0.482962906360626,
-        -0.5
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 3648,
-      "componentType": 5126,
-      "count": 204,
-      "max": [
-        0.999999940395355,
-        0.963165760040283,
-        0.999999940395355
-      ],
-      "min": [
-        -1,
-        -0.963165700435638,
-        -1
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 288,
-      "componentType": 5123,
-      "count": 720,
-      "max": [
-        203
-      ],
-      "min": [
-        0
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 6096,
-      "componentType": 5126,
-      "count": 204,
-      "max": [
-        0.5,
-        0.482962906360626,
-        0.5
-      ],
-      "min": [
-        -0.5,
-        -0.482962906360626,
-        -0.5
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 8544,
-      "componentType": 5126,
-      "count": 204,
-      "max": [
-        0.999999940395355,
-        0.963165760040283,
-        0.999999940395355
-      ],
-      "min": [
-        -1,
-        -0.963165760040283,
-        -1
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 1728,
-      "componentType": 5123,
-      "count": 720,
-      "max": [
-        203
-      ],
-      "min": [
-        0
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 1,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 20,
-      "max": [
-        0.9916666666666667
-      ],
-      "min": [
-        0.041666666666666664
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 1,
-      "byteOffset": 80,
-      "componentType": 5126,
-      "count": 20,
-      "max": [
-        0,
-        2.7406444549560547,
-        0
-      ],
-      "min": [
-        0,
-        0.2996174097061157,
-        0
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 1,
-      "byteOffset": 320,
-      "componentType": 5126,
-      "count": 20,
-      "max": [
-        1.3701729774475098,
-        1.5768864154815674,
-        1.3701729774475098
-      ],
-      "min": [
-        0.7761592268943787,
-        0.61479252576828,
-        0.7761592268943787
-      ],
-      "type": "VEC3"
-    }
-  ],
-  "animations": [
-    {
-      "channels": [
-        {
-          "sampler": 0,
-          "target": {
-            "node": 0,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 1,
-          "target": {
-            "node": 0,
-            "path": "translation"
-          }
-        }
-      ],
-      "name": "Main",
-      "samplers": [
-        {
-          "input": 9,
-          "interpolation": "LINEAR",
-          "output": 11
-        },
-        {
-          "input": 9,
-          "interpolation": "LINEAR",
-          "output": 10
-        }
-      ]
-    }
-  ],
-  "asset": {
-    "generator": "qtek fbx2gltf",
-    "version": "2.0"
-  },
-  "bufferViews": [
-    {
-      "buffer": 0,
-      "byteLength": 10992,
-      "byteOffset": 0,
-      "target": 34962
-    },
-    {
-      "buffer": 0,
-      "byteLength": 560,
-      "byteOffset": 10992,
-      "target": 34962
-    },
-    {
-      "buffer": 0,
-      "byteLength": 3168,
-      "byteOffset": 11552,
-      "target": 34963
-    }
-  ],
-  "buffers": [
-    {
-      "byteLength": 14720,
-      "uri": "bouncyball.bin"
-    }
-  ],
-  "materials": [
-    {
-      "name": "Blue",
-      "emissiveFactor": [
-        0,
-        0,
-        0
-      ],
-      "pbrMetallicRoughness": {
-        "baseColorFactor": [
-          0,
-          0.0392156862745098,
-          0.9019607843137255,
-          1
-        ],
-        "metallicFactor": 0,
-        "roughnessFactor": 0.8213901449934544
-      }
-    },
-    {
-      "name": "Yellow",
-      "emissiveFactor": [
-        0,
-        0,
-        0
-      ],
-      "pbrMetallicRoughness": {
-        "baseColorFactor": [
-          0.9019607843137255,
-          0.9019607843137255,
-          0,
-          1
-        ],
-        "metallicFactor": 0,
-        "roughnessFactor": 0.8213901449934544
-      }
-    },
-    {
-      "name": "Red",
-      "emissiveFactor": [
-        0,
-        0,
-        0
-      ],
-      "pbrMetallicRoughness": {
-        "baseColorFactor": [
-          0.9019607843137255,
-          0,
-          0,
-          1
-        ],
-        "metallicFactor": 0,
-        "roughnessFactor": 0.8213901449934544
-      }
-    }
-  ],
-  "meshes": [
-    {
-      "name": "sphere_object1_Material0",
-      "primitives": [
-        {
-          "attributes": {
-            "NORMAL": 1,
-            "POSITION": 0
-          },
-          "indices": 2,
-          "material": 0
-        },
-        {
-          "attributes": {
-            "NORMAL": 4,
-            "POSITION": 3
-          },
-          "indices": 5,
-          "material": 1
-        },
-        {
-          "attributes": {
-            "NORMAL": 7,
-            "POSITION": 6
-          },
-          "indices": 8,
-          "material": 2
-        }
-      ]
-    }
-  ],
-  "nodes": [
-    {
-      "matrix": [
-        1.3701729774475098,
-        0,
-        0,
-        0,
-        0,
-        0.61479252576828,
-        0,
-        0,
-        0,
-        0,
-        1.3701729774475098,
-        0,
-        0,
-        0.2996174097061157,
-        0,
-        1
-      ],
-      "mesh": 0,
-      "name": "sphere_object1"
-    }
-  ],
-  "scene": 0,
-  "scenes": [
-    {
-      "nodes": [
-        0
-      ]
-    }
-  ],
-  "extras": {
-    "qtekModelViewerConfig": {
-      "preZ": true,
-      "materials": [
-        {
-          "name": "Blue",
-          "color": "#000ae6",
-          "emission": "#000000",
-          "alpha": 1,
-          "alphaCutoff": 0,
-          "emissionIntensity": 1,
-          "uvRepeat": {
-            "0": 1,
-            "1": 1
-          },
-          "parallaxOcclusionScale": 0.02,
-          "diffuseMap": "",
-          "normalMap": "",
-          "parallaxOcclusionMap": "",
-          "emissiveMap": "",
-          "metalness": 0,
-          "roughness": 0.8213901449934544,
-          "metalnessMap": "",
-          "roughnessMap": "",
-          "type": "pbrMetallicRoughness",
-          "targetMeshes": [
-            "sphere_object1_Material0"
-          ]
-        },
-        {
-          "name": "Yellow",
-          "color": "#e6e600",
-          "emission": "#000000",
-          "alpha": 1,
-          "alphaCutoff": 0,
-          "emissionIntensity": 1,
-          "uvRepeat": {
-            "0": 1,
-            "1": 1
-          },
-          "parallaxOcclusionScale": 0.02,
-          "diffuseMap": "",
-          "normalMap": "",
-          "parallaxOcclusionMap": "",
-          "emissiveMap": "",
-          "metalness": 0,
-          "roughness": 0.8213901449934544,
-          "metalnessMap": "",
-          "roughnessMap": "",
-          "type": "pbrMetallicRoughness",
-          "targetMeshes": [
-            "sphere_object1_Material0$1"
-          ]
-        },
-        {
-          "name": "Red",
-          "color": "#e60000",
-          "emission": "#000000",
-          "alpha": 1,
-          "alphaCutoff": 0,
-          "emissionIntensity": 1,
-          "uvRepeat": {
-            "0": 1,
-            "1": 1
-          },
-          "parallaxOcclusionScale": 0.02,
-          "diffuseMap": "",
-          "normalMap": "",
-          "parallaxOcclusionMap": "",
-          "emissiveMap": "",
-          "metalness": 0,
-          "roughness": 0.8213901449934544,
-          "metalnessMap": "",
-          "roughnessMap": "",
-          "type": "pbrMetallicRoughness",
-          "targetMeshes": [
-            "sphere_object1_Material0$2"
-          ]
-        }
-      ],
-      "takes": [],
-      "textureFlipY": false,
-      "zUpToYUp": false,
-      "shadow": true,
-      "environment": "auto",
-      "viewControl": {
-        "center": [
-          1.0690909624099731,
-          -1.1321967840194702,
-          0.9232351183891296
-        ],
-        "alpha": 10.229259828771838,
-        "beta": 33.79452028477864,
-        "distance": 47.03251490338545
-      },
-      "ground": {
-        "show": true
-      },
-      "mainLight": {
-        "shadow": true,
-        "shadowQuality": "medium",
-        "intensity": 0.8,
-        "color": "#fff",
-        "alpha": 45,
-        "beta": 45,
-        "$padAngle": [
-          0.25,
-          0.5
-        ]
-      },
-      "secondaryLight": {
-        "shadow": false,
-        "shadowQuality": "medium",
-        "intensity": 0,
-        "color": "#fff",
-        "alpha": 60,
-        "beta": -50,
-        "$padAngle": [
-          -0.2777777777777778,
-          0.6666666666666666
-        ]
-      },
-      "tertiaryLight": {
-        "shadow": false,
-        "shadowQuality": "medium",
-        "intensity": 0,
-        "color": "#fff",
-        "alpha": 89,
-        "beta": 0,
-        "$padAngle": [
-          0,
-          0.9888888888888889
-        ]
-      },
-      "ambientLight": {
-        "intensity": 0,
-        "color": "#fff"
-      },
-      "ambientCubemapLight": {
-        "texture": "./asset/texture/Barce_Rooftop_C.hdr",
-        "$texture": "Barce_Rooftop_C",
-        "$textureOptions": [
-          "pisa",
-          "Barce_Rooftop_C",
-          "Factory_Catwalk",
-          "Grand_Canyon_C",
-          "Ice_Lake",
-          "Hall",
-          "Old_Industrial_Hall"
-        ],
-        "exposure": 3,
-        "diffuseIntensity": 0.2,
-        "specularIntensity": 0.2,
-        "$intensity": 0.2
-      },
-      "postEffect": {
-        "enable": true,
-        "bloom": {
-          "enable": true,
-          "intensity": 0.1
-        },
-        "depthOfField": {
-          "enable": false,
-          "focalDistance": 4,
-          "focalRange": 1,
-          "blurRadius": 5,
-          "fstop": 10,
-          "quality": "medium",
-          "$qualityOptions": [
-            "low",
-            "medium",
-            "high",
-            "ultra"
-          ]
-        },
-        "screenSpaceAmbientOcclusion": {
-          "enable": false,
-          "radius": 1.5,
-          "quality": "medium",
-          "intensity": 1,
-          "$qualityOptions": [
-            "low",
-            "medium",
-            "high",
-            "ultra"
-          ]
-        },
-        "screenSpaceReflection": {
-          "enable": false,
-          "quality": "medium",
-          "maxRoughness": 0.8,
-          "$qualityOptions": [
-            "low",
-            "medium",
-            "high",
-            "ultra"
-          ]
-        },
-        "colorCorrection": {
-          "enable": true,
-          "exposure": 0,
-          "brightness": 0,
-          "contrast": 1,
-          "saturation": 1,
-          "lookupTexture": ""
-        },
-        "FXAA": {
-          "enable": false
-        }
-      }
-    }
-  },
-  "extensionsUsed": [
-    "KHR_materials_pbrSpecularGlossiness"
-  ]
-}

二进制
modules/mojo3d/tests/assets/heightmap_256.BMP


+ 0 - 1
modules/mojo3d/tests/assets/mossy-ground1.pbr/About these PBR files.txt

@@ -1 +0,0 @@
-These texture files were created by FreePBR.com and may be used freely in your video games and 3d work at no cost. They may not however be redistributed on other websites or anywhere else other than FreePBR.com. We think that is more than fair. :) We also would greatly appreciate it if some sorrt of credit was given if you do indeed use these textures in a published game. Other than that, keep on creating and have fun. :)

二进制
modules/mojo3d/tests/assets/mossy-ground1.pbr/color.png


二进制
modules/mojo3d/tests/assets/mossy-ground1.pbr/height.png


二进制
modules/mojo3d/tests/assets/mossy-ground1.pbr/metalness.png


二进制
modules/mojo3d/tests/assets/mossy-ground1.pbr/normal.png


二进制
modules/mojo3d/tests/assets/mossy-ground1.pbr/occlusion.png


二进制
modules/mojo3d/tests/assets/mossy-ground1.pbr/roughness.png


二进制
modules/mojo3d/tests/assets/mossy.pbr/color.png


二进制
modules/mojo3d/tests/assets/mossy.pbr/normal.png


二进制
modules/mojo3d/tests/assets/mossy.pbr/occlusion.png


二进制
modules/mojo3d/tests/assets/platform.glb


二进制
modules/mojo3d/tests/assets/terrain_256.png


二进制
modules/mojo3d/tests/assets/walker/walk.bin


+ 0 - 2470
modules/mojo3d/tests/assets/walker/walk.gltf

@@ -1,2470 +0,0 @@
-{
-  "accessors": [
-    {
-      "bufferView": 0,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 956,
-      "max": [
-        0.307114273309708,
-        1.88036692142487,
-        0.301835179328918
-      ],
-      "min": [
-        -0.307114273309708,
-        0.00452733971178532,
-        -0.307114273309708
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 11472,
-      "componentType": 5126,
-      "count": 956,
-      "max": [
-        0.125,
-        0.375
-      ],
-      "min": [
-        0.125,
-        0.375
-      ],
-      "type": "VEC2"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 19120,
-      "componentType": 5123,
-      "count": 956,
-      "max": [
-        12,
-        12,
-        11,
-        10
-      ],
-      "min": [
-        0,
-        0,
-        0,
-        0
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 26768,
-      "componentType": 5126,
-      "count": 956,
-      "max": [
-        1,
-        0.916199564933777,
-        0.843633890151978,
-        0.322161793708801
-      ],
-      "min": [
-        0.0000332839408656582,
-        0,
-        0,
-        0
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 3,
-      "byteOffset": 0,
-      "componentType": 5123,
-      "count": 4320,
-      "max": [
-        955
-      ],
-      "min": [
-        0
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 42064,
-      "componentType": 5126,
-      "count": 59,
-      "max": [
-        0.297124952077866,
-        1.87145125865936,
-        0.291844874620438
-      ],
-      "min": [
-        -0.297124952077866,
-        0.00624265894293785,
-        -0.297124952077866
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 42772,
-      "componentType": 5126,
-      "count": 59,
-      "max": [
-        0.125,
-        0.125
-      ],
-      "min": [
-        0.125,
-        0.125
-      ],
-      "type": "VEC2"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 43244,
-      "componentType": 5123,
-      "count": 59,
-      "max": [
-        12,
-        12,
-        11,
-        10
-      ],
-      "min": [
-        0,
-        0,
-        0,
-        0
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 0,
-      "byteOffset": 43716,
-      "componentType": 5126,
-      "count": 59,
-      "max": [
-        1,
-        0.862461030483246,
-        0.787990570068359,
-        0.279946267604828
-      ],
-      "min": [
-        0.00219220668077469,
-        0,
-        0,
-        0
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 3,
-      "byteOffset": 8640,
-      "componentType": 5123,
-      "count": 312,
-      "max": [
-        58
-      ],
-      "min": [
-        0
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 1,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 13,
-      "max": [
-        0.7071069616676381,
-        0.7065039792525689,
-        0.18352295839579968,
-        0,
-        1.297598889720983e-36,
-        0.2595406240953048,
-        0.9991472703742983,
-        0,
-        1.00000001242492,
-        0.7065039938963843,
-        0.18352292110010368,
-        0,
-        2.3755418781675774e-7,
-        -5.071771698169818e-15,
-        1.60000004629283,
-        1
-      ],
-      "min": [
-        -0.7071069801562327,
-        -0.9999999688522121,
-        -0.18352298509004772,
-        0,
-        -1.0288886087161426e-7,
-        -0.08012979196722309,
-        -1.00000002106023,
-        0,
-        -0.7071069937475054,
-        -0.7065039378907493,
-        -0.18352295945499197,
-        0,
-        -5.58189149511033e-15,
-        -0.5467795687954656,
-        -1.5979803382428897,
-        1
-      ],
-      "type": "MAT4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 0,
-      "componentType": 5126,
-      "count": 28,
-      "max": [
-        1.4416666666666669
-      ],
-      "min": [
-        0.041666666666666664
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 112,
-      "componentType": 5126,
-      "count": 28,
-      "max": [
-        0.3787504732608795,
-        0.059866804629564285,
-        -0.19540420174598694
-      ],
-      "min": [
-        0.10466296225786209,
-        1.066356958290271e-8,
-        -0.19540420174598694
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 448,
-      "componentType": 5126,
-      "count": 28,
-      "max": [
-        0,
-        0,
-        0,
-        1
-      ],
-      "min": [
-        0,
-        0,
-        0,
-        1
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 896,
-      "componentType": 5126,
-      "count": 28,
-      "max": [
-        1,
-        1,
-        1
-      ],
-      "min": [
-        1,
-        1,
-        1
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 1232,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        1.4416666666666669
-      ],
-      "min": [
-        0.041666666666666664
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 1348,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        0.10212353616952896,
-        0.05983922630548477,
-        -0.19540409743785858
-      ],
-      "min": [
-        -0.17865866422653198,
-        1.066356958290271e-8,
-        -0.19540409743785858
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 1696,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        0,
-        0,
-        0,
-        1
-      ],
-      "min": [
-        0,
-        0,
-        0,
-        1
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 2160,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        1,
-        1,
-        1
-      ],
-      "min": [
-        1,
-        1,
-        1
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 2508,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        0.10212364047765732,
-        0.06039157137274742,
-        0.08743858337402344
-      ],
-      "min": [
-        -0.17833927273750305,
-        1.066356958290271e-8,
-        0.08743858337402344
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 2856,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        0,
-        0,
-        0,
-        1
-      ],
-      "min": [
-        0,
-        0,
-        0,
-        1
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 3320,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        1,
-        1,
-        1
-      ],
-      "min": [
-        1,
-        1,
-        1
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 3668,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        0.3882029056549072,
-        0.059866804629564285,
-        0.08743848651647568
-      ],
-      "min": [
-        0.10466305911540985,
-        1.066356958290271e-8,
-        0.08743848651647568
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 4016,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        0,
-        0,
-        0,
-        1
-      ],
-      "min": [
-        0,
-        0,
-        0,
-        1
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 4480,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        1,
-        1,
-        1
-      ],
-      "min": [
-        1,
-        1,
-        1
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 4828,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        0,
-        1.7387977838516235,
-        0.03374987840652466
-      ],
-      "min": [
-        0,
-        1.71110200881958,
-        -0.0334467813372612
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 5176,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        0.0256829595709123,
-        0.0005007423353603812,
-        0.00049700447537215,
-        0.9999997557907885
-      ],
-      "min": [
-        -0.01785916289340164,
-        0.00047956127536375424,
-        0.0004756569971589696,
-        0.9996698998145406
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 5640,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        1.0000000000000002,
-        1.0000000000000002,
-        1.0000000000000002
-      ],
-      "min": [
-        0.9999999999999999,
-        0.9999999999999998,
-        0.9999999999999998
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 5988,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        1.4416666666666669
-      ],
-      "min": [
-        0.041666666666666664
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 5996,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        0.08011647313833238,
-        -0.06073546037077904,
-        0.08011647313833237
-      ],
-      "min": [
-        0.08011647313833235,
-        -0.06073546037077904,
-        0.08011647313833237
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 6020,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        3.75530232012281e-18,
-        -0.38268343236508967,
-        9.066101792051642e-18,
-        0.9238795325112868
-      ],
-      "min": [
-        -9.388255800307029e-19,
-        -0.38268343236508967,
-        -2.266525448012911e-18,
-        0.9238795325112868
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 6052,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        1.0000000000000002,
-        1,
-        1.0000000000000002
-      ],
-      "min": [
-        0.9999999999999999,
-        1,
-        0.9999999999999999
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 6076,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        1.4333333333333336
-      ],
-      "min": [
-        0.03333333333333333
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 6192,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.34327567463483477,
-        -0.5646079643917237,
-        -0.3825899012579683,
-        0.6209772332146184
-      ],
-      "min": [
-        -0.3963100561429893,
-        -0.5940892308030855,
-        -0.42289289031820115,
-        0.5858613604175246
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 6656,
-      "componentType": 5126,
-      "count": 28,
-      "max": [
-        1.4500000000000002
-      ],
-      "min": [
-        0.1
-      ],
-      "type": "SCALAR"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 6768,
-      "componentType": 5126,
-      "count": 28,
-      "max": [
-        -0.11154751992319904,
-        -2.227614974576578e-9,
-        -9.924262985301493e-9,
-        0.9937591009892606
-      ],
-      "min": [
-        -0.19375562757825307,
-        -3.0630453960360002e-9,
-        -1.0144504604253384e-8,
-        0.9810498238019093
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 7216,
-      "componentType": 5126,
-      "count": 28,
-      "max": [
-        -0.061867483469879365,
-        6.7151424641743684e-9,
-        -5.561533723753888e-9,
-        0.9980843724300587
-      ],
-      "min": [
-        -0.17346961800430458,
-        6.048687328187861e-9,
-        -6.2799025750352286e-9,
-        0.9848392212079292
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 7664,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        -0.08011647313833237,
-        -0.060735460370778815,
-        0.08011647313833237
-      ],
-      "min": [
-        -0.08011647313833238,
-        -0.06073546037077904,
-        0.08011647313833237
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 7688,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        8.000390764101652e-17,
-        0.9238795325112867,
-        8.000390764101652e-17,
-        -0.3826834323650898
-      ],
-      "min": [
-        -3.3138703587753536e-17,
-        0.9238795325112867,
-        3.3138703587753536e-17,
-        -0.3826834323650898
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 7720,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        1.0000000000000002,
-        1,
-        1.0000000000000002
-      ],
-      "min": [
-        0.9999999999999999,
-        1,
-        0.9999999999999999
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 7744,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.35032506818952497,
-        -0.5181793742259639,
-        -0.34669574095674915,
-        0.6143522840977433
-      ],
-      "min": [
-        -0.43733678030753825,
-        -0.6164970852371117,
-        -0.48079020248750415,
-        0.5548516194390245
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 8208,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.1179497210369631,
-        7.2960567370699746e-9,
-        -1.1566850091859941e-8,
-        0.9930195684412783
-      ],
-      "min": [
-        -0.2182250838808589,
-        6.083173761707528e-9,
-        -1.2248243155057646e-8,
-        0.9758984643728014
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 8672,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.06883043527648022,
-        4.375810562473946e-8,
-        -9.039760573008193e-9,
-        0.9976283732831821
-      ],
-      "min": [
-        -0.2104509740317789,
-        4.202087980935973e-8,
-        -1.5189955259001044e-8,
-        0.9776044125969735
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 9136,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        -0.08011647313833237,
-        -0.060735460370778815,
-        -0.08011647313833237
-      ],
-      "min": [
-        -0.08011647313833238,
-        -0.06073546037077926,
-        -0.08011647313833238
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 9160,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        3.3138703587753536e-17,
-        0.9238795325112868,
-        8.000390764101651e-17,
-        0.38268343236508967
-      ],
-      "min": [
-        -8.000390764101651e-17,
-        0.9238795325112868,
-        3.3138703587753536e-17,
-        0.3826834323650896
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 9192,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        1.0000000000000004,
-        1,
-        1.0000000000000007
-      ],
-      "min": [
-        1,
-        1,
-        1
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 9216,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.343444731652475,
-        -0.5558793258000364,
-        -0.3259296294201151,
-        0.617500033375863
-      ],
-      "min": [
-        -0.4900495809040575,
-        -0.6284700585352242,
-        -0.43653592424678644,
-        0.50871679025711
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 9680,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.10349640764329562,
-        2.0664895611674537e-10,
-        -1.0346681992879392e-8,
-        0.9946298274257276
-      ],
-      "min": [
-        -0.21569876964838308,
-        -9.737863953382407e-10,
-        -1.0392400893684155e-8,
-        0.9764599534912702
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 10144,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.050364139529761466,
-        1.640184618372893e-8,
-        -5.5468564316988404e-9,
-        0.9987309214445232
-      ],
-      "min": [
-        -0.20636874025867186,
-        1.5328995765290026e-8,
-        -8.050469704393677e-9,
-        0.9784742935019032
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 10608,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        0.0801164731383324,
-        -0.06073546037077904,
-        -0.08011647313833235
-      ],
-      "min": [
-        0.08011647313833235,
-        -0.06073546037077904,
-        -0.08011647313833237
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 10632,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        6.410702056087227e-18,
-        0.38268343236508967,
-        4.533050896025822e-18,
-        0.9238795325112868
-      ],
-      "min": [
-        -1.8776511600614058e-18,
-        0.38268343236508967,
-        -6.4107020560872245e-18,
-        0.9238795325112868
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 10664,
-      "componentType": 5126,
-      "count": 2,
-      "max": [
-        1.0000000000000002,
-        1,
-        1.0000000000000002
-      ],
-      "min": [
-        0.9999999999999999,
-        1,
-        0.9999999999999999
-      ],
-      "type": "VEC3"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 10688,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.37352379378857636,
-        -0.5760199987620502,
-        -0.34708724295824445,
-        0.6006692983826076
-      ],
-      "min": [
-        -0.4128239883703936,
-        -0.618794036498964,
-        -0.4103461623942859,
-        0.5737047525262833
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 11152,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.11039836731563783,
-        8.858239287575232e-10,
-        -1.0516184125613276e-8,
-        0.9938874184202361
-      ],
-      "min": [
-        -0.187059344927289,
-        6.851271898838119e-11,
-        -1.0553204128495013e-8,
-        0.9823486150422228
-      ],
-      "type": "VEC4"
-    },
-    {
-      "bufferView": 2,
-      "byteOffset": 11616,
-      "componentType": 5126,
-      "count": 29,
-      "max": [
-        -0.058074676265901945,
-        2.0036171020764496e-8,
-        -6.548683375121414e-9,
-        0.9983122417243065
-      ],
-      "min": [
-        -0.1636239282889574,
-        1.922864494882868e-8,
-        -8.63670163838025e-9,
-        0.9865227874161294
-      ],
-      "type": "VEC4"
-    }
-  ],
-  "animations": [
-    {
-      "channels": [
-        {
-          "sampler": 0,
-          "target": {
-            "node": 2,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 1,
-          "target": {
-            "node": 2,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 2,
-          "target": {
-            "node": 2,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 3,
-          "target": {
-            "node": 3,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 4,
-          "target": {
-            "node": 3,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 5,
-          "target": {
-            "node": 3,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 6,
-          "target": {
-            "node": 4,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 7,
-          "target": {
-            "node": 4,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 8,
-          "target": {
-            "node": 4,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 9,
-          "target": {
-            "node": 5,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 10,
-          "target": {
-            "node": 5,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 11,
-          "target": {
-            "node": 5,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 12,
-          "target": {
-            "node": 6,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 13,
-          "target": {
-            "node": 6,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 14,
-          "target": {
-            "node": 6,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 15,
-          "target": {
-            "node": 9,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 16,
-          "target": {
-            "node": 9,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 17,
-          "target": {
-            "node": 9,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 18,
-          "target": {
-            "node": 10,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 19,
-          "target": {
-            "node": 11,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 20,
-          "target": {
-            "node": 12,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 21,
-          "target": {
-            "node": 14,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 22,
-          "target": {
-            "node": 14,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 23,
-          "target": {
-            "node": 14,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 24,
-          "target": {
-            "node": 15,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 25,
-          "target": {
-            "node": 16,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 26,
-          "target": {
-            "node": 17,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 27,
-          "target": {
-            "node": 19,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 28,
-          "target": {
-            "node": 19,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 29,
-          "target": {
-            "node": 19,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 30,
-          "target": {
-            "node": 20,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 31,
-          "target": {
-            "node": 21,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 32,
-          "target": {
-            "node": 22,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 33,
-          "target": {
-            "node": 24,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 34,
-          "target": {
-            "node": 24,
-            "path": "scale"
-          }
-        },
-        {
-          "sampler": 35,
-          "target": {
-            "node": 24,
-            "path": "translation"
-          }
-        },
-        {
-          "sampler": 36,
-          "target": {
-            "node": 25,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 37,
-          "target": {
-            "node": 26,
-            "path": "rotation"
-          }
-        },
-        {
-          "sampler": 38,
-          "target": {
-            "node": 27,
-            "path": "rotation"
-          }
-        }
-      ],
-      "name": "Main",
-      "samplers": [
-        {
-          "input": 11,
-          "interpolation": "LINEAR",
-          "output": 13
-        },
-        {
-          "input": 11,
-          "interpolation": "LINEAR",
-          "output": 14
-        },
-        {
-          "input": 11,
-          "interpolation": "LINEAR",
-          "output": 12
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 17
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 18
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 16
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 20
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 21
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 19
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 23
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 24
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 22
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 26
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 27
-        },
-        {
-          "input": 15,
-          "interpolation": "LINEAR",
-          "output": 25
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 30
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 31
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 29
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 33
-        },
-        {
-          "input": 34,
-          "interpolation": "LINEAR",
-          "output": 35
-        },
-        {
-          "input": 34,
-          "interpolation": "LINEAR",
-          "output": 36
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 38
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 39
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 37
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 40
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 41
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 42
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 44
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 45
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 43
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 46
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 47
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 48
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 50
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 51
-        },
-        {
-          "input": 28,
-          "interpolation": "LINEAR",
-          "output": 49
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 52
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 53
-        },
-        {
-          "input": 32,
-          "interpolation": "LINEAR",
-          "output": 54
-        }
-      ]
-    }
-  ],
-  "asset": {
-    "generator": "qtek fbx2gltf",
-    "version": "2.0"
-  },
-  "bufferViews": [
-    {
-      "buffer": 0,
-      "byteLength": 44660,
-      "byteOffset": 0,
-      "target": 34962
-    },
-    {
-      "buffer": 0,
-      "byteLength": 832,
-      "byteOffset": 44660,
-      "target": 34962
-    },
-    {
-      "buffer": 0,
-      "byteLength": 12080,
-      "byteOffset": 45492,
-      "target": 34962
-    },
-    {
-      "buffer": 0,
-      "byteLength": 9264,
-      "byteOffset": 57572,
-      "target": 34963
-    }
-  ],
-  "buffers": [
-    {
-      "byteLength": 66836,
-      "uri": "walk.bin"
-    }
-  ],
-  "materials": [
-    {
-      "name": "Wire",
-      "emissiveFactor": [
-        0.9019607843137255,
-        0,
-        0
-      ],
-      "extensions": {
-        "KHR_materials_pbrSpecularGlossiness": {
-          "diffuseFactor": [
-            0.9019607843137255,
-            0,
-            0,
-            1
-          ],
-          "specularFactor": [
-            0.10196078431372549,
-            0.10196078431372549,
-            0.10196078431372549
-          ],
-          "glossinessFactor": 0.5
-        }
-      }
-    },
-    {
-      "name": "Base",
-      "emissiveFactor": [
-        0,
-        0,
-        0
-      ],
-      "extensions": {
-        "KHR_materials_pbrSpecularGlossiness": {
-          "diffuseFactor": [
-            0,
-            0,
-            0,
-            1
-          ],
-          "specularFactor": [
-            0.10196078431372549,
-            0.10196078431372549,
-            0.10196078431372549
-          ],
-          "glossinessFactor": 0.5
-        }
-      }
-    }
-  ],
-  "meshes": [
-    {
-      "name": "Mesh_Material0",
-      "primitives": [
-        {
-          "attributes": {
-            "JOINTS_0": 2,
-            "POSITION": 0,
-            "TEXCOORD_0": 1,
-            "WEIGHTS_0": 3
-          },
-          "indices": 4,
-          "material": 0
-        },
-        {
-          "attributes": {
-            "JOINTS_0": 7,
-            "POSITION": 5,
-            "TEXCOORD_0": 6,
-            "WEIGHTS_0": 8
-          },
-          "indices": 9,
-          "material": 1
-        }
-      ]
-    }
-  ],
-  "nodes": [
-    {
-      "matrix": [
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1
-      ],
-      "mesh": 0,
-      "name": "Mesh",
-      "skin": 0
-    },
-    {
-      "children": [
-        2,
-        3,
-        4,
-        5,
-        6
-      ],
-      "matrix": [
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1
-      ],
-      "name": "layout"
-    },
-    {
-      "matrix": [
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0.10908540338277817,
-        0.007917225360870361,
-        -0.19540420174598694,
-        1
-      ],
-      "name": "arm_L_goal1"
-    },
-    {
-      "matrix": [
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        -0.041061561554670334,
-        1.066356958290271e-8,
-        -0.19540409743785858,
-        1
-      ],
-      "name": "leg_L_goal1"
-    },
-    {
-      "matrix": [
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        -0.08989156037569046,
-        0.05766163021326065,
-        0.08743858337402344,
-        1
-      ],
-      "name": "leg_R_goal1"
-    },
-    {
-      "matrix": [
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1,
-        0,
-        0.3882029056549072,
-        1.066356958290271e-8,
-        0.08743848651647568,
-        1
-      ],
-      "name": "arm_R_goal1"
-    },
-    {
-      "children": [
-        7,
-        9,
-        14,
-        19,
-        24
-      ],
-      "matrix": [
-        0.9999990460150695,
-        0.0009767210557009947,
-        -0.0009767215215899124,
-        0,
-        -0.0009418413642818668,
-        0.9993835218089064,
-        0.03509543092300879,
-        0,
-        0.001010397840414483,
-        -0.03509447752576613,
-        0.9993834883283782,
-        0,
-        0,
-        1.71110200881958,
-        0.03374987840652466,
-        1
-      ],
-      "name": "root"
-    },
-    {
-      "children": [
-        8
-      ],
-      "matrix": [
-        1.331580544223403e-7,
-        1.3877787807814457e-17,
-        0.9999999999999912,
-        0,
-        -0.9999999999999915,
-        6.125064648185297e-17,
-        1.3315805442190663e-7,
-        0,
-        -6.125064648185297e-17,
-        -1,
-        0,
-        0,
-        0,
-        0,
-        0,
-        1
-      ],
-      "name": "head_bone"
-    },
-    {
-      "matrix": [
-        0.9999999999999999,
-        -2.168404344971009e-19,
-        -1.3877787807814457e-17,
-        0,
-        -1.0842021724855044e-19,
-        1,
-        -8.809142651444724e-20,
-        0,
-        0,
-        1.3552527156068805e-19,
-        0.9999999999999999,
-        0,
-        0,
-        -2.168404344971009e-19,
-        -0.20000004768371582,
-        1
-      ],
-      "name": "head_bone_end_effector"
-    },
-    {
-      "children": [
-        10
-      ],
-      "matrix": [
-        0.7071067811865477,
-        1.3877787807814457e-17,
-        0.7071067811865476,
-        0,
-        -5.969888212248309e-18,
-        1,
-        0,
-        0,
-        -0.7071067811865477,
-        3.469446951953614e-18,
-        0.7071067811865477,
-        0,
-        0.08011647313833238,
-        -0.06073546037077904,
-        0.08011647313833237,
-        1
-      ],
-      "name": "arm_R_root"
-    },
-    {
-      "children": [
-        11
-      ],
-      "matrix": [
-        0.011257608597905144,
-        -0.11446542204609372,
-        0.9933634447695698,
-        0,
-        0.917545554229092,
-        0.3960659950484638,
-        0.03524036720436163,
-        0,
-        -0.3974712847025359,
-        0.9110594902211819,
-        0.10948599506254547,
-        0,
-        2.7755575615628914e-17,
-        -2.220446049250313e-16,
-        1.3877787807814457e-17,
-        1
-      ],
-      "name": "arm_R_bone1"
-    },
-    {
-      "children": [
-        12
-      ],
-      "matrix": [
-        1,
-        -1.904130303431728e-8,
-        8.301912282626667e-9,
-        0,
-        2.0545667389626487e-8,
-        0.9655471563735203,
-        -0.26022814763012936,
-        0,
-        -3.060804772830883e-9,
-        0.26022814763012964,
-        0.9655471563735208,
-        0,
-        4.5585011293480804e-8,
-        3.086052191569877e-9,
-        -0.5214316844940188,
-        1
-      ],
-      "name": "arm_R_bone2"
-    },
-    {
-      "children": [
-        13
-      ],
-      "matrix": [
-        0.9999999999999993,
-        -1.3284179367634152e-8,
-        -1.1297157027564952e-8,
-        0,
-        1.1143629130572208e-8,
-        0.9851037177266527,
-        -0.17196053879469503,
-        0,
-        1.3413226029879155e-8,
-        0.17196053879469492,
-        0.9851037177266524,
-        0,
-        3.3320748799026134e-8,
-        4.767711780928607e-10,
-        -0.3811449110507964,
-        1
-      ],
-      "name": "arm_R_bone3"
-    },
-    {
-      "matrix": [
-        1,
-        -1.6653345369377348e-16,
-        2.7755575615628914e-17,
-        0,
-        -1.1102230246251565e-16,
-        1,
-        0,
-        0,
-        2.7755575615628914e-17,
-        0,
-        0.9999999999999998,
-        0,
-        2.7755575615628914e-17,
-        0,
-        -0.8033324480056764,
-        1
-      ],
-      "name": "arm_R_bone3_end_effector"
-    },
-    {
-      "children": [
-        15
-      ],
-      "matrix": [
-        -0.7071067811865477,
-        6.938893903907228e-18,
-        0.7071067811865477,
-        0,
-        9.622294280808852e-19,
-        1,
-        6.938893903907228e-18,
-        0,
-        -0.7071067811865477,
-        0,
-        -0.7071067811865476,
-        0,
-        -0.08011647313833238,
-        -0.060735460370778815,
-        0.08011647313833237,
-        1
-      ],
-      "name": "leg_R_root"
-    },
-    {
-      "children": [
-        16
-      ],
-      "matrix": [
-        0.0003127647562193303,
-        -0.008904262574921468,
-        0.9999603073553489,
-        0,
-        0.8651231226820654,
-        0.5015420030419078,
-        0.004195448193306306,
-        0,
-        -0.5015594528857362,
-        0.865087471469046,
-        0.007860148106312193,
-        0,
-        -4.163336342344337e-17,
-        -2.220446049250313e-16,
-        0,
-        1
-      ],
-      "name": "leg_R_bone1"
-    },
-    {
-      "children": [
-        17
-      ],
-      "matrix": [
-        0.9999999999999997,
-        -2.576050761593507e-8,
-        -9.192067412788774e-9,
-        0,
-        1.94184820445642e-8,
-        0.9053448602044203,
-        -0.4246771527895501,
-        0,
-        1.926188996151379e-8,
-        0.42467715278955,
-        0.9053448602044204,
-        0,
-        4.5585011279603016e-8,
-        3.0860520805475744e-9,
-        -0.5214316844940187,
-        1
-      ],
-      "name": "leg_R_bone2"
-    },
-    {
-      "children": [
-        18
-      ],
-      "matrix": [
-        0.999999999999996,
-        -3.6092491495498535e-8,
-        -8.175138145952165e-8,
-        0,
-        -5.535752967134044e-10,
-        0.9122919994006253,
-        -0.4095400705804557,
-        0,
-        8.936245271540244e-8,
-        0.40954007058045433,
-        0.9122919994006214,
-        0,
-        3.3320748854537285e-8,
-        4.767711225817095e-10,
-        -0.3811449110507964,
-        1
-      ],
-      "name": "leg_R_bone3"
-    },
-    {
-      "matrix": [
-        1.0000000000000002,
-        -1.1102230246251565e-16,
-        -5.551115123125783e-17,
-        0,
-        -1.1102230246251565e-16,
-        1,
-        5.551115123125783e-17,
-        0,
-        -2.7755575615628914e-17,
-        -5.551115123125783e-17,
-        1,
-        0,
-        6.938893903907228e-18,
-        2.7755575615628914e-17,
-        -0.8033324480056764,
-        1
-      ],
-      "name": "leg_R_bone3_end_effector"
-    },
-    {
-      "children": [
-        20
-      ],
-      "matrix": [
-        -0.707106781186548,
-        -1.734723475976807e-17,
-        -0.7071067811865478,
-        0,
-        -5.969888212248309e-18,
-        1,
-        0,
-        0,
-        0.7071067811865479,
-        -1.0408340855860843e-17,
-        -0.707106781186548,
-        0,
-        -0.08011647313833238,
-        -0.06073546037077926,
-        -0.08011647313833237,
-        1
-      ],
-      "name": "leg_L_root"
-    },
-    {
-      "children": [
-        21
-      ],
-      "matrix": [
-        -0.001971520764457557,
-        0.053848580223104306,
-        0.9985471663941728,
-        0,
-        0.9406502904524712,
-        0.3389798200984154,
-        -0.016422930241824563,
-        0,
-        -0.3393716903007043,
-        0.9392513039511856,
-        -0.05132098838137236,
-        0,
-        0,
-        -2.220446049250313e-16,
-        0,
-        1
-      ],
-      "name": "leg_L_bone1"
-    },
-    {
-      "children": [
-        22
-      ],
-      "matrix": [
-        1.0000000000000004,
-        -2.0380670373576493e-8,
-        4.078802823270777e-9,
-        0,
-        2.0657071497787172e-8,
-        0.9528065559440093,
-        -0.3035781068359762,
-        0,
-        2.300815246658594e-9,
-        0.30357810683597636,
-        0.9528065559440095,
-        0,
-        4.5585011293480804e-8,
-        3.0860520805475744e-9,
-        -0.5214316844940187,
-        1
-      ],
-      "name": "leg_L_bone2"
-    },
-    {
-      "children": [
-        23
-      ],
-      "matrix": [
-        0.9999999999999993,
-        -1.7624569248475552e-8,
-        -2.980817417896908e-8,
-        0,
-        1.0295256203107783e-8,
-        0.973184055245276,
-        -0.23002729446262357,
-        0,
-        3.306297183952589e-8,
-        0.23002729446262302,
-        0.9731840552452757,
-        0,
-        3.33207488406595e-8,
-        4.767710670705583e-10,
-        -0.3811449110507963,
-        1
-      ],
-      "name": "leg_L_bone3"
-    },
-    {
-      "matrix": [
-        1.0000000000000002,
-        5.551115123125783e-17,
-        5.551115123125783e-17,
-        0,
-        5.551115123125783e-17,
-        1.0000000000000002,
-        -4.163336342344337e-17,
-        0,
-        -1.3877787807814457e-17,
-        -6.938893903907228e-18,
-        1.0000000000000004,
-        0,
-        5.551115123125783e-17,
-        0,
-        -0.8033324480056764,
-        1
-      ],
-      "name": "leg_L_bone3_end_effector"
-    },
-    {
-      "children": [
-        25
-      ],
-      "matrix": [
-        0.7071067811865478,
-        -6.938893903907228e-18,
-        -0.7071067811865476,
-        0,
-        9.622294280808852e-19,
-        1,
-        6.938893903907228e-18,
-        0,
-        0.7071067811865476,
-        0,
-        0.7071067811865477,
-        0,
-        0.0801164731383324,
-        -0.06073546037077904,
-        -0.08011647313833237,
-        1
-      ],
-      "name": "arm_L_root"
-    },
-    {
-      "children": [
-        26
-      ],
-      "matrix": [
-        0.0013311372808006983,
-        -0.02628076331575018,
-        0.999653714819827,
-        0,
-        0.9212641414912593,
-        0.3888334608959349,
-        0.008995626162872972,
-        0,
-        -0.388935225552935,
-        0.9209331469586867,
-        0.024729115569640914,
-        0,
-        -2.7755575615628914e-17,
-        -2.220446049250313e-16,
-        -1.3877787807814457e-17,
-        1
-      ],
-      "name": "arm_L_bone1"
-    },
-    {
-      "children": [
-        27
-      ],
-      "matrix": [
-        1,
-        -2.099252122134132e-8,
-        2.1939252359270967e-9,
-        0,
-        2.0585442239706708e-8,
-        0.9470524752700538,
-        -0.3210788206731546,
-        0,
-        4.66249158725951e-9,
-        0.3210788206731545,
-        0.9470524752700542,
-        0,
-        4.5585011314297486e-8,
-        3.0860520805475744e-9,
-        -0.5214316844940183,
-        1
-      ],
-      "name": "arm_L_bone2"
-    },
-    {
-      "children": [
-        28
-      ],
-      "matrix": [
-        0.9999999999999993,
-        -1.9477644552789997e-8,
-        -3.7389235998941395e-8,
-        0,
-        9.294988445596175e-9,
-        0.9669130921291693,
-        -0.2551055347314979,
-        0,
-        4.112099672576308e-8,
-        0.2551055347314972,
-        0.9669130921291688,
-        0,
-        3.3320748854537285e-8,
-        4.767711780928607e-10,
-        -0.3811449110507964,
-        1
-      ],
-      "name": "arm_L_bone3"
-    },
-    {
-      "matrix": [
-        1,
-        0,
-        0,
-        0,
-        1.6653345369377348e-16,
-        1,
-        0,
-        0,
-        0,
-        0,
-        1.0000000000000002,
-        0,
-        0,
-        -2.7755575615628914e-17,
-        -0.8033324480056765,
-        1
-      ],
-      "name": "arm_L_bone3_end_effector"
-    }
-  ],
-  "scene": 0,
-  "scenes": [
-    {
-      "nodes": [
-        0,
-        1
-      ]
-    }
-  ],
-  "skins": [
-    {
-      "inverseBindMatrices": 10,
-      "joints": [
-        7,
-        10,
-        11,
-        12,
-        15,
-        16,
-        17,
-        20,
-        21,
-        22,
-        25,
-        26,
-        27
-      ]
-    }
-  ],
-  "extras": {
-    "qtekModelViewerConfig": {
-      "preZ": true,
-      "materials": [
-        {
-          "name": "Wire",
-          "color": "#e60000",
-          "emission": "#e60000",
-          "alpha": 1,
-          "alphaCutoff": 0,
-          "emissionIntensity": 1,
-          "uvRepeat": {
-            "0": 1,
-            "1": 1
-          },
-          "parallaxOcclusionScale": 0.02,
-          "diffuseMap": "",
-          "normalMap": "",
-          "parallaxOcclusionMap": "",
-          "emissiveMap": "",
-          "specularColor": "#1a1a1a",
-          "glossiness": 0.5,
-          "specularMap": "",
-          "glossinessMap": "",
-          "type": "pbrSpecularGlossiness",
-          "targetMeshes": [
-            "Mesh_Material0"
-          ]
-        },
-        {
-          "name": "Base",
-          "color": "#000000",
-          "emission": "#000000",
-          "alpha": 1,
-          "alphaCutoff": 0,
-          "emissionIntensity": 1,
-          "uvRepeat": {
-            "0": 1,
-            "1": 1
-          },
-          "parallaxOcclusionScale": 0.02,
-          "diffuseMap": "",
-          "normalMap": "",
-          "parallaxOcclusionMap": "",
-          "emissiveMap": "",
-          "specularColor": "#1a1a1a",
-          "glossiness": 0.5,
-          "specularMap": "",
-          "glossinessMap": "",
-          "type": "pbrSpecularGlossiness",
-          "targetMeshes": [
-            "Mesh_Material0$1"
-          ]
-        }
-      ],
-      "takes": [],
-      "textureFlipY": false,
-      "zUpToYUp": false,
-      "shadow": true,
-      "environment": "auto",
-      "viewControl": {
-        "center": [
-          1.0690909624099731,
-          -1.1321967840194702,
-          0.9232351183891296
-        ],
-        "alpha": 10.229259828771838,
-        "beta": 33.79452028477864,
-        "distance": 19.502084087073698
-      },
-      "ground": {
-        "show": true
-      },
-      "mainLight": {
-        "shadow": true,
-        "shadowQuality": "medium",
-        "intensity": 0.8,
-        "color": "#fff",
-        "alpha": 45,
-        "beta": 45,
-        "$padAngle": [
-          0.25,
-          0.5
-        ]
-      },
-      "secondaryLight": {
-        "shadow": false,
-        "shadowQuality": "medium",
-        "intensity": 0,
-        "color": "#fff",
-        "alpha": 60,
-        "beta": -50,
-        "$padAngle": [
-          -0.2777777777777778,
-          0.6666666666666666
-        ]
-      },
-      "tertiaryLight": {
-        "shadow": false,
-        "shadowQuality": "medium",
-        "intensity": 0,
-        "color": "#fff",
-        "alpha": 89,
-        "beta": 0,
-        "$padAngle": [
-          0,
-          0.9888888888888889
-        ]
-      },
-      "ambientLight": {
-        "intensity": 0,
-        "color": "#fff"
-      },
-      "ambientCubemapLight": {
-        "texture": "./asset/texture/Barce_Rooftop_C.hdr",
-        "$texture": "Barce_Rooftop_C",
-        "$textureOptions": [
-          "pisa",
-          "Barce_Rooftop_C",
-          "Factory_Catwalk",
-          "Grand_Canyon_C",
-          "Ice_Lake",
-          "Hall",
-          "Old_Industrial_Hall"
-        ],
-        "exposure": 3,
-        "diffuseIntensity": 0.2,
-        "specularIntensity": 0.2,
-        "$intensity": 0.2
-      },
-      "postEffect": {
-        "enable": true,
-        "bloom": {
-          "enable": true,
-          "intensity": 0.1
-        },
-        "depthOfField": {
-          "enable": false,
-          "focalDistance": 4,
-          "focalRange": 1,
-          "blurRadius": 5,
-          "fstop": 10,
-          "quality": "medium",
-          "$qualityOptions": [
-            "low",
-            "medium",
-            "high",
-            "ultra"
-          ]
-        },
-        "screenSpaceAmbientOcclusion": {
-          "enable": false,
-          "radius": 1.5,
-          "quality": "medium",
-          "intensity": 1,
-          "$qualityOptions": [
-            "low",
-            "medium",
-            "high",
-            "ultra"
-          ]
-        },
-        "screenSpaceReflection": {
-          "enable": false,
-          "quality": "medium",
-          "maxRoughness": 0.8,
-          "$qualityOptions": [
-            "low",
-            "medium",
-            "high",
-            "ultra"
-          ]
-        },
-        "colorCorrection": {
-          "enable": true,
-          "exposure": 0,
-          "brightness": 0,
-          "contrast": 1,
-          "saturation": 1,
-          "lookupTexture": ""
-        },
-        "FXAA": {
-          "enable": false
-        }
-      }
-    }
-  },
-  "extensionsUsed": [
-    "KHR_materials_pbrSpecularGlossiness"
-  ]
-}

二进制
modules/mojo3d/tests/assets/water1.jpg


+ 0 - 76
modules/mojo3d/tests/bouncyball_gltf2.monkey2

@@ -1,76 +0,0 @@
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/bouncyball/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _model:Model
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		_scene=Scene.GetCurrent()
-		
-		_scene.ClearColor=Color.Sky
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Move( 0,10,-5 )
-		
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.RotateX( 90 )
-		
-		'create donut - metallic silver...
-		
-		Local material:=New PbrMaterial( Color.Silver,1,0.5 )
-		
-		_model=Model.LoadBoned( "asset::bouncyball.gltf" )
-		
-		_model.Animator.Animate( 0 )
-		
-		_model.Move( 0,7,0 )
-		
-'		_model.Mesh.FitVertices( New Boxf( -1,1 ),False )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 324
modules/mojo3d/tests/bouncyboxes.monkey2

@@ -1,324 +0,0 @@
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-#Import "<bullet>"
- 
-Using std..
-Using mojo..
-Using mojo3d..
- 
-Const WALL_WIDTH:Int	= 20
-Const WALL_HEIGHT:Int	= 20
- 
-Class PhysBox
- 
-	Class PhysParams
-		Field mass:Float
-		Field group:Short
-		Field mask:Short
-	End
-	
-	Field box:Boxf
-	Field model:Model
-	Field collider:BoxCollider
-	Field body:RigidBody
- 
-	Field init:PhysParams
-	 
-	Method New (width:Float = 1, height:Float = 1, depth:Float = 1, mass:Float = 1, material:Material = Null, group:Int = 1, mask:Int = 1)
- 
-		' Store setup params for PhysBox.Start ()
-		
-'		SetConfig( "MOJO3D_RENDERER","forward" )
-		
-		init = New PhysParams
-		
-		init.mass	= mass
-		init.group	= group
-		init.mask	= mask
-		
-		If Not material
-			material = New PbrMaterial (Color.Red)
-		Endif
-		
-		box					= New Boxf (-width * 0.5, -height * 0.5, -depth * 0.5, width * 0.5, height * 0.5, depth * 0.5)
-		model				= Model.CreateBox (box, 1, 1, 1, material)
- 
-	End
- 
-	Method Start ()
- 
-		collider			= New BoxCollider (model)
-		body				= New RigidBody (model)
- 
-		collider.Box		= box
-	
-		body.Mass			= init.mass
-		body.CollisionGroup	= init.group
-		body.CollisionMask	= init.mask
-		
-		box					= Null
-		init				= Null
-		
-	End
-	 
-	Method Move (x:Float, y:Float, z:Float)
-		model.Move (x, y, z)
-	End
- 
-	Method Rotate (pitch:Float, roll:Float, yaw:Float, localspace:Bool = False)
-		model.Rotate (pitch, roll, yaw, localspace)
-	End
-	
-End
- 
-Class Game Extends Window
- 
-	Const CAMERA_MOVE:Float = 0.05
-	Const CAMERA_BOOST:Float = 4.0
-	
-	Field cam_boost:Float = 1.0
-	 
-	Field scene:Scene
-	Field cam:Camera
-	Field light:Light
-	
-	Field ground:PhysBox
- 
-	Field boxes:List <PhysBox>
-	Field bullets:List <PhysBox>
-	
-	Method New (title:String, width:Int, height:Int, flags:WindowFlags)
- 
-		Super.New (title, width, height, flags)
- 
-		SwapInterval = 1
-		
-		CreateArena (50)
-		
-	End
-	
-	Method CreateArena:Void (ground_size:Float = 100)
- 
-		SeedRnd (Millisecs ())
-		
-		scene					= Scene.GetCurrent ()
-		ground					= New PhysBox (ground_size, 1, ground_size, 0, New PbrMaterial (Color.Green * 0.25))
-		cam						= New Camera( Self )
-		light					= New Light
- 
-		scene.AmbientLight	= Color.White * 0.75
-		scene.ClearColor	= Color.Sky * 0.75
-		scene.ShadowAlpha	= .5
- 
-		cam.FOV = 100
-		cam.Move (0, 10, -10)
-		
-		ground.Start ()
-		
-		cam.Near				= 0.01
-		cam.Far					= 1000
-	
-		light.CastsShadow		= True
-		light.Range				= 1000
- 
-		light.Move (0, 20, 10)
-		
-'		cam.PointAt (ground.model)
-		light.PointAt (ground.model)
- 
-		boxes	= New List <PhysBox>
-		bullets	= New List <PhysBox>
- 
-		BuildWall (WALL_WIDTH, WALL_HEIGHT)
-		
-	End
- 
-	Method BuildWall (width:Int, height:Int)
-	
-		For Local y:Int = 0 Until height
-			For Local x:Int = 0 Until width
-				
-				Local color:Color = New Color (Rnd (0.4, 1.0), Rnd (0.4, 1.0), Rnd (0.4, 1.0))
-				
-				' Create new PhysBox...
-				
-				Local pb:PhysBox = New PhysBox (1, 1, 1, 1, New PbrMaterial (color))
-				
-				' Position PhysBox...
-				
-	 			pb.Move (x - (width / 2.0), (y + 1), 0)
-	
-				boxes.Add (pb)
-				
-				' Start its physics...
-				
-				pb.Start ()
-				
-			Next
-		Next
- 
-	End
- 
-	Method DropBox ()
- 
-		Local pb:PhysBox = New PhysBox (1, 1, 1, 1, New PbrMaterial (Color.Red))
-		
-		pb.Move (0, 50, 0)
- 
-		boxes.Add (pb)
-		
-		pb.Start ()
- 
-	End
-	
-	Method BumpWall ()
- 
-		Local vec:Vec3f = New Vec3f (0.0, 0.5, 0.0)
-	
-		'Local count:Int
-		
-		For Local pb:PhysBox = Eachin boxes
-			'If Not pb.collider Then Print "No collider"
-			'If Not pb.body Then Print "No body"
-			pb.body.ApplyImpulse (vec)
-			'pb.body.LinearVelocity=vec
-			'Print "Body count: " + count
-			'count = count + 1
-		Next
-		
-		'Print Millisecs ()
-		
-	End
-	
-	Method UpdateBoxes ()
- 
-		For Local pb:PhysBox = Eachin boxes
- 
-			If pb.model.Y < -20
- 
-				pb.model.Scale = pb.model.Scale * 0.75
- 
-				If pb.model.Scale.x < 0.01
-					pb.model.Destroy ()
-					boxes.Remove (pb)
-				Endif
- 
-			Endif
- 
-		Next
- 
-	End
- 
-	Method UpdateGame ()
-		
-		UpdateBoxes ()
-		
-		If Keyboard.KeyDown (Key.D)
-			DropBox ()
-		Endif
- 	
-		If Keyboard.KeyDown (Key.B)
-			BumpWall ()
-		Endif
- 	
-		If Keyboard.KeyHit (Key.Escape)
-			App.Terminate ()
-		Endif
- 	
- 		If Keyboard.KeyHit (Key.S)
-			light.CastsShadow = Not light.CastsShadow
-		Endif
-	 
- 		If Keyboard.KeyHit (Key.Space)
- 			
- 			For Local pb:PhysBox = Eachin boxes
-				pb.model.Destroy ()
-				boxes.Remove (pb)
-			Next
-			
-			BuildWall (WALL_WIDTH, WALL_HEIGHT)
-			
-		Endif
-	 
-		If Keyboard.KeyDown (Key.LeftShift)
-			cam_boost = CAMERA_BOOST
-		Else
-			cam_boost = 1.0
-		Endif
-		
-		If Keyboard.KeyDown (Key.A)
-			cam.Move (0.0, 0.0, CAMERA_MOVE * cam_boost)
-		Endif
- 
-		If Keyboard.KeyDown (Key.Z)
-			cam.Move (0.0, 0.0, -CAMERA_MOVE * cam_boost)
-		Endif
- 
-		If Keyboard.KeyDown (Key.Left)
-			cam.Rotate (0.0, 1.0, 0.0)
-		Endif
- 
-		If Keyboard.KeyDown (Key.Right)
-			cam.Rotate (0.0, -1.0, 0.0)
-		Endif
- 
-		If Keyboard.KeyDown (Key.Up)
-			cam.Rotate (1.0, 0.0, 0.0, True)
-		Endif
- 
-		If Keyboard.KeyDown (Key.Down)
-			cam.Rotate (-1.0, 0.0, 0.0, True)
-		Endif
-		
-	End
- 
-	Method ShadowText:Void (canvas:Canvas, s:String, x:Float, y:Float)
-		canvas.Color = Color.Black
-		canvas.DrawText	(s, x + 1, y + 1)
-		canvas.Color = Color.White
-		canvas.DrawText	(s, x, y)
-	End
- 
-	Method RenderText (canvas:Canvas)
-		
-		ShadowText (canvas, "FPS: " + App.FPS, 20.0, 20.0)
-		ShadowText (canvas, "A/Z + Cursors to move camera", 20.0, 40.0)
-		ShadowText (canvas, "SHIFT to boost", 20.0, 60.0)
-		ShadowText (canvas, "SPACE to rebuild wall", 20.0, 80.0)
-		ShadowText (canvas, "S to toggle shadows", 20.0, 100.0)
-		ShadowText (canvas, "B to boost boxes", 20.0, 120.0)
- 		ShadowText (canvas, "Boxes: " + boxes.Count (), 20.0, 160.0)
-		
-	End
-	
-	Method OnRender (canvas:Canvas) Override
- 
-		RequestRender ()
-		
-		UpdateGame ()
-		
-		scene.Update ()
-		
-		scene.Render (canvas)
- 
-		RenderText (canvas)
-		
-	End
-	
-End
- 
-Function Run3D (title:String, width:Int, height:Int, flags:WindowFlags = WindowFlags.Center)
- 
-	New AppInstance
-	New Game (title, width, height, flags)
- 
-	App.Run ()
- 
-End
- 
-Function Main ()
-	Run3D ("3D Scene", 960, 540, WindowFlags.Center)		' 1/4 HD!
-'	Run3D ("3D Scene", 1920, 1080, WindowFlags.Fullscreen) 
-End

+ 0 - 103
modules/mojo3d/tests/constraints.monkey2

@@ -1,103 +0,0 @@
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _ground:Model
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		_scene=New Scene
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Name="Camera"
-		_camera.Near=.1
-		_camera.Far=60
-		_camera.Move( 0,10,-10 )
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.RotateX( 75,15 )
-		_light.CastsShadow=true
-		
-		'create ground
-		'
-		Local groundBox:=New Boxf( -60,-1,-60,60,0,60 )
-		_ground=Model.CreateBox( groundBox,16,16,16,New PbrMaterial( Color.Green ) )
-		_ground.Name="Ground"
-		Local groundCollider:=New BoxCollider( _ground )
-		groundCollider.Box=groundBox
-		Local groundBody:=New RigidBody( _ground )
-		groundBody.Mass=0
-		
-		Local modelBox:=New Boxf( -.5,.5 )
-		Local modelMaterial:=New PbrMaterial( Color.Orange )
-		Local model:=Model.CreateBox( modelBox,1,1,1,modelMaterial )
-		Local modelCollider:=model.AddComponent<BoxCollider>()
-		modelCollider.Box=modelBox
-		Local modelBody:=model.AddComponent<RigidBody>()
-
-		Local prev:Model
-		
-		For Local i:=0 Until 100
-			
-			Local copy:=model.Copy()
-			copy.Move( 0,1+i*1.2,0 )
-			
-			If prev
-				Local constraint:=prev.AddComponent<PointToPointConstraint>()
-				constraint.Pivot=New Vec3f( 0,.6,0 )
-				constraint.ConnectedBody=copy.RigidBody
-				constraint.ConnectedPivot=New Vec3f( 0,-.6,0 )
-			Endif
-			
-			prev=copy
-		Next
-		
-		prev.RigidBody.Mass=0
-		
-		model.Destroy()
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-		
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 88
modules/mojo3d/tests/cubes.monkey2

@@ -1,88 +0,0 @@
-Namespace myapp
-
-#Reflect mojo3d
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		Print opengl.glGetString( opengl.GL_VERSION )
-		
-		_scene=New Scene
-		
-		_scene.Editing=True
-		
-		_scene.ClearColor=Color.Sky
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Name="Camera"
-		_camera.Near=.1
-		_camera.Far=1000
-		_camera.Move( 0,10,-10 )
-		
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.Rotate( 30,60,0 )
-		
-		'Create cube
-		'
-		Local cube:=Model.CreateBox( New Boxf( -1,1 ),1,1,1,New PbrMaterial( Color.White ) )
-		
-		cube.CastsShadow=False
-		
-		For Local x:=-50.0 To 50.0 Step 2.5
-			For Local z:=-50.0 To 50.0 Step 2.5
-				Local copy:=cube.Copy()
-				copy.Move( x,0,z )
-			Next
-		Next
-		
-		cube.Destroy()
-		
-		_scene.Save( "cubes-scene.mojo3d" )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-		
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-	
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 94
modules/mojo3d/tests/cubeseam.monkey2

@@ -1,94 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _donut:Model
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		_scene=Scene.GetCurrent()
-		
-		_scene.AmbientLight=Color.Black
-		
-		_scene.ClearColor=Color.Black
-		
-		ToggleEnv()
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Move( 0,0,-5 )
-		New FlyBehaviour( _camera )
-		
-		'create white donut
-		'		
-		Local material:=New PbrMaterial( Color.White,1,1 )
-		
-		_donut=Model.CreateTorus( 2,.5,48,24,material )
-	End
-	
-	Method ToggleEnv()
-		
-		Global _filter:TextureFlags=Null
-		
-		_filter=_filter ? Null Else TextureFlags.FilterMipmap
-			
-		'little mini cubemap
-		Local pixmap:=New Pixmap( 4,3 )
-		pixmap.Clear( Color.Black )
-		pixmap.SetPixelARGB( 1,0,$ffff0000 )
-		pixmap.SetPixelARGB( 1,1,$ff00ff00 )
-		pixmap.SetPixelARGB( 1,2,$ff0000ff )
-		pixmap.SetPixelARGB( 0,1,$ffffff00 )
-		pixmap.SetPixelARGB( 2,1,$ffff00ff )
-		pixmap.SetPixelARGB( 3,1,$ff00ffff )
-		Local cubemap:=New Texture( pixmap,TextureFlags.Cubemap|_filter )
-		
-		_scene.EnvTexture=cubemap
-		
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		RequestRender()
-		
-		If Keyboard.KeyHit( Key.Space ) ToggleEnv()
-		
-		_donut.Rotate( .1,.2,.3 )
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "Hit <space> to toggle cubemap filtering (ie: seamless cubemaps)",0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 78
modules/mojo3d/tests/donut.monkey2

@@ -1,78 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Function Main()
-	
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _donut:Model
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		SetConfig( "MOJO3D_RENDERER","forward" )
-		
-		_scene=New Scene
-		
-		_scene.ClearColor=Color.Sky
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Move( 0,10,-10 )
-		
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.Rotate( 75,15,0 )
-		
-		'create donut - metallic silver...
-		
-		Local material:=New PbrMaterial( Color.Silver,1,0.5 )
-		
-		_donut=Model.CreateTorus( 2,.5,48,24,material )
-		
-		_donut.Move( 0,10,0 )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		RequestRender()
-		
-		_donut.Rotate( .1,.2,.3 )
-		
-		_scene.Update()
-		
-		_camera.Render( canvas )
-		
-		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
-	End
-	
-End
-

+ 0 - 131
modules/mojo3d/tests/ducks-scene.monkey2

@@ -1,131 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Reflect mojo3d
-
-#Import "assets/duck.gltf/@/duck.gltf"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _ground:Model
-	
-	Field _ducks:=New Stack<Model>
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		'create scene
-		'		
-		_scene=New Scene( True )
-		
-		'for softer shadows
-		'
-		_scene.ShadowAlpha=.6
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Move( 0,15,-20 )
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.CastsShadow=True
-		_light.Rotate( 75,15,0 )
-		
-		'create ground
-		'
-		_ground=Model.CreateBox( New Boxf( -50,-1,-50,50,0,50 ),1,1,1,New PbrMaterial( Color.Green,0,1 ) )
-		_ground.CastsShadow=False
-		
-		'create ducks
-		'		
-		Local duck:=Model.Load( "asset::duck.gltf/Duck.gltf" )
-		duck.Mesh.FitVertices( New Boxf( -1,1 ) )
-		
-		Local root:=duck.Copy()
-		root.Move( 0,10,0 )
-		root.Scale=New Vec3f( 3 )
-		
-		_ducks.Push( root )
-		
-		For Local m:=0.0 To 1.0 Step .125
-		
-			For Local i:=0.0 Until 360.0 Step 24
-			
-				Local copy:=duck.Copy( root )
-				
-				copy.RotateY( i )
-				
-				copy.Move( 0,0,6+m*16 )
-
-				copy.Scale=New Vec3f( 1 )
-				
-				Local materials:=copy.Materials.Slice( 0 )
-				
-				For Local j:=0 Until materials.Length
-				
-					Local material:=Cast<PbrMaterial>( materials[j].Copy() )
-					
-					material.MetalnessFactor=m
-					material.RoughnessFactor=i/360.0
-					
-					materials[j]=material
-				Next
-				
-				copy.Materials=materials
-				
-				_ducks.Push( copy )
-			Next
-		Next
-		
-		duck.Destroy()
-		
-		_ducks[0].AddComponent<RotateBehaviour>().Speed=New Vec3f( 0,.01,0 )
-		
-		Print "Saving.."
-		
-		_scene.Save( "ducks-scene.mojo3d","modules/mojo3d/tests/assets/" )	'note: assets path is a bit of a hack! Need access to compile time assets dir path.
-		
-		Print "Loading..."
-		
-		_scene=Scene.Load( "ducks-scene.mojo3d" )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-
-		canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )
-	End
-	
-End
-
-Function Main()
-	
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 5 - 4
modules/mojo3d/tests/ducks.monkey2

@@ -38,6 +38,7 @@ Class MyWindow Extends Window
 		'create camera
 		'
 		_camera=New Camera( Self )
+		
 		_camera.Move( 0,15,-20 )
 		
 		New FlyBehaviour( _camera )
@@ -46,7 +47,7 @@ Class MyWindow Extends Window
 		'
 		_light=New Light
 		_light.CastsShadow=True
-		_light.Rotate( 75,15,0 )
+		_light.Rotate( 90,0,0 )'75,15,0 )
 		
 		'create ground
 		'
@@ -64,6 +65,8 @@ Class MyWindow Extends Window
 		
 		_ducks.Push( root )
 		
+		_ducks[0].AddComponent<RotateBehaviour>().Speed=New Vec3f( 0,-.01,0 )
+		
 		For Local m:=0.0 To 1.0 Step .125
 		
 			For Local i:=0.0 Until 360.0 Step 24
@@ -102,11 +105,9 @@ Class MyWindow Extends Window
 
 		RequestRender()
 		
-		_ducks[0].Rotate( 0,-.01,0 )
-		
 		_scene.Update()
 		
-		_camera.Render( canvas )
+		_scene.Render( canvas )
 
 		canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )
 	End

+ 12 - 5
modules/mojo3d/tests/bloom.monkey2 → modules/mojo3d/tests/effects.monkey2

@@ -22,18 +22,21 @@ Class MyWindow Extends Window
 	
 	Field _bloom:BloomEffect
 	
+	Field _mono:MonochromeEffect
+	
 	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
 
 		Super.New( title,width,height,flags )
 		
 		_scene=Scene.GetCurrent()
-		
 		_scene.ClearColor=Color.Black
 		
 		_bloom=New BloomEffect
-		
 		_scene.AddPostEffect( _bloom )
 		
+		_mono=New MonochromeEffect
+		_scene.AddPostEffect( _mono )
+		
 		'create camera
 		'
 		_camera=New Camera( self )
@@ -49,6 +52,7 @@ Class MyWindow Extends Window
 		material.EmissiveFactor=New Color( 0,2,0 )
 		
 		_donut=Model.CreateTorus( 2,.5,48,24,material )
+		_donut.AddComponent<RotateBehaviour>().Speed=New Vec3f( .1,.2,.3 )
 		
 		_donut.Move( 0,10,0 )
 	End
@@ -57,12 +61,15 @@ Class MyWindow Extends Window
 		
 		RequestRender()
 		
-		_donut.Rotate( .1,.2,.3 )
+		If Keyboard.KeyHit( Key.Key1 ) _bloom.Enabled=Not _bloom.Enabled
+
+		If Keyboard.KeyHit( Key.Key2 ) _mono.Enabled=Not _mono.Enabled
 		
-		_scene.Render( canvas )
+		_scene.Update()
 		
-		canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )
+		_scene.Render( canvas )
 		
+		canvas.DrawText( "Bloom="+_bloom.Enabled+" (1) monochrome="+_mono.Enabled+" (2)",0,0 )
 	End
 	
 End

+ 0 - 127
modules/mojo3d/tests/fishes.monkey2

@@ -1,127 +0,0 @@
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/fish.glb"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _ground:Model
-	
-	Field _ducks:=New Stack<Model>
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		Print "GL_VERSION="+opengl.glGetString( opengl.GL_VERSION )
-		
-'		SetConfig( "MOJO3D_RENDERER_DEFERRED",1 )
-		
-		SwapInterval=1
-		
-		'create scene
-		'		
-		_scene=New Scene
-		
-		_scene.ClearColor=Color.Sky
-		
-		_scene.ShadowAlpha=.5
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Near=.1
-		_camera.Far=50
-		_camera.FOV=90
-		_camera.Move( 0,15,-20 )
-		
-		New FlyBehaviour( _camera )
-		
-		'create light
-		_light=New Light
-		_light.Rotate( 75,15,0 )
-		_light.Range=40
-		_light.CastsShadow=True
-
-		'create ground
-		'
-		_ground=Model.CreateBox( New Boxf( -50,-1,-50,50,0,50 ),1,1,1,New PbrMaterial( Color.Green,0,1 ) )
-		_ground.CastsShadow=False
-		
-		'create ducks
-		'		
-		Local duck:=Model.Load( "asset::fish.glb" )
-		duck.Mesh.FitVertices( New Boxf( -1,1 ) )
-		
-		Local root:=duck.Copy()
-		root.Move( 0,10,0 )
-		root.Scale=New Vec3f( 3 )
-		
-		_ducks.Push( root )
-		
-		For Local m:=0.0 To 1.0 Step .125
-		
-			For Local i:=0.0 Until 360.0 Step 24
-			
-				Local copy:=duck.Copy( root )
-				
-				copy.RotateY( i )
-				
-				copy.Move( 0,0,6+m*16 )
-				
-				copy.Scale=New Vec3f( 1 )
-				
-				For Local j:=0 Until copy.Materials.Length
-				
-					Local material:=Cast<PbrMaterial>( copy.Materials[j].Copy() )
-					
-					material.MetalnessFactor=m
-					material.RoughnessFactor=i/360.0
-					
-					copy.Materials[j]=material
-				Next
-				
-				_ducks.Push( copy )
-			
-			Next
-		Next
-		
-		duck.Destroy()
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-
-		canvas.Scale( Width/640.0,Height/480.0 )
-		
-		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 70
modules/mojo3d/tests/glb_test.monkey2

@@ -1,70 +0,0 @@
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/platform.glb"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _model:Model
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		_scene=Scene.GetCurrent()
-		
-		_scene.ClearColor=Color.Sky
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Move( 0,10,-10 )
-		
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.RotateX( 90 )
-		
-		'load glb model
-		'
-		_model=Model.Load( "asset::platform.glb" )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		RequestRender()
-		
-		_model.Rotate( 1,2,3 )
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 100
modules/mojo3d/tests/loadscene.monkey2

@@ -1,100 +0,0 @@
-Namespace myapp3d
-
-#Reflect mojo3d
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	Field _camera:Camera
-	Field _light:Light
-	Field _ground:Model
-	Field _donut:Model
-	
-	Method New( title:String="Simple mojo3d app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-		
-		Super.New( title,width,height,flags )
-	End
-	
-	Method CreateScene()
-		
-		_scene.AmbientLight = _scene.ClearColor * 0.25
-		_scene.FogColor = _scene.ClearColor
-		_scene.FogFar = 1.0
-		_scene.FogFar = 200.0
-
-		'create camera
-		_camera=New Camera
-		_camera.AddComponent<FlyBehaviour>()
-		_camera.Move( 0,2.5,-5 )
-		
-		'create light
-		_light=New Light
-		_light.CastsShadow=True
-		_light.Rotate( 45, 45, 0 )
-		
-		'create ground
-		Local groundBox:=New Boxf( -100,-1,-100,100,0,100 )
-		Local groundMaterial:=New PbrMaterial( Color.Lime )
-		_ground=Model.CreateBox( groundBox,1,1,1,groundMaterial )
-		_ground.CastsShadow=False
-		
-		'create donut
-		Local donutMaterial:=New PbrMaterial( Color.Red, 0.05, 0.2 )
-		_donut=Model.CreateTorus( 2,.5,48,24,donutMaterial )
-		_donut.Move( 0,2.5,0 )
-		Local rb:=_donut.AddComponent<RotateBehaviour>()
-		rb.Speed=New Vec3f( .2,.4,.6 )
-	End
-	
-	Method OnCreateWindow() Override
-		
-		Local path:=CurrentDir()+"test-scene.mojo3d"
-		
-		_scene=New Scene
-		
-		_scene.Editing=True
-		
-		Print "Creating scene"
-		
-		CreateScene()
-		
-		Print "Saving scene to "+path
-			
-		_scene.Save( path )
-		
-		Print "Loading scene from "+path
-			
-		_scene=Scene.Load( path )
-			
-		_camera=Cast<Camera>( _scene.FindEntity( "Camera" ) )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-		
-		RequestRender()
-		
-		_scene.Update()
-		
-		_camera.Render( canvas )
-		
-		canvas.DrawText( "FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 86
modules/mojo3d/tests/makequad.monkey2

@@ -1,86 +0,0 @@
-
-#rem
-
-Very simple demo showing how to make a custom mesh.
-
-#end
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _model:Model
-	
-	Method New()
-		
-		'create scene
-		'
-		_scene=New Scene
-
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Move( 0,0,-2.5 )
-		
-		'create light
-		'
-		_light=New Light
-		_light.Rotate( 60,30,0 )
-		
-		'create quad mesh
-		'
-		Local vertices:=New Vertex3f[](
-			New Vertex3f( -1, 1,0 ),
-			New Vertex3f(  1, 1,0 ),
-			New Vertex3f(  1,-1,0 ),
-			New Vertex3f( -1,-1,0 ) )
-
-		Local indices:=New UInt[]( 0,1,2,0,2,3 )
-		
-		Local mesh:=New Mesh( vertices,indices )
-		
-		'Update mesh normals since we haven't provided them ourselves
-		'
-		mesh.UpdateNormals()
-		
-		'create model for the mesh
-		'
-		_model=New Model
-		_model.Mesh=mesh
-		_model.Material=New PbrMaterial( Color.Red )
-		_model.Material.CullMode=CullMode.None
-
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-		
-		RequestRender()
-		
-		_model.RotateY( 1 )
-		
-		_scene.Render( canvas )
-
-		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-	
-	New AppInstance
-	New MyWindow
-	App.Run()
-End
-
-	

+ 0 - 160
modules/mojo3d/tests/morpher.monkey2

@@ -1,160 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class Morpher Extends Renderable
-
-	Method New( mesh0:Mesh,mesh1:Mesh,material:Material,parent:Entity=null )
-		Super.New( parent )
-
-		'get mesh vertices - don't need entire meshes	
-		_vertices0=mesh0.GetVertices()
-		_vertices1=mesh1.GetVertices()
-		_material=material
-		
-		'create vertexbuffer
-		'
-		_vbuffer=New VertexBuffer( Vertex3f.Format,_vertices0.Length )
-		
-		'create and initilize indexbuffer
-		'	
-		Local indices:=mesh0.GetIndices( 0 )
-		_ibuffer=New IndexBuffer( IndexFormat.UINT32,indices.Length )
-		_ibuffer.SetIndices( indices.Data,0,indices.Length )
-		
-		Visible=true
-	End
-	
-	Protected
-	
-	Method OnRender( rq:RenderQueue ) override
-	
-		Local alpha:=Sin( Now() )*.5+.5
-		
-		'lock vertex buffer
-		Local vp:=Cast<Vertex3f Ptr>( _vbuffer.Lock() )
-		
-		For Local i:=0 Until _vbuffer.Length
-		
-			Local v:=_vertices0[i]
-
-			'interpolate position			
-			v.position=_vertices0[i].position.Blend( _vertices1[i].position,alpha )
-			
-			'interpolate normal
-			v.normal=_vertices0[i].normal.Blend( _vertices1[i].normal,alpha ).Normalize()
-			
-			vp[i]=v
-		Next
-		
-		'invalidate all vertices
-		_vbuffer.Invalidate()
-		
-		'unlock vertices
-		_vbuffer.Unlock()
-		
-		'add renderop
-		rq.AddRenderOp( _material,Self,_vbuffer,_ibuffer,3,_ibuffer.Length/3,0 )
-	End
-	
-	Private
-	
-	Field _vertices0:Vertex3f[]
-	Field _vertices1:Vertex3f[]
-	Field _material:Material
-	
-	Field _vbuffer:VertexBuffer
-	Field _ibuffer:IndexBuffer
-	
-	Field _nvertices:Int
-End
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _morpher:Morpher
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		'create scene
-		'		
-		_scene=New Scene
-		
-		_scene.ClearColor=Color.Sky
-		
-		'create camera
-		'
-		_camera=New Camera
-		
-		_camera.Move( 0,0,-5 )
-		
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		
-		_light.Rotate( 75,15,0 )
-		
-		Local mesh1:=Mesh.CreateBox( New Boxf( -1,1 ),8,8,8 )
-		
-		Local mesh2:=Mesh.CreateBox( New Boxf( -1,1 ),8,8,8 )
-		
-		'sphericalize mesh2
-		For Local i:=0 Until mesh2.NumVertices
-			Local v:=mesh2.GetVertex( i )
-			v.position=v.position.Normalize()
-			v.normal=v.position.Normalize()
-			mesh2.SetVertex( i,v )
-		Next
-		
-		Local material:=New PbrMaterial( Color.Green )
-		
-		_morpher=New Morpher( mesh1,mesh2,material )
-		
-		_morpher.Visible=True
-		
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-
-		RequestRender()
-		
-		_camera.Viewport=Rect
-
-		_scene.Render( canvas )
-
-		canvas.Scale( Width/640.0,Height/480.0 )
-		
-		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-	
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End
-		
-		
-		

+ 4 - 6
modules/mojo3d/tests/particles.monkey2

@@ -4,8 +4,6 @@ Namespace myapp
 #Import "<mojo>"
 #Import "<mojo3d>"
 
-#Import "assets/"
-
 Using std..
 Using mojo..
 Using mojo3d..
@@ -28,7 +26,7 @@ Class MyWindow Extends Window
 		
 		_scene=Scene.GetCurrent()
 		
-		_scene.SkyTexture=Texture.Load( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )
+'		_scene.SkyTexture=Texture.Load( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )
 		
 		_scene.FogColor=Color.Sky
 		_scene.FogNear=20
@@ -54,7 +52,7 @@ Class MyWindow Extends Window
 		_particles.RotateX( -90 )	'point upwards!
 		
 		Local pmaterial:=_particles.Material
-		pmaterial.ColorTexture=Texture.Load( "asset::bluspark.png",TextureFlags.FilterMipmap )
+'		pmaterial.ColorTexture=Texture.Load( "asset::bluspark.png",TextureFlags.FilterMipmap )
 		
 		Local pbuffer:=_particles.ParticleBuffer
 		pbuffer.Gravity=New Vec3f( 0,-9.81,0 )	'gravity in world space in m/s^2.
@@ -64,8 +62,8 @@ Class MyWindow Extends Window
 		pbuffer.ConeAngle=30		'angle of particle emission cone.
 		pbuffer.MinVelocity=15.0	'min particle velocity.
 		pbuffer.MaxVelocity=20.0	'max particle velocity.
-		pbuffer.MinSize=32.0		'min particle size.
-		pbuffer.MaxSize=64.0		'max particle size.
+		pbuffer.MinSize=8.0		'min particle size.
+		pbuffer.MaxSize=12.0		'max particle size.
 		
 		For Local an:=0 Until 360 Step 45
 			

+ 3 - 2
modules/mojo3d/tests/pbrspheres.monkey2

@@ -5,7 +5,8 @@ Namespace myapp
 #Import "<mojo>"
 #Import "<mojo3d>"
 
-#Import "assets/"
+#Import "assets/miramar-skybox.jpg"
+#Import "assets/spheres.gltf"
 
 Using std..
 Using mojo..
@@ -54,7 +55,7 @@ Class MyWindow Extends Window
 		
 		'create spheres
 		
-		_spheres=Model.Load( "asset::spheres.gltf/MetalRoughSpheres.gltf" )
+		_spheres=Model.Load( "asset::MetalRoughSpheres.gltf" )
 		
 		_spheres.Move( 0,10,0 )
 		

+ 52 - 52
modules/mojo3d/tests/room.monkey2

@@ -4,7 +4,7 @@ Namespace myapp
 #Import "<mojo>"
 #Import "<mojo3d>"
 
-#Import "assets/"
+#Import "assets/fish.glb"
 
 Using std..
 Using mojo..
@@ -35,78 +35,78 @@ Class MyWindow Extends Window
 
 		Super.New( title,width,height,flags )
 		
-		SetConfig( "MOJO3D_RENDERER","forward" )
-		
-		'Create scene
-		_scene=New Scene
-		_scene.ClearColor=Color.Black
-		_scene.AmbientLight=Color.Black'DarkGrey*.2
-		_scene.EnvColor=Color.DarkGrey
-		_scene.ShadowAlpha=.7
-		
-		'Create camera
-		_camera=New Camera( Self )
-		_camera.Move( 0,0,-5 )
-		
-		New FlyBehaviour( _camera )
-		
-		'Create light
-		_light=New Light
-		_light.Type=LightType.Point
-		_light.CastsShadow=True
-		_light.Range=15
-		
-		Local sphereMaterial:=New PbrMaterial( Color.Black,0,1 )
-		sphereMaterial.EmissiveFactor=_light.Color
-		
-		'Local sphere:=Model.CreateSphere( .1,24,12,sphereMaterial,_light )
-		'sphere.CastsShadow=False
+		CreateScene()
+	End
+	
+	Method CreateRoom()
+
+		Local box:=New Boxf( -10,10 )
 		
-		'_light.Visible=False
+		Local material:=New PbrMaterial( Color.Orange )
 		
-		'Create room
-		Local roomBox:=New Boxf( -10,10 )
-		Local roomMaterial:=New PbrMaterial( Color.Orange )
-'		Local roomMaterial:=PbrMaterial.Load( "asset::blocksrough.pbr" )
-		_room=Model.CreateBox( roomBox,1,1,1,roomMaterial )
-		_room.Mesh.FlipTriangles()
-		_room.Mesh.UpdateNormals()
-		_room.Mesh.UpdateTangents()
-		_room.CastsShadow=False
+		Local model:=Model.CreateBox( box,1,1,1,material )
+		model.Mesh.FlipTriangles()
+		model.Mesh.UpdateNormals()
+		model.Mesh.UpdateTangents()
+		model.CastsShadow=False
+	
+	End
+	
+	Method CreateFishes()
 		
-		Local fish:=Model.Load( "asset::fish.glb" )
-'		Local fish:=Model.Load( "asset::barramundi.gltf/BarramundiFish.gltf" )
-		fish.Mesh.FitVertices( New Boxf( -1,1 ) )
+		Local model:=Model.Load( "asset::fish.glb" )
+		model.Mesh.FitVertices( New Boxf( -1,1 ) )
 		
-		_fish=New Entity
-		_fish.Visible=True
+		Local root:=New Entity
+		root.AddComponent<RotateBehaviour>().Speed=New Vec3f( 0,.1,0 )
+		root.Visible=True
 		
-		For Local an:=0 Until 360 Step 15
+		For Local an:=0 Until 360 Step 9
 			
-			local copy:=fish.Copy( _fish )
+			Local copy:=model.Copy( root )
 			
 			copy.Rotate( 0,an,0 )
-			copy.Move( 0,Sin( an )*3,Rnd( 2.5,7.5 ) )
-			
+			copy.Move( 0,Sin( an )*3,Rnd( 2.5,9.5 ) )
 			copy.Rotate( 0,-90,0 )
 			
 		Next
 		
-		fish.Destroy()
+		model.Destroy()
+	End
+	
+	Method CreateScene()
+		
+		'Create scene
+		_scene=New Scene
+		_scene.ClearColor=Color.Black
+		_scene.AmbientLight=Color.Black
+		_scene.EnvColor=Color.Black
+		_scene.ShadowAlpha=.7
 		
+		'Create camera
+		Local camera:=New Camera( Self )
+		camera.Move( 0,0,-5 )
+		camera.AddComponent<FlyBehaviour>()
+		
+		'Create light
+		Local light:=New Light
+		light.Type=LightType.Point
+		light.CastsShadow=True
+		light.Range=15
+		
+		CreateRoom()
+		
+		CreateFishes()
 	End
+		
 	
 	Method OnRender( canvas:Canvas ) Override
 	
 		RequestRender()
 		
-		_fish.Rotate( 0,.1,0 )
-		
 		_scene.Update()
 		
-		_camera.Render( canvas )
-		
-		canvas.DrawText(	"POS="+_camera.Position,0,0 )
+		_scene.Render( canvas )
 		
 		canvas.DrawText( "FPS "+App.FPS,Width,0,1,0 )
 	End

+ 0 - 181
modules/mojo3d/tests/shapes-scene.monkey2

@@ -1,181 +0,0 @@
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-'Need this to be able to create an 'editable' scene
-#Reflect mojo3d
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	Field _camera:Camera
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		Local scene:=New Scene( True )	'True to create an 'editable' scene.
-		
-		'create camera
-		'
-		Local camera:=New Camera( Self )
-		camera.Name="Camera"	'so we can find camera later after loading
-		camera.Near=.1
-		camera.Far=60
-		camera.Move( 0,10,-10 )
-		New FlyBehaviour( camera )
-		
-		Local camCollider:=New SphereCollider( camera )
-		camCollider.Radius=1
-		Local camBody:=New RigidBody( camera )
-		camBody.Kinematic=True
-		camBody.Mass=0
-		camBody.CollisionGroup=32
-		camBody.CollisionMask=127
-		
-		'create light
-		'
-		Local light:=New Light
-		light.RotateX( 75,15 )
-		light.CastsShadow=true
-		
-		'create ground
-		'
-		Local groundBox:=New Boxf( -60,-1,-60,60,0,60 )
-		
-		Local ground:=Model.CreateBox( groundBox,16,16,16,New PbrMaterial( Color.Green ) )
-		
-		ground.Collided+=Lambda( body:RigidBody )
-		
-'			Print "Ground hit: "+body.Entity.Name
-		End
-
-		'3 ways to create a ground collider!
-		Local groundCollider:=New BoxCollider( ground )
-		groundCollider.Box=groundBox
-		
-'		Local groundCollider:=New ConvexHullCollider( _ground )
-'		groundCollider.Mesh=_ground.Mesh
-
-'		Local groundCollider:=New MeshCollider( _ground )
-'		groundCollider.Mesh=_ground.Mesh
-		
-		Local groundBody:=New RigidBody( ground )
-		groundBody.CollisionGroup=64
-		groundBody.CollisionMask=127
-		groundBody.Mass=0	'static body
-		
-		Local material:=New PbrMaterial( Color.White )
-
-		Local box0:=New Boxf( -1,-5,-1,1,5,1 )		
-		Local model0:=Model.CreateBox( box0,1,1,1,material )
-		model0.Name="Box"
-		Local collider0:=New BoxCollider( model0 )
-		collider0.Box=box0
-		Local body0:=New RigidBody( model0 )
-		body0.CollisionGroup=1
-		body0.CollisionMask=127
-		
-		Local model1:=Model.CreateSphere( 1,32,16,material )
-		model1.Name="Sphere"
-		Local collider1:=New SphereCollider( model1 )
-		Local body1:=New RigidBody( model1 )
-		body1.CollisionGroup=2
-		body1.CollisionMask=127
-
-		Local model2:=Model.CreateCylinder( 1,8,Axis.Y,32,material )
-		model2.Name="Cylinder"
-		Local collider2:=New CylinderCollider( model2 )
-		collider2.Radius=1
-		collider2.Length=8
-		Local body2:=New RigidBody( model2 )
-		body2.CollisionGroup=4
-		body2.CollisionMask=127
-
-		Local model3:=Model.CreateCapsule( 1,10,Axis.Y,32,material )
-		model3.Name="Capsule"
-		Local collider3:=New CapsuleCollider( model3 )
-		collider3.Radius=1
-		collider3.Length=10
-		Local body3:=New RigidBody( model3 )
-		body3.CollisionGroup=8
-		body3.CollisionMask=127
-		
-		Local model4:=Model.CreateCone( 2.5,5,Axis.Y,32,material )
-		model4.Name="Cone"
-		Local collider4:=New ConeCollider( model4 )
-		collider4.Radius=2.5
-		collider4.Length=5
-		Local body4:=New RigidBody( model4 )
-		body4.CollisionGroup=16
-		body4.CollisionMask=127
-		
-		Local models:=New Model[]( model0,model1,model2,model3,model4 )
-		
-		For Local x:=-40 To 40 Step 8
-			
-			For Local z:=-40 To 40 Step 8
-				
-				Local i:=Int( Rnd( models.Length ) )
-				
-				Local materials:=New Material[]( New PbrMaterial( New Color( Rnd(),Rnd(),Rnd() ) ) )
-
-				Local model:=models[i].Copy()
-				
-				model.Materials=materials
-				
-				model.Move( x,50,z )
-			Next
-		
-		Next
-		
-		local x:=0
-		For Local model:=Eachin models
-			
-			x+=5
-			
-			model.Materials=New Material[]( New PbrMaterial( New Color( Rnd(),Rnd(),Rnd() ) ) )
-			
-			model.Move( x,50,0 )
-			
-'			model.Destroy()
-		Next
-		
-		Print "Saving scene..."
-		
-		scene.Save( "shapes-scene.mojo3d" )
-		
-		Print "Loading scene..."
-		
-		_scene=Scene.Load( "shapes-scene.mojo3d" )
-		_camera=Cast<Camera>( _scene.FindEntity( "Camera" ) )
-		_camera.View=Self
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-		
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 110
modules/mojo3d/tests/sprites-scene.monkey2

@@ -1,110 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Reflect mojo3d
-
-#Import "assets/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Function Main()
-	
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _ground:Model
-	
-	Field _sprites:=New Stack<Sprite>
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		_scene=New Scene( True )
-		
-		_scene.SkyTexture=_scene.LoadTexture( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )
-		_scene.FogColor=Color.Sky
-		_scene.FogNear=10
-		_scene.FogFar=30
-		
-		'create camera
-		'
-		_camera=New Camera( Self )
-		_camera.Near=.1
-		_camera.Far=100
-		_camera.Move( 0,10,-10 )
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.Rotate( 60,45,0 )
-		
-		'create ground
-		'
-		_ground=Model.CreateBox( New Boxf( -50,-1,-50,50,0,50 ),1,1,1,New PbrMaterial( Color.Green ) )
-		
-		'create sprites
-		'
-		Local material:=SpriteMaterial.Load( "asset::Acadia-Tree-Sprite.png" )
-		
-		material.AlphaDiscard=1.0/255.0
-		
-		For Local i:=0 Until 1000
-			
-			Local sprite:=New Sprite( material )
-			
-			sprite.Move( Rnd(-50,50),0,Rnd(-50,50) )
-
-			sprite.Scale=New Vec3f( Rnd(4,5),Rnd(5,6),1 )
-			
-			sprite.Handle=New Vec2f( .5,0 )
-			
-			sprite.Mode=SpriteMode.Upright
-
-			_sprites.Push( sprite )
-		Next
-		
-		For Local i:=0 Until 100
-			
-			Local box:=Model.CreateBox( New Boxf( -5,0,-5,5,Rnd(2,10),5 ),1,1,1,New PbrMaterial( New Color( Rnd(),Rnd(),Rnd() ) ) )
-			
-			box.Move( Rnd(-50,50),0,Rnd(-50,50) )
-		next	
-		
-		_scene.Save( "sprites-scene.mojo3d","modules/mojo3d/tests/assets/" )
-		
-		_scene=Scene.Load( "sprites-scene.mojo3d" )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
-	End
-	
-End
-

+ 9 - 7
modules/mojo3d/tests/sprites.monkey2

@@ -5,7 +5,8 @@ Namespace myapp
 #Import "<mojo>"
 #Import "<mojo3d>"
 
-#Import "assets/"
+#Import "assets/miramar-skybox.jpg"
+#Import "assets/Acadia-Tree-Sprite.png"
 
 Using std..
 Using mojo..
@@ -62,16 +63,15 @@ Class MyWindow Extends Window
 		'create sprites
 		'
 		Local material:=SpriteMaterial.Load( "asset::Acadia-Tree-Sprite.png" )
-		
-		material.AlphaDiscard=1.0/255.0
-		
+'		material.AlphaDiscard=1.0/255.0
+
 		For Local i:=0 Until 1000
 			
 			Local sprite:=New Sprite( material )
 			
 			sprite.Move( Rnd(-50,50),0,Rnd(-50,50) )
-
-			sprite.Scale=New Vec3f( Rnd(4,5),Rnd(5,6),1 )
+			
+			sprite.Scale=New Vec3f( Rnd( 1,2 ),Rnd( 2,3 ),1 )
 			
 			sprite.Handle=New Vec2f( .5,0 )
 			
@@ -82,7 +82,9 @@ Class MyWindow Extends Window
 		
 		For Local i:=0 Until 100
 			
-			Local box:=Model.CreateBox( New Boxf( -5,0,-5,5,Rnd(2,10),5 ),1,1,1,New PbrMaterial( New Color( Rnd(),Rnd(),Rnd() ) ) )
+			Local sx:=Rnd( 1,2 )
+
+			Local box:=Model.CreateBox( New Boxf( -sx,0,-sx,sx,Rnd( 2,10 ),sx ),1,1,1,New PbrMaterial( New Color( Rnd(),Rnd(),Rnd() ) ) )
 			
 			box.Move( Rnd(-50,50),0,Rnd(-50,50) )
 		next	

+ 118 - 0
modules/mojo3d/tests/terrain.monkey2

@@ -0,0 +1,118 @@
+
+Namespace myapp
+
+#Import "<std>"
+#Import "<mojo>"
+#Import "<mojo3d>"
+
+#Import "assets/miramar-skybox.jpg"
+#Import "assets/terrain_256.png"
+#Import "assets/mossy.pbr/@/mossy.pbr"
+
+Using std..
+Using mojo..
+Using mojo3d..
+
+Class MyWindow Extends Window
+	
+	Field _scene:Scene
+	
+	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
+
+		Super.New( title,width,height,flags )
+		
+		CreateScene()
+	End
+	
+	Method CreateTerrain:Model()
+		
+		Local box:=New Boxf( -256,0,-256,256,32,256 )
+		
+		Local hmap:=Pixmap.Load( "asset::terrain_256.png",PixelFormat.I8 )
+
+		Local material:=PbrMaterial.Load( "asset::mossy.pbr" )
+		material.ScaleTextureMatrix( 64,64 )
+		
+		'model+mesh
+		Local terrain:=Model.CreateTerrain( hmap,box,material )
+		terrain.CastsShadow=False
+		
+		Local collider:=New TerrainCollider( terrain )
+		collider.Heightmap=hmap
+		collider.Bounds=box
+		
+		Local body:=New RigidBody( terrain )
+		body.Mass=0
+		
+		Return terrain
+	End
+	
+	Method CreateBodies()
+		
+		Local material:=New PbrMaterial( Color.Brown,1,.5 )
+		
+		Local box:=New Boxf( -.5,.5 )
+		
+		Local model:=Model.CreateBox( box,1,1,1,material )
+		
+		Local collider:=model.AddComponent<BoxCollider>()
+		collider.Box=box
+		
+		Local body:=model.AddComponent<RigidBody>()
+			
+		For Local i:=0 Until 360 Step 6
+			
+			Local copy:=model.Copy()
+			
+			copy.Rotate( 0,i,0 )
+			
+			copy.Move( 0,40+i*.1,Rnd( 5,10 ) )
+		Next			
+		
+		model.Destroy()
+	End
+
+	Method CreateScene()
+
+		_scene=New Scene
+		_scene.SkyTexture=Texture.Load( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )
+		_scene.FogColor=New Color( .75,1,0 )*.25
+		_scene.FogNear=75
+		_scene.FogFar=100
+		
+		Local camera:=New Camera( Self )
+		camera.Near=.1
+		camera.Far=100
+		camera.Move( 0,40,0 )
+		New FlyBehaviour( camera )
+		
+		Local light:=New Light
+		light.CastsShadow=True
+		light.RotateX( 45 )
+		
+		CreateTerrain()
+		
+		CreateBodies()
+	End
+	
+	Method OnRender( canvas:Canvas ) Override
+
+		RequestRender()
+		
+		_scene.Update()
+		
+		_scene.Render( canvas )
+
+		canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )
+	End
+	
+End
+
+Function Main()
+	
+	New AppInstance
+	
+	New MyWindow
+	
+	App.Run()
+End

+ 0 - 118
modules/mojo3d/tests/terrainmesh.monkey2

@@ -1,118 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/miramar-skybox.jpg"
-
-#Import "assets/terrain_256.png"
-#Import "assets/mossy-ground1.pbr@/mossy-ground1.pbr"
-
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _terrain:Model
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		'create scene
-		'		
-		_scene=New Scene
-		_scene.SkyTexture=Texture.Load( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )
-		_scene.FogColor=Color.White *.7
-		_scene.FogNear=75
-		_scene.FogFar=100
-		
-		'create camera
-		'
-		_camera=New Camera
-		_camera.Near=.1
-		_camera.Far=100
-		_camera.Move( 0,16,0 )
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.RotateX( 45 )
-
-		'create terrain
-		'
-		'box
-		Local terrainBox:=New Boxf( -256,0,-256,256,32,256 )
-		
-		'heightmap
-		Local terrainHMap:=Pixmap.Load( "asset::terrain_256.png",PixelFormat.I8 )
-
-		'material		
-		Local terrainMaterial:=PbrMaterial.Load( "asset::mossy-ground1.pbr" )
-		terrainMaterial.ScaleTextureMatrix( 64,64 )
-		
-		'model+mesh
-		_terrain=Model.CreateTerrain( terrainHMap,terrainBox,terrainMaterial )
-		_terrain.CastsShadow=False
-		
-		Local collider:=New TerrainCollider( _terrain )
-		collider.Heightmap=terrainHMap'.Convert( PixelFormat.I8 )
-		collider.Bounds=terrainBox
-		Local body:=New RigidBody( _terrain )
-		body.Mass=0
-		
-		Local material:=New PbrMaterial( Color.Sky,1,.5 )
-		
-		For Local i:=0 Until 360 Step 3
-			
-			Local box:=New Boxf( -.5,.5 )
-		
-			Local model:=Model.CreateBox( box,1,1,1,material )
-			Local collider:=New BoxCollider( model )
-			Local body:=New RigidBody( model )
-
-			collider.Box=box
-			
-			model.Rotate( 0,i,0 )
-			model.Move( 0,32,Rnd( 5,10 ) )
-			
-		Next			
-		
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-
-		RequestRender()
-		
-		_camera.Viewport=Rect
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-
-		canvas.Scale( Width/640.0,Height/480.0 )
-		
-		canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )
-	End
-	
-End
-
-Function Main()
-	
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 84
modules/mojo3d/tests/test-scene.monkey2

@@ -1,84 +0,0 @@
-Namespace myapp3d
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Reflect mojo3d
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	Field _camera:Camera
-	Field _light:Light
-	Field _ground:Model
-	Field _donut:Model
-	
-	Method New( title:String="Simple mojo3d app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-		
-		Super.New( title,width,height,flags )
-	End
-	
-	Method OnCreateWindow() Override
-		
-		'create editable scene
-		_scene=New Scene( True )
-		
-		_scene.ClearColor = New Color( 0.2, 0.6, 1.0 )
-		_scene.AmbientLight = _scene.ClearColor * 0.25
-		_scene.FogColor = _scene.ClearColor
-		_scene.FogFar = 1.0
-		_scene.FogFar = 200.0
-		
-		'create camera
-		_camera=New Camera( Self )
-		_camera.AddComponent<FlyBehaviour>()
-		_camera.Move( 0,2.5,-5 )
-		
-		'create light
-		_light=New Light
-		_light.CastsShadow=True
-		_light.Rotate( 45, 45, 0 )
-		
-		'create ground
-		Local groundBox:=New Boxf( -100,-1,-100,100,0,100 )
-		Local groundMaterial:=New PbrMaterial( Color.Lime )
-		_ground=Model.CreateBox( groundBox,1,1,1,groundMaterial )
-		_ground.CastsShadow=False
-		
-		'create donut
-		Local donutMaterial:=New PbrMaterial( Color.Red, 0.05, 0.2 )
-		_donut=Model.CreateTorus( 2,.5,48,24,donutMaterial )
-		_donut.Move( 0,2.5,0 )
-		_donut.AddComponent<RotateBehaviour>().Speed=New Vec3f( .1,.2,.3 )
-		
-		_scene.Save( "test-scene.mojo3d","modules/mojo3d/tests/assets/" )
-		
-		_scene=Scene.Load( "test-scene.mojo3d" )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-		
-		RequestRender()
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 89
modules/mojo3d/tests/test.monkey2

@@ -1,89 +0,0 @@
-Namespace myapp3d
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Reflect mojo3d
-
-#Import "assets/mossy-ground1.pbr/@/mossy-ground1.pbr"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	Field _camera:Camera
-	Field _light:Light
-	Field _ground:Model
-	Field _donut:Model
-	
-	
-	Method New( title:String="Simple mojo3d app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-		
-		Super.New( title,width,height,flags )
-	End
-	
-	Method OnCreateWindow() Override
-		
-		'Xreate editable scene and makes it current
-		_scene=New Scene( True )
-		
-		_scene.ClearColor = New Color( 0.2, 0.6, 1.0 )
-		_scene.AmbientLight = _scene.ClearColor * 0.25
-		_scene.FogColor = _scene.ClearColor
-		_scene.FogFar = 1.0
-		_scene.FogFar = 200.0
-		
-		'create camera
-		_camera=New Camera( Self )
-		_camera.AddComponent<FlyBehaviour>()
-		_camera.Move( 0,2.5,-5 )
-		
-		'create light
-		_light=New Light
-		_light.CastsShadow=True
-		_light.Rotate( 45, 45, 0 )
-		
-		'create ground
-		Local groundBox:=New Boxf( -100,-1,-100,100,0,100 )
-		Local groundMaterial:=New PbrMaterial( Color.Lime )
-		_ground=Model.CreateBox( groundBox,1,1,1,groundMaterial )
-		_ground.CastsShadow=False
-		
-		'create donut
-		Local donutMaterial:=PbrMaterial.Load( "asset::mossy-ground1.pbr" )
-		_donut=Model.CreateTorus( 2,.5,48,24,donutMaterial )
-		_donut.Move( 0,2.5,0 )
-		
-		Print "Saving..."
-		
-		_scene.Save( "test.mojo3d" )
-		
-		Print "Loading..."
-		
-		Scene.Load( "test.mojo3d" )
-		
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-		
-		RequestRender()
-		_donut.Rotate( .2,.4,.6 )
-		_scene.Update()
-		_camera.Render( canvas )
-		canvas.DrawText( "FPS="+App.FPS,0,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 80
modules/mojo3d/tests/walker_gltf2.monkey2

@@ -1,80 +0,0 @@
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojo3d>"
-
-#Import "assets/walker/"
-
-Using std..
-Using mojo..
-Using mojo3d..
-
-Class MyWindow Extends Window
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _model:Model
-	
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
-
-		Super.New( title,width,height,flags )
-		
-		_scene=Scene.GetCurrent()
-		
-		_scene.ClearColor=Color.Sky
-		
-		'create camera
-		'
-		_camera=New Camera
-		_camera.Near=.1
-		_camera.Far=100
-		_camera.Move( 0,10,-5 )
-		
-		New FlyBehaviour( _camera )
-		
-		'create light
-		'
-		_light=New Light
-		_light.RotateX( 90 )
-		
-		'create donut - metallic silver...
-		
-		Local material:=New PbrMaterial( Color.Silver,1,0.5 )
-		
-		_model=Model.LoadBoned( "asset::walk.gltf" )
-		
-		_model.Animator.Animate( 0 )
-		
-		_model.Move( 0,10,0 )
-		
-'		_model.Mesh.FitVertices( New Boxf( -1,1 ),False )
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		RequestRender()
-		
-		_camera.Viewport=Rect
-		
-		_scene.Update()
-		
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 7 - 7
modules/mojo3d/tests/water.monkey2

@@ -1,11 +1,12 @@
-
 Namespace myapp
 
 #Import "<std>"
 #Import "<mojo>"
 #Import "<mojo3d>"
 
-#Import "assets/"
+#Import "assets/miramar-skybox.jpg"
+#Import "assets/water_normal0.png"
+#Import "assets/water_normal1.png"
 
 Using std..
 Using mojo..
@@ -25,7 +26,7 @@ Class MyWindow Extends Window
 
 		Super.New( title,width,height,flags )
 		
-		_scene=Scene.GetCurrent()
+		_scene=New Scene
 		
 		_scene.SkyTexture=Texture.Load( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )
 		
@@ -33,8 +34,7 @@ Class MyWindow Extends Window
 		'
 		_camera=New Camera( self )
 		_camera.Move( 0,10,-10 )
-		
-		New FlyBehaviour( _camera )
+		_camera.AddComponent<FlyBehaviour>()
 		
 		'create light
 		'
@@ -46,8 +46,8 @@ Class MyWindow Extends Window
 		Local waterMaterial:=New WaterMaterial
 		
 		waterMaterial.ScaleTextureMatrix( 10,10 )
+		
 		waterMaterial.ColorFactor=Color.SeaGreen
-		waterMaterial.Roughness=0
 		
 		waterMaterial.NormalTextures=New Texture[]( 
 			Texture.Load( "asset::water_normal0.png",TextureFlags.WrapST|TextureFlags.FilterMipmap ),
@@ -68,7 +68,7 @@ Class MyWindow Extends Window
 		
 		_scene.Update()
 		
-		_camera.Render( canvas )
+		_scene.Render( canvas )
 	End
 	
 End