Browse Source

New StandardMaterial.useSpecularOverAlpha property

David Catuhe 11 năm trước cách đây
mục cha
commit
3dd8919f7e

+ 6 - 0
Babylon/Materials/babylon.standardMaterial.js

@@ -31,6 +31,7 @@ var BABYLON;
             this.specularPower = 64;
             this.emissiveColor = new BABYLON.Color3(0, 0, 0);
             this.useAlphaFromDiffuseTexture = false;
+            this.useSpecularOverAlpha = true;
             this._cachedDefines = null;
             this._renderTargets = new BABYLON.SmartArray(16);
             this._worldViewProjectionMatrix = BABYLON.Matrix.Zero();
@@ -151,6 +152,11 @@ var BABYLON;
             }
 
             // Effect
+            if (this.useSpecularOverAlpha) {
+                defines.push("#define SPECULAROVERALPHA");
+                fallbacks.addFallback(0, "SPECULAROVERALPHA");
+            }
+
             if (scene.clipPlane) {
                 defines.push("#define CLIPPLANE");
             }

+ 6 - 0
Babylon/Materials/babylon.standardMaterial.ts

@@ -24,6 +24,7 @@
         public specularPower = 64;
         public emissiveColor = new BABYLON.Color3(0, 0, 0);
         public useAlphaFromDiffuseTexture = false;
+        public useSpecularOverAlpha = true;
 
         public diffuseFresnelParameters: FresnelParameters;
         public opacityFresnelParameters: FresnelParameters;
@@ -155,6 +156,11 @@
             }
 
             // Effect
+            if (this.useSpecularOverAlpha) {
+                defines.push("#define SPECULAROVERALPHA");
+                fallbacks.addFallback(0, "SPECULAROVERALPHA");
+            }
+
             if (scene.clipPlane) {
                 defines.push("#define CLIPPLANE");
             }

+ 4 - 0
Babylon/Math/babylon.math.js

@@ -1065,6 +1065,10 @@
         };
 
         // Statics
+        Quaternion.Inverse = function (q) {
+            return new Quaternion(-q.x, -q.y, -q.z, q.w);
+        };
+
         Quaternion.RotationAxis = function (axis, angle) {
             var result = new Quaternion();
             var sin = Math.sin(angle / 2);

+ 4 - 4
Babylon/Math/babylon.math.ts

@@ -1033,6 +1033,10 @@
         }
 
         // Statics
+        public static Inverse(q: Quaternion): Quaternion {
+			return new Quaternion(-q.x, -q.y, -q.z, q.w);
+        }
+
         public static RotationAxis(axis: Vector3, angle: number): Quaternion {
             var result = new Quaternion();
             var sin = Math.sin(angle / 2);
@@ -1104,10 +1108,6 @@
 
             return new Quaternion((num3 * left.x) + (num2 * right.x), (num3 * left.y) + (num2 * right.y), (num3 * left.z) + (num2 * right.z), (num3 * left.w) + (num2 * right.w));
         }
-		
-		public static Inverse(q: Quaternion): Quaternion {
-			return new Quaternion(-q.x, -q.y, -q.z, q.w);
-		}		
     }
 
     export class Matrix {

+ 2 - 0
Babylon/Shaders/default.fragment.fx

@@ -696,7 +696,9 @@ void main(void) {
 	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
 	vec3 finalSpecular = specularBase * specularColor;
 
+#ifdef SPECULAROVERALPHA
 	alpha = clamp(alpha + dot(finalSpecular, vec3(0.3, 0.59, 0.11)), 0., 1.);
+#endif
 
 	vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);
 

+ 0 - 6
Babylon/Tools/babylon.database.js

@@ -106,12 +106,6 @@ var BABYLON;
                     request.onupgradeneeded = function (event) {
                         _this.db = (event.target).result;
                         try  {
-                            if (event.oldVersion > 0) {
-                                _this.db.deleteObjectStore("scenes");
-                                _this.db.deleteObjectStore("versions");
-                                _this.db.deleteObjectStore("textures");
-                            }
-
                             var scenesStore = _this.db.createObjectStore("scenes", { keyPath: "sceneUrl" });
                             var versionsStore = _this.db.createObjectStore("versions", { keyPath: "sceneUrl" });
                             var texturesStore = _this.db.createObjectStore("textures", { keyPath: "textureUrl" });

+ 1 - 7
Babylon/Tools/babylon.database.ts

@@ -136,13 +136,7 @@ module BABYLON {
                     // Initialization of the DB. Creating Scenes & Textures stores
                     request.onupgradeneeded = (event: IDBVersionChangeEvent) => {
                         this.db = (<any>(event.target)).result;
-                        try {
-                            if (event.oldVersion > 0) {
-                                this.db.deleteObjectStore("scenes");
-                                this.db.deleteObjectStore("versions");
-                                this.db.deleteObjectStore("textures");
-                            }
-                            
+                        try {                            
                             var scenesStore = this.db.createObjectStore("scenes", { keyPath: "sceneUrl" });
                             var versionsStore = this.db.createObjectStore("versions", { keyPath: "sceneUrl" });
                             var texturesStore = this.db.createObjectStore("textures", { keyPath: "textureUrl" });

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 11 - 7
babylon.1.14-beta-debug.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 4 - 4
babylon.1.14-beta.js


+ 3 - 0
babylon.d.ts

@@ -1582,6 +1582,7 @@ declare module BABYLON {
         public specularPower: number;
         public emissiveColor: Color3;
         public useAlphaFromDiffuseTexture: boolean;
+        public useSpecularOverAlpha: boolean;
         public diffuseFresnelParameters: FresnelParameters;
         public opacityFresnelParameters: FresnelParameters;
         public reflectionFresnelParameters: FresnelParameters;
@@ -1691,6 +1692,7 @@ declare module BABYLON {
         public coordinatesMode: number;
         public onBeforeRender: () => void;
         public onAfterRender: () => void;
+        public activeCamera: Camera;
         public customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
         private _size;
         public _generateMipMaps: boolean;
@@ -1950,6 +1952,7 @@ declare module BABYLON {
         public toEulerAngles(): Vector3;
         public toRotationMatrix(result: Matrix): void;
         public fromRotationMatrix(matrix: Matrix): void;
+        static Inverse(q: Quaternion): Quaternion;
         static RotationAxis(axis: Vector3, angle: number): Quaternion;
         static FromArray(array: number[], offset?: number): Quaternion;
         static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;