浏览代码

Merge branch 'master' into startDrag

Trevor Baron 7 年之前
父节点
当前提交
1a8b4ae33a

文件差异内容过多而无法显示
+ 17673 - 17644
Playground/babylon.d.txt


文件差异内容过多而无法显示
+ 14320 - 14291
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/babylon.js


文件差异内容过多而无法显示
+ 73 - 8
dist/preview release/babylon.max.js


文件差异内容过多而无法显示
+ 74 - 8
dist/preview release/babylon.no-module.max.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/babylon.worker.js


文件差异内容过多而无法显示
+ 74 - 9
dist/preview release/es6.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 3 - 1
dist/preview release/what's new.md

@@ -49,7 +49,6 @@
 - All NPM packages have `latest`and `preview` streams [#3055](https://github.com/BabylonJS/Babylon.js/issues/3055) ([RaananW](https://github.com/RaananW))
 - Added New Tools Tab in the inspector (env texture and screenshot tools so far) ([sebavan](http://www.github.com/sebavan))
 - Moved to gulp 4, updated dependencies to latest ([RaananW](https://github.com/RaananW))
-- Added EdgesLineRenderer to address [#4919](https://github.com/BabylonJS/Babylon.js/pull/4919) ([barteq100](https://github.com/barteq100))
 
 ### GUI
 - Added dead key support and before key add observable to InputText. [Doc](https://doc.babylonjs.com/how_to/gui#using-onbeforekeyaddobservable-for-extended-keyboard-layouts-and-input-masks)([theom](https://github.com/theom))
@@ -105,6 +104,8 @@
 - Added support for main WebGL2 texture formats ([PeapBoy](https://github.com/NicolasBuecher))
 - Added fadeInOutBehavior and tooltipText for holographic buttons ([TrevorDev](https://github.com/TrevorDev))
 - StartDrag method added to pointerDragBehavior to simulate the start of a drag ([TrevorDev](https://github.com/TrevorDev))
+- Added EdgesLineRenderer to address [#4919](https://github.com/BabylonJS/Babylon.js/pull/4919) ([barteq100](https://github.com/barteq100))
+- Added ```ambientTextureImpactOnAnalyticalLights``` in PBRMaterial to allow fine grained control of the AmbientTexture on the analytical diffuse light ([sebavan](http://www.github.com/sebavan))
 
 ### glTF Loader
 
@@ -162,6 +163,7 @@
 - Fix File Loading if hosted from `file:`-Protocol ([ltetzlaff](https://github.com/ltetzlaff))
 - Do not throw error when updating a controller with no left stick ([TrevorDev](https://github.com/TrevorDev))
 - Exiting VR can result in messed up view ([TrevorDev](https://github.com/TrevorDev))
+- Dispose existing gazeTrackers when setting a new one, remove pivot matrix of meshes using boundingBoxGizmo ([TrevorDev](https://github.com/TrevorDev))
 
 ### Core Engine
 

+ 43 - 4
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -405,7 +405,7 @@ module BABYLON {
         }
 
         /**
-         * The mesh used to display where the user is selecting, 
+         * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
          * when set bakeCurrentTransformIntoVertices will be called on the mesh.
          * See http://doc.babylonjs.com/resources/baking_transformations 
          */
@@ -415,6 +415,18 @@ module BABYLON {
 
         public set gazeTrackerMesh(value: Mesh) {
             if (value) {
+                // Dispose of existing meshes
+                if( this._cameraGazer._gazeTracker){
+                    this._cameraGazer._gazeTracker.dispose();
+                }
+                if (this._leftController && this._leftController._gazeTracker) {
+                    this._leftController._gazeTracker.dispose();
+                }
+                if (this._rightController && this._rightController._gazeTracker) {
+                    this._rightController._gazeTracker.dispose();
+                }
+
+                // Set and create gaze trackers on head and controllers
                 this._cameraGazer._gazeTracker = value;
                 this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
                 this._cameraGazer._gazeTracker.isPickable = false;
@@ -431,6 +443,31 @@ module BABYLON {
         }
 
         /**
+         * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
+         */
+        public updateGazeTrackerScale = true;
+
+        /**
+         * The gaze tracking mesh corresponding to the left controller
+         */
+        public get leftControllerGazeTrackerMesh():Nullable<Mesh>{
+            if (this._leftController) {
+                return this._leftController._gazeTracker;
+            }
+            return null;
+        }
+
+        /**
+         * The gaze tracking mesh corresponding to the right controller
+         */
+        public get rightControllerGazeTrackerMesh():Nullable<Mesh>{
+            if (this._rightController) {
+                return this._rightController._gazeTracker;
+            }
+            return null;
+        }
+
+        /**
          * If the ray of the gaze should be displayed.
          */
         public get displayGaze(): boolean {
@@ -1653,9 +1690,11 @@ module BABYLON {
                     if (gazer._isActionableMesh) {
                         multiplier = 3;
                     }
-                    gazer._gazeTracker.scaling.x = hit.distance * multiplier;
-                    gazer._gazeTracker.scaling.y = hit.distance * multiplier;
-                    gazer._gazeTracker.scaling.z = hit.distance * multiplier;
+                    if(this.updateGazeTrackerScale){
+                        gazer._gazeTracker.scaling.x = hit.distance * multiplier;
+                        gazer._gazeTracker.scaling.y = hit.distance * multiplier;
+                        gazer._gazeTracker.scaling.z = hit.distance * multiplier;
+                    }
 
                     var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
                     // To avoid z-fighting

+ 9 - 2
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -236,6 +236,13 @@
         protected _ambientTextureStrength: number = 1.0;
 
         /**
+         * Defines how much the AO map is occluding the analytical lights (point spot...).
+         * 1 means it completely occludes it 
+         * 0 mean it has no impact
+         */
+        protected _ambientTextureImpactOnAnalyticalLights: number = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
+
+        /**
          * Stores the alpha values in a texture.
          */
         protected _opacityTexture: BaseTexture;
@@ -1320,7 +1327,7 @@
         public buildUniformLayout(): void {
             // Order is important !
             this._uniformBuffer.addUniform("vAlbedoInfos", 2);
-            this._uniformBuffer.addUniform("vAmbientInfos", 3);
+            this._uniformBuffer.addUniform("vAmbientInfos", 4);
             this._uniformBuffer.addUniform("vOpacityInfos", 2);
             this._uniformBuffer.addUniform("vEmissiveInfos", 2);
             this._uniformBuffer.addUniform("vLightmapInfos", 2);
@@ -1426,7 +1433,7 @@
                         }
 
                         if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
-                            this._uniformBuffer.updateFloat3("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength);
+                            this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
                             MaterialHelper.BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
                         }
 

+ 15 - 0
src/Materials/PBR/babylon.pbrMaterial.ts

@@ -29,6 +29,12 @@
         public static readonly PBRMATERIAL_ALPHATESTANDBLEND = 3;
 
         /**
+         * Defines the default value of how much AO map is occluding the analytical lights
+         * (point spot...).
+         */
+        public static DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
+
+        /**
          * Intensity of the direct lights e.g. the four lights available in your scene.
          * This impacts both the direct diffuse and specular highlights.
          */
@@ -89,6 +95,15 @@
         public ambientTextureStrength: number = 1.0;
 
         /**
+         * Defines how much the AO map is occluding the analytical lights (point spot...).
+         * 1 means it completely occludes it 
+         * 0 mean it has no impact
+         */
+        @serialize()
+        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        public ambientTextureImpactOnAnalyticalLights: number = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
+
+        /**
          * Stores the alpha values in a texture.
          */
         @serializeAsTexture()

+ 1 - 1
src/Mesh/babylon.mesh.ts

@@ -1816,7 +1816,7 @@
          * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
          * The parameter `clonePhysicsImpostor` (default `true`)  allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any. 
          */
-        public clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor: boolean = true): Mesh {
+        public clone(name: string = "", newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor: boolean = true): Mesh {
             return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
         }
 

+ 1 - 1
src/Shaders/ShadersInclude/pbrFragmentDeclaration.fx

@@ -13,7 +13,7 @@ uniform vec2 vAlbedoInfos;
 #endif
 
 #ifdef AMBIENT
-uniform vec3 vAmbientInfos;
+uniform vec4 vAmbientInfos;
 #endif
 
 #ifdef BUMP

+ 1 - 1
src/Shaders/ShadersInclude/pbrUboDeclaration.fx

@@ -3,7 +3,7 @@ layout(std140, column_major) uniform;
 uniform Material
 {
 	uniform vec2 vAlbedoInfos;
-	uniform vec3 vAmbientInfos;
+	uniform vec4 vAmbientInfos;
 	uniform vec2 vOpacityInfos;
 	uniform vec2 vEmissiveInfos;
 	uniform vec2 vLightmapInfos;

+ 1 - 1
src/Shaders/ShadersInclude/pbrVertexDeclaration.fx

@@ -8,7 +8,7 @@ uniform vec2 vAlbedoInfos;
 
 #ifdef AMBIENT
 uniform mat4 ambientMatrix;
-uniform vec3 vAmbientInfos;
+uniform vec4 vAmbientInfos;
 #endif
 
 #ifdef OPACITY

+ 8 - 1
src/Shaders/pbr.fragment.fx

@@ -788,11 +788,18 @@ void main(void) {
     finalEmissive *=  vEmissiveInfos.y;
 #endif
 
+// ______________________________ Ambient ________________________________________
+#ifdef AMBIENT
+    vec3 ambientOcclusionForDirectDiffuse = mix(vec3(1.), ambientOcclusionColor, vAmbientInfos.w);
+#else
+    vec3 ambientOcclusionForDirectDiffuse = ambientOcclusionColor;
+#endif
+
 // _______________________________________________________________________________
 // _____________________________ Composition _____________________________________
     // Reflection already includes the environment intensity.
     vec4 finalColor = vec4(
-        finalDiffuse			* ambientOcclusionColor * vLightingIntensity.x +
+        finalDiffuse			* ambientOcclusionForDirectDiffuse * vLightingIntensity.x +
 #ifndef UNLIT
     #ifdef REFLECTION
         finalIrradiance			* ambientOcclusionColor * vLightingIntensity.z +