Bläddra i källkod

Addressed some code review feedback

Gary Hsu 8 år sedan
förälder
incheckning
5abc1c6407
1 ändrade filer med 12 tillägg och 4 borttagningar
  1. 12 4
      src/Materials/babylon.pbrMaterial.ts

+ 12 - 4
src/Materials/babylon.pbrMaterial.ts

@@ -293,9 +293,17 @@
         @serializeAsTexture()
         @serializeAsTexture()
         public metallicTexture: BaseTexture;
         public metallicTexture: BaseTexture;
 
 
+        /**
+         * Specifies the metallic scalar of the metallic/roughness workflow.
+         * Can also be used to scale the metalness values of the metallic texture.
+         */
         @serialize()
         @serialize()
         public metallic: number;
         public metallic: number;
 
 
+        /**
+         * Specifies the roughness scalar of the metallic/roughness workflow.
+         * Can also be used to scale the roughness values of the metallic texture.
+         */
         @serialize()
         @serialize()
         public roughness: number;
         public roughness: number;
 
 
@@ -1282,10 +1290,10 @@
                 // Colors
                 // Colors
                 this._myScene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
                 this._myScene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
 
 
-                if (this.metallic !== undefined || this.roughness !== undefined || this.metallicTexture) {
-                    var metallic = this.metallic === undefined ? 1 : this.metallic;
-                    var roughness = this.roughness === undefined ? 1 : this.roughness;
-                    this._effect.setColor4("vReflectivityColor", new Color3(metallic, roughness), 0);
+                if (this._defines.METALLICWORKFLOW) {
+                    PBRMaterial._scaledReflectivity.r = this.metallic === undefined ? 1 : this.metallic;
+                    PBRMaterial._scaledReflectivity.g = this.roughness === undefined ? 1 : this.roughness;
+                    this._effect.setColor4("vReflectivityColor", PBRMaterial._scaledReflectivity, 0);
                 }
                 }
                 else {
                 else {
                     // GAMMA CORRECTION.
                     // GAMMA CORRECTION.