Browse Source

working example with 2 buffers

Benjamin Guignabert 8 years ago
parent
commit
d04d83ee30

File diff suppressed because it is too large
+ 30 - 29
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 2008 - 1985
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 42 - 40
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 166 - 18
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 2008 - 1985
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 40 - 39
dist/preview release/babylon.noworker.js


File diff suppressed because it is too large
+ 12 - 12
dist/preview release/canvas2D/babylon.canvas2d.min.js


File diff suppressed because it is too large
+ 251 - 251
dist/preview release/inspector/babylon.inspector.bundle.js


File diff suppressed because it is too large
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


+ 2 - 2
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -446,7 +446,7 @@ declare module BABYLON {
         * Defines an override for loading the runtime
         * Return true to stop further extensions from loading the runtime
         */
-        loadRuntimeAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: () => void): boolean;
+        loadRuntimeAsync(scene: Scene, data: string, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: () => void): boolean;
         /**
          * Defines an onverride for creating gltf runtime
          * Return true to stop further extensions from creating the runtime
@@ -477,7 +477,7 @@ declare module BABYLON {
         * Return true to stop further extensions from loading this material
         */
         loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: () => void): boolean;
-        static LoadRuntimeAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: () => void): void;
+        static LoadRuntimeAsync(scene: Scene, data: string, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: () => void): void;
         static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: () => void): void;
         static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: () => void): void;
         static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: () => void): void;

+ 4 - 4
dist/preview release/materialsLibrary/babylon.gradientMaterial.js

@@ -47,10 +47,10 @@ var BABYLON;
             _this.SHADOW2 = false;
             _this.SHADOW3 = false;
             _this.SHADOWS = false;
-            _this.SHADOWVSM0 = false;
-            _this.SHADOWVSM1 = false;
-            _this.SHADOWVSM2 = false;
-            _this.SHADOWVSM3 = false;
+            _this.SHADOWESM0 = false;
+            _this.SHADOWESM1 = false;
+            _this.SHADOWESM2 = false;
+            _this.SHADOWESM3 = false;
             _this.SHADOWPCF0 = false;
             _this.SHADOWPCF1 = false;
             _this.SHADOWPCF2 = false;

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.gradientMaterial.min.js


+ 4 - 4
dist/preview release/materialsLibrary/babylon.lavaMaterial.js

@@ -46,10 +46,10 @@ var BABYLON;
             _this.SHADOW2 = false;
             _this.SHADOW3 = false;
             _this.SHADOWS = false;
-            _this.SHADOWVSM0 = false;
-            _this.SHADOWVSM1 = false;
-            _this.SHADOWVSM2 = false;
-            _this.SHADOWVSM3 = false;
+            _this.SHADOWESM0 = false;
+            _this.SHADOWESM1 = false;
+            _this.SHADOWESM2 = false;
+            _this.SHADOWESM3 = false;
             _this.SHADOWPCF0 = false;
             _this.SHADOWPCF1 = false;
             _this.SHADOWPCF2 = false;

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.lavaMaterial.min.js


+ 4 - 4
dist/preview release/materialsLibrary/babylon.normalMaterial.js

@@ -46,10 +46,10 @@ var BABYLON;
             _this.SHADOW2 = false;
             _this.SHADOW3 = false;
             _this.SHADOWS = false;
-            _this.SHADOWVSM0 = false;
-            _this.SHADOWVSM1 = false;
-            _this.SHADOWVSM2 = false;
-            _this.SHADOWVSM3 = false;
+            _this.SHADOWESM0 = false;
+            _this.SHADOWESM1 = false;
+            _this.SHADOWESM2 = false;
+            _this.SHADOWESM3 = false;
             _this.SHADOWPCF0 = false;
             _this.SHADOWPCF1 = false;
             _this.SHADOWPCF2 = false;

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.normalMaterial.min.js


+ 7 - 1
index.html

@@ -59,7 +59,13 @@
 					// Move the sphere upward 1/2 its height
 					sphere.position.y = 1;
 					sphere.material = new BABYLON.StandardMaterial("test");
-					sphere.material.diffuseColor = new BABYLON.Color3(1, 0, 0);
+					sphere.material.diffuseColor = new BABYLON.Color3(1, 1, 1);
+					var t = 0;
+					scene.registerAfterRender(function() {
+						sphere.material.specularColor = new BABYLON.Color3(0, 0, Math.sin(t/100));
+						sphere.material.diffuseColor = new BABYLON.Color3(Math.abs(Math.sin(t/100)), Math.abs(Math.cos(t/200)), Math.abs(Math.sin(t/50)));
+						t++;
+					})
 
 					// Let's try our built-in 'ground' shape.  Params: name, width, depth, subdivisions, scene
 					var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);

+ 4 - 3
src/Materials/babylon.effect.ts

@@ -612,12 +612,13 @@
 
             // std140 layout forces uniform to be multiple of 16 bytes (4 floats)
             var correctedSize = Math.ceil(size / 4) * 4;
-            index += correctedSize;
 
             if (dynamic) {
-                this._uniformBufferDynamicCache = new Float32Array(index);
+                this._uniformCurrentDynamicPointer += correctedSize;
+                this._uniformBufferDynamicCache = new Float32Array(this._uniformCurrentDynamicPointer);
             } else {
-                this._uniformBufferStaticCache = new Float32Array(index); 
+                this._uniformCurrentStaticPointer += correctedSize;
+                this._uniformBufferStaticCache = new Float32Array(this._uniformCurrentStaticPointer); 
             }
         };
 

+ 0 - 7
src/Materials/babylon.standardMaterial.ts

@@ -895,13 +895,6 @@ module BABYLON {
                 }
                 this._effect.setColor3("vEmissiveColor", this.emissiveColor);
 
-                var cameraPos = [];
-                if (scene._mirroredCameraPosition) {
-                    scene._mirroredCameraPosition.toArray(cameraPos);
-                } else {
-                    scene.activeCamera.position.toArray(cameraPos);
-                }
-
                 this._effect.updateUniformBufferDynamic();
                 this._effect.bindUniformBuffers();
             }

+ 2 - 5
src/Shaders/default.fragment.fx

@@ -34,9 +34,6 @@ uniform Static {
 // Constants
 #define RECIPROCAL_PI2 0.15915494
 
-#ifdef SPECULARTERM
-uniform vec4 vSpecularColor;
-#endif
 uniform vec3 vEmissiveColor;
 
 // Input
@@ -232,8 +229,8 @@ void main(void) {
 
 	// Specular map
 #ifdef SPECULARTERM
-	float glossiness = vSpecularColor.a;
-	vec3 specularColor = vSpecularColor.rgb;
+	float glossiness = uStatic.material.vSpecularColor.a;
+	vec3 specularColor = uStatic.material.vSpecularColor.rgb;
 
 #ifdef SPECULAR
 	vec4 specularMapColor = texture2D(specularSampler, vSpecularUV + uvOffset);