浏览代码

Fixing issues with cache and TouchCamera
Better support for noSpecular mode

David Catuhe 10 年之前
父节点
当前提交
a7bce6e656

+ 3 - 1
Babylon/Audio/babylon.soundtrack.js

@@ -32,7 +32,9 @@ var BABYLON;
                 while (this.soundCollection.length) {
                     this.soundCollection[0].dispose();
                 }
-                this._outputAudioNode.disconnect();
+                if (this._outputAudioNode) {
+                    this._outputAudioNode.disconnect();
+                }
                 this._outputAudioNode = null;
             }
         };

+ 11 - 12
Babylon/Cameras/babylon.touchCamera.js

@@ -96,18 +96,17 @@ var BABYLON;
             this._attachedCanvas = null;
         };
         TouchCamera.prototype._checkInputs = function () {
-            if (!this._offsetX) {
-                return;
-            }
-            this.cameraRotation.y += this._offsetX / this.angularSensibility;
-            if (this._pointerPressed.length > 1) {
-                this.cameraRotation.x += -this._offsetY / this.angularSensibility;
-            }
-            else {
-                var speed = this._computeLocalCameraSpeed();
-                var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
-                BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
-                this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+            if (this._offsetX) {
+                this.cameraRotation.y += this._offsetX / this.angularSensibility;
+                if (this._pointerPressed.length > 1) {
+                    this.cameraRotation.x += -this._offsetY / this.angularSensibility;
+                }
+                else {
+                    var speed = this._computeLocalCameraSpeed();
+                    var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+                    BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
+                    this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+                }
             }
             _super.prototype._checkInputs.call(this);
         };

+ 11 - 11
Babylon/Cameras/babylon.touchCamera.ts

@@ -118,19 +118,19 @@ module BABYLON {
         }
 
         public _checkInputs(): void {
-            if (!this._offsetX) {
-                return;
-            }
-            this.cameraRotation.y += this._offsetX / this.angularSensibility;
+            if (this._offsetX) {
+
+                this.cameraRotation.y += this._offsetX / this.angularSensibility;
 
-            if (this._pointerPressed.length > 1) {
-                this.cameraRotation.x += -this._offsetY / this.angularSensibility;
-            } else {
-                var speed = this._computeLocalCameraSpeed();
-                var direction = new Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+                if (this._pointerPressed.length > 1) {
+                    this.cameraRotation.x += -this._offsetY / this.angularSensibility;
+                } else {
+                    var speed = this._computeLocalCameraSpeed();
+                    var direction = new Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
 
-                Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
-                this.cameraDirection.addInPlace(Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+                    Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
+                    this.cameraDirection.addInPlace(Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+                }
             }
 
             super._checkInputs();

+ 1 - 1
Babylon/Shaders/default.fragment.fx

@@ -131,7 +131,7 @@ uniform vec2 vEmissiveInfos;
 uniform sampler2D emissiveSampler;
 #endif
 
-#if defined(SPECULAR) || defined(SPECULARTERM)
+#if defined(SPECULAR) && defined(SPECULARTERM)
 varying vec2 vSpecularUV;
 uniform vec2 vSpecularInfos;
 uniform sampler2D specularSampler;

+ 2 - 2
Babylon/Shaders/default.vertex.fx

@@ -59,7 +59,7 @@ uniform vec2 vEmissiveInfos;
 uniform mat4 emissiveMatrix;
 #endif
 
-#ifdef SPECULAR
+#if defined(SPECULAR) && defined(SPECULARTERM)
 varying vec2 vSpecularUV;
 uniform vec2 vSpecularInfos;
 uniform mat4 specularMatrix;
@@ -208,7 +208,7 @@ void main(void) {
 	}
 #endif
 
-#ifdef SPECULAR
+#if defined(SPECULAR) && defined(SPECULARTERM)
 	if (vSpecularInfos.x == 0.)
 	{
 		vSpecularUV = vec2(specularMatrix * vec4(uv, 1.0, 0.0));

+ 51 - 7
Babylon/Shaders/legacydefault.fragment.fx

@@ -8,7 +8,9 @@ precision highp float;
 uniform vec3 vEyePosition;
 uniform vec3 vAmbientColor;
 uniform vec4 vDiffuseColor;
+#ifdef SPECULARTERM
 uniform vec4 vSpecularColor;
+#endif
 uniform vec3 vEmissiveColor;
 
 // Input
@@ -23,7 +25,9 @@ varying vec4 vColor;
 #ifdef LIGHT0
 uniform vec4 vLightData0;
 uniform vec4 vLightDiffuse0;
+#ifdef SPECULARTERM
 uniform vec3 vLightSpecular0;
+#endif
 #ifdef SHADOW0
 varying vec4 vPositionFromLight0;
 uniform sampler2D shadowSampler0;
@@ -39,7 +43,9 @@ uniform vec3 vLightGround0;
 #ifdef LIGHT1
 uniform vec4 vLightData1;
 uniform vec4 vLightDiffuse1;
+#ifdef SPECULARTERM
 uniform vec3 vLightSpecular1;
+#endif
 #ifdef SHADOW1
 varying vec4 vPositionFromLight1;
 uniform sampler2D shadowSampler1;
@@ -55,7 +61,9 @@ uniform vec3 vLightGround1;
 #ifdef LIGHT2
 uniform vec4 vLightData2;
 uniform vec4 vLightDiffuse2;
+#ifdef SPECULARTERM
 uniform vec3 vLightSpecular2;
+#endif
 #ifdef SHADOW2
 varying vec4 vPositionFromLight2;
 uniform sampler2D shadowSampler2;
@@ -71,7 +79,9 @@ uniform vec3 vLightGround2;
 #ifdef LIGHT3
 uniform vec4 vLightData3;
 uniform vec4 vLightDiffuse3;
+#ifdef SPECULARTERM
 uniform vec3 vLightSpecular3;
+#endif
 #ifdef SHADOW3
 varying vec4 vPositionFromLight3;
 uniform sampler2D shadowSampler3;
@@ -116,7 +126,7 @@ uniform vec2 vEmissiveInfos;
 uniform sampler2D emissiveSampler;
 #endif
 
-#ifdef SPECULAR
+#if defined(SPECULAR) && defined(SPECULARTERM)
 varying vec2 vSpecularUV;
 uniform vec2 vSpecularInfos;
 uniform sampler2D specularSampler;
@@ -273,13 +283,18 @@ mat3 computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 dif
 	// diffuse
 	float ndl = max(0., dot(vNormal, lightVectorW));
 
+	result[0] = ndl * diffuseColor.rgb;
+
+#ifdef SPECULARTERM
 	// Specular
 	vec3 angleW = normalize(viewDirectionW + lightVectorW);
 	float specComp = max(0., dot(vNormal, angleW));
 	specComp = max(0., pow(specComp, max(1.0, vSpecularColor.a)));
-
-	result[0] = ndl * diffuseColor.rgb;
 	result[1] = specComp * specularColor;
+#else
+	result[1] = vec3(0.);
+#endif
+
 	result[2] = vec3(0.);
 
 	return result;
@@ -301,14 +316,17 @@ mat3 computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4
 
 		// Diffuse
 		float ndl = max(0., dot(vNormal, -lightDirection.xyz));
+		result[0] = ndl * spotAtten * diffuseColor.rgb;
 
+#ifdef SPECULARTERM
 		// Specular
 		vec3 angleW = normalize(viewDirectionW - lightDirection.xyz);
 		float specComp = max(0., dot(vNormal, angleW));
 		specComp = pow(specComp, vSpecularColor.a);
-
-		result[0] = ndl * spotAtten * diffuseColor.rgb;
 		result[1] = specComp * specularColor * spotAtten;
+#else
+		result[1] = vec3(0.);
+#endif
 		result[2] = vec3(0.);
 
 		return result;
@@ -326,14 +344,18 @@ mat3 computeHemisphericLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightDat
 
 	// Diffuse
 	float ndl = dot(vNormal, lightData.xyz) * 0.5 + 0.5;
+	result[0] = mix(groundColor, diffuseColor.rgb, ndl);
 
+#ifdef SPECULARTERM
 	// Specular
 	vec3 angleW = normalize(viewDirectionW + lightData.xyz);
 	float specComp = max(0., dot(vNormal, angleW));
 	specComp = pow(specComp, vSpecularColor.a);
-
-	result[0] = mix(groundColor, diffuseColor.rgb, ndl);
 	result[1] = specComp * specularColor;
+#else
+	result[1] = vec3(0.);
+#endif
+
 	result[2] = vec3(0.);
 
 	return result;
@@ -379,10 +401,15 @@ void main(void) {
 
 	// Lighting
 	vec3 diffuseBase = vec3(0., 0., 0.);
+#ifdef SPECULARTERM
 	vec3 specularBase = vec3(0., 0., 0.);
+#endif
 	float shadow = 1.;
 
 #ifdef LIGHT0
+#ifndef SPECULARTERM
+	vec3 vLightSpecular0 = vec3(0.0);
+#endif
 #ifdef SPOTLIGHT0
 	mat3 info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0, vLightSpecular0);
 #endif
@@ -406,6 +433,9 @@ void main(void) {
 #endif
 
 #ifdef LIGHT1
+#ifndef SPECULARTERM
+	vec3 vLightSpecular1 = vec3(0.0);
+#endif
 #ifdef SPOTLIGHT1
 	info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1, vLightSpecular1);
 #endif
@@ -429,6 +459,9 @@ void main(void) {
 #endif
 
 #ifdef LIGHT2
+#ifndef SPECULARTERM
+	vec3 vLightSpecular2 = vec3(0.0);
+#endif
 #ifdef SPOTLIGHT2
 	info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2, vLightSpecular2);
 #endif
@@ -452,6 +485,9 @@ void main(void) {
 #endif
 
 #ifdef LIGHT3
+#ifndef SPECULARTERM
+	vec3 vLightSpecular3 = vec3(0.0);
+#endif
 #ifdef SPOTLIGHT3
 	info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3, vLightSpecular3);
 #endif
@@ -471,8 +507,10 @@ void main(void) {
 	shadow = 1.;
 #endif
 	diffuseBase += info[0] * shadow;
+#ifdef SPECULARTERM
 	specularBase += info[1] * shadow;
 #endif
+#endif
 
 	// Reflection
 	vec3 reflectionColor = vec3(0., 0., 0.);
@@ -539,10 +577,12 @@ void main(void) {
 #endif
 
 	// Specular map
+#ifdef SPECULARTERM
 	vec3 specularColor = vSpecularColor.rgb;
 #ifdef SPECULAR
 	specularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;
 #endif
+#endif
 
 	// Fresnel
 #ifdef DIFFUSEFRESNEL
@@ -553,7 +593,11 @@ void main(void) {
 
 	// Composition
 	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
+#ifdef SPECULARTERM
 	vec3 finalSpecular = specularBase * specularColor;
+#else
+	vec3 finalSpecular = vec3(0.0);
+#endif
 
 	vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);
 

+ 2 - 2
Babylon/Shaders/legacydefault.vertex.fx

@@ -62,7 +62,7 @@ uniform vec2 vEmissiveInfos;
 uniform mat4 emissiveMatrix;
 #endif
 
-#ifdef SPECULAR
+#if defined(SPECULAR) && defined(SPECULARTERM)
 varying vec2 vSpecularUV;
 uniform vec2 vSpecularInfos;
 uniform mat4 specularMatrix;
@@ -231,7 +231,7 @@ void main(void) {
 	}
 #endif
 
-#ifdef SPECULAR
+#if defined(SPECULAR) && defined(SPECULARTERM)
 	if (vSpecularInfos.x == 0.)
 	{
 		vSpecularUV = vec2(specularMatrix * vec4(uv, 1.0, 0.0));

文件差异内容过多而无法显示
+ 12 - 12
Preview release - Alpha/babylon.2.2.js


文件差异内容过多而无法显示
+ 15 - 14
Preview release - Alpha/babylon.2.2.max.js


文件差异内容过多而无法显示
+ 10 - 10
Preview release - Alpha/babylon.2.2.noworker.js