Bladeren bron

Initial commit + do not merge

David Catuhe 7 jaren geleden
bovenliggende
commit
6a41f5ce7b

+ 6 - 4
.vscode/launch.json

@@ -130,10 +130,12 @@
             "request": "launch",
             "reAttach": true,
             "url": "http://localhost:1338/localDev/index.html",
-            "pathMappings": [{
-                "url": "http://localhost:1338",
-                "path": "${workspaceFolder}"
-            }],
+            "pathMappings": [
+                {
+                    "url": "http://localhost:1338",
+                    "path": "${workspaceFolder}"
+                }
+            ],
             "preLaunchTask": "run"
         },
         {

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

@@ -5,6 +5,7 @@
 - New [AnimationGroup class](http://doc.babylonjs.com/how_to/group) to control simultaneously multiple animations with different targets ([deltakosh](https://github.com/deltakosh))
 
 ## Updates
+- Improved [SceneOptimizer](http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer) to provide better adapatability ([deltakosh](https://github.com/deltakosh))
 - New watcher configuration for VSCode. Now the task only compiles changed files ([sebavan](https://github.com/sebavan))
 - Added new draw modes to engine (points, lines, linesloop, linestrip, trianglestrip, trianglefan) ([benaadams](https://github.com/benaadams))
 - Added GUI Textblock.lineSpacing setter and getter to configure vertical space between lines in pixels or percentage values when working with text wrapping ([carloslanderas](https://github.com/carloslanderas))

+ 21 - 11
src/Lights/Shadows/babylon.shadowGenerator.ts

@@ -345,7 +345,6 @@
         private _cachedDirection: Vector3;
         private _cachedDefines: string;
         private _currentRenderID: number;
-        private _downSamplePostprocess: Nullable<PassPostProcess>;
         private _boxBlurPostprocess: Nullable<PostProcess>;
         private _kernelBlurXPostprocess: Nullable<PostProcess>;
         private _kernelBlurYPostprocess: Nullable<PostProcess>;
@@ -428,10 +427,6 @@
                 if (!this.useBlurExponentialShadowMap && !this.useBlurCloseExponentialShadowMap) {
                     return;
                 }
-
-                if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
-                    this._initializeBlurRTTAndPostProcesses();
-                }
                 let shadowMap = this.getShadowMapForRendering();
 
                 if (shadowMap) {
@@ -727,7 +722,27 @@
                     ["diffuseSampler"], join);
             }
 
-            return this._effect.isReady();
+            if (!this._effect.isReady()) {
+                return false;
+            }
+
+            if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
+                if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
+                    this._initializeBlurRTTAndPostProcesses();
+                }
+            }
+
+            if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
+                return false;
+            }
+            if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
+                return false;
+            }
+            if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
+                return false;
+            }
+
+            return true;
         }
 
         /**
@@ -861,11 +876,6 @@
                 this._shadowMap2 = null;
             }
 
-            if (this._downSamplePostprocess) {
-                this._downSamplePostprocess.dispose();
-                this._downSamplePostprocess = null;
-            }
-
             if (this._boxBlurPostprocess) {
                 this._boxBlurPostprocess.dispose();
                 this._boxBlurPostprocess = null;

+ 1 - 1
src/Lights/babylon.light.ts

@@ -18,7 +18,7 @@
 
         /**
          * material.lightmapTexture as only diffuse lighting from this light
-         * adds pnly specular lighting from this light
+         * adds only specular lighting from this light
          * adds dynamic shadows
          */
         public static get LIGHTMAP_SPECULAR(): number {

+ 4 - 0
src/PostProcess/babylon.postProcess.ts

@@ -334,6 +334,10 @@
             return this.width / this.height;
         }
 
+        public isReady(): boolean {
+            return this._effect && this._effect.isReady();
+        }
+
         public apply(): Nullable<Effect> {
             // Check
             if (!this._effect || !this._effect.isReady())

+ 59 - 17
src/babylon.scene.ts

@@ -1855,7 +1855,11 @@
             this.onPrePointerObservable.clear();
         }
 
-        // Ready
+        /**
+         * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
+         * Delay loaded resources are not taking in account
+         * @return true if all required resources are ready
+         */
         public isReady(): boolean {
             if (this._isDisposed) {
                 return false;
@@ -1864,7 +1868,8 @@
             if (this._pendingData.length > 0) {
                 return false;
             }
-            var index: number;
+            let index: number;
+            let engine = this.getEngine();
 
             // Geometries
             for (index = 0; index < this._geometries.length; index++) {
@@ -1891,10 +1896,47 @@
                     return false;
                 }
 
-                var mat = mesh.material;
+                let hardwareInstancedRendering = false;
+                if (mesh.getClassName() === "Mesh") {
+                    hardwareInstancedRendering = engine.getCaps().instancedArrays && (<Mesh>mesh).instances.length > 0;
+                }
+
+                let mat = mesh.material;
                 if (mat) {
-                    if (!mat.isReady(mesh)) {
-                        return false;
+                    let currentAlphaTestingState = engine.getAlphaTesting();
+
+                    if (mat.storeEffectOnSubMeshes) {
+                        for (var subMesh of mesh.subMeshes) {
+                            let effectiveMaterial = subMesh.getMaterial();
+                            if (effectiveMaterial) {
+                                engine.setAlphaTesting(effectiveMaterial.needAlphaTesting());
+                                if (!effectiveMaterial.isReadyForSubMesh(mesh, subMesh, hardwareInstancedRendering)) {
+                                    engine.setAlphaTesting(currentAlphaTestingState);
+                                    return false;
+                                }
+                            }
+                        }
+                    } else {
+                        engine.setAlphaTesting(mat.needAlphaTesting());
+                        if (!mat.isReady(mesh, hardwareInstancedRendering)) {
+                            engine.setAlphaTesting(currentAlphaTestingState);
+                            return false;
+                        }
+                    }
+
+                    engine.setAlphaTesting(currentAlphaTestingState);
+                }
+
+                // Shadows
+                for (var light of mesh._lightSources) {
+                    let generator = light.getShadowGenerator();
+
+                    if (generator) {
+                        for (var subMesh of mesh.subMeshes) {
+                            if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
+                                return false;
+                            }
+                        }
                     }
                 }
             }
@@ -2343,7 +2385,7 @@
             return index;
         }
 
-        
+
         public removeParticleSystem(toRemove: ParticleSystem): number {
             var index = this.particleSystems.indexOf(toRemove);
             if (index !== -1) {
@@ -2372,14 +2414,14 @@
             }
             return index;
         };
-        public removeLensFlareSystem(toRemove:LensFlareSystem){
+        public removeLensFlareSystem(toRemove: LensFlareSystem) {
             var index = this.lensFlareSystems.indexOf(toRemove);
             if (index !== -1) {
                 this.lensFlareSystems.splice(index, 1);
             }
             return index;
         };
-        public removeActionManager(toRemove:ActionManager){
+        public removeActionManager(toRemove: ActionManager) {
             var index = this._actionManagers.indexOf(toRemove);
             if (index !== -1) {
                 this._actionManagers.splice(index, 1);
@@ -2413,39 +2455,39 @@
             this.onNewCameraAddedObservable.notifyObservers(newCamera);
         }
 
-        public addSkeleton(newSkeleton:Skeleton){
+        public addSkeleton(newSkeleton: Skeleton) {
             this.skeletons.push(newSkeleton)
         }
 
-        public addParticleSystem(newParticleSystem:ParticleSystem){
+        public addParticleSystem(newParticleSystem: ParticleSystem) {
             this.particleSystems.push(newParticleSystem)
         }
 
-        public addAnimation(newAnimation:Animation){
+        public addAnimation(newAnimation: Animation) {
             this.animations.push(newAnimation)
         }
 
-        public addMultiMaterial(newMultiMaterial:MultiMaterial){
+        public addMultiMaterial(newMultiMaterial: MultiMaterial) {
             this.multiMaterials.push(newMultiMaterial)
         }
 
-        public addMaterial(newMaterial:Material){
+        public addMaterial(newMaterial: Material) {
             this.materials.push(newMaterial)
         }
 
-        public addMorphTargetManager(newMorphTargetManager:MorphTargetManager){
+        public addMorphTargetManager(newMorphTargetManager: MorphTargetManager) {
             this.morphTargetManagers.push(newMorphTargetManager)
         }
 
-        public addGeometry(newGeometrie:Geometry){
+        public addGeometry(newGeometrie: Geometry) {
             this._geometries.push(newGeometrie)
         }
 
-        public addLensFlareSystem(newLensFlareSystem:LensFlareSystem){
+        public addLensFlareSystem(newLensFlareSystem: LensFlareSystem) {
             this.lensFlareSystems.push(newLensFlareSystem)
         }
 
-        public addActionManager(newActionManager:ActionManager){
+        public addActionManager(newActionManager: ActionManager) {
             this._actionManagers.push(newActionManager)
         }
 

BIN
tests/validation/ReferenceImages/Flat2009.png


BIN
tests/validation/ReferenceImages/Hillvalley.png


BIN
tests/validation/ReferenceImages/SpaceDeK.png


BIN
tests/validation/ReferenceImages/TheCar.png


BIN
tests/validation/ReferenceImages/advancedShadows.png


BIN
tests/validation/ReferenceImages/mansion.png


BIN
tests/validation/ReferenceImages/pbrrough.png


BIN
tests/validation/ReferenceImages/pointLightShadows.png


BIN
tests/validation/ReferenceImages/softShadows.png


+ 3 - 32
tests/validation/config.json

@@ -15,9 +15,8 @@
     },
     {
       "title": "Espilit",
-      "renderCount": 10,
       "sceneFolder": "/Scenes/Espilit/",
-      "sceneFilename": "Espilit.binary.babylon",
+      "sceneFilename": "espilit.babylon",
       "referenceImage": "Espilit.png"
     },
     {
@@ -64,7 +63,6 @@
     },
     {
       "title": "Flat2009",
-      "renderCount": 20,
       "sceneFolder": "/Scenes/Flat2009/",
       "sceneFilename": "Flat2009.babylon",
       "referenceImage": "Flat2009.png"
@@ -96,7 +94,6 @@
     },
     {
       "title": "Soft Shadows",
-      "renderCount": 5,
       "scriptToRun": "/Demos/SoftShadows/softShadows.js",
       "functionToCall": "CreateSoftShadowsTestScene",
       "referenceImage": "softShadows.png"
@@ -109,7 +106,7 @@
     },
     {
       "title": "Highlights",
-      "renderCount": 10,
+      "": 10,
       "scriptToRun": "/Demos/Highlights/highlights.js",
       "functionToCall": "CreateHighlightsScene",
       "referenceImage": "highlights.png",
@@ -132,7 +129,6 @@
     },
     {
       "title": "LOD",
-      "renderCount": 10,
       "scriptToRun": "/Demos/LOD/lod.js",
       "functionToCall": "CreateLODTestScene",
       "referenceImage": "lod.png"
@@ -147,14 +143,12 @@
     },
     {
       "title": "Self shadowing",
-      "renderCount": 10,
       "scriptToRun": "/Demos/SelfShadowing/shadows.js",
       "functionToCall": "CreateShadowsTestScene",
       "referenceImage": "selfShadowing.png"
     },
     {
       "title": "Advanced shadows",
-      "renderCount": 10,
       "scriptToRun": "/Demos/AdvancedShadows/advancedShadows.js",
       "functionToCall": "CreateAdvancedShadowsTestScene",
       "referenceImage": "advancedShadows.png",
@@ -162,7 +156,6 @@
     },
     {
       "title": "point light shadows",
-      "renderCount": 10,
       "scriptToRun": "/Demos/PointLightShadowMap/pointLightShadows.js",
       "functionToCall": "CreatePointLightShadowScene",
       "referenceImage": "pointLightShadows.png",
@@ -183,55 +176,47 @@
     {
       "title": "Custom render target",
       "scriptToRun": "/Demos/CustomRenderTarget/customRenderTarget.js",
-      "renderCount": 10,
       "functionToCall": "CreateCustomRenderTargetTestScene",
       "referenceImage": "customRTT.png"
     },
     {
       "title": "GLTF Normals",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GLTFNormals/index.js",
       "functionToCall": "createScene",
       "referenceImage": "gltfnormals.png"
     },
     {
       "title": "GLTF Material",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GLTFTests/index.js",
       "functionToCall": "createMaterialScene",
       "referenceImage": "gltfMaterial.png"
     },
     {
       "title": "GLTF Material Alpha",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GLTFTests/index.js",
       "functionToCall": "createMaterialAlphaScene",
       "referenceImage": "gltfMaterialAlpha.png"
     },
     {
       "title": "GLTF Primitive Attribute",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GLTFTests/index.js",
       "functionToCall": "createPrimitiveAttributeScene",
       "referenceImage": "gltfPrimitiveAttribute.png"
     },
     {
       "title": "GLTF Metallic Roughness",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GLTFTests/index.js",
       "functionToCall": "createMaterialMetallicRoughnessScene",
       "referenceImage": "gltfMaterialMetallicRoughness.png"
     },
     {
       "title": "GLTF Specular Glossiness",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GLTFTests/index.js",
       "functionToCall": "createMaterialSpecularGlossinessScene",
       "referenceImage": "gltfMaterialSpecularGlossiness.png"
     },
     {
       "title": "GLTF Texture Sampler",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GLTFTests/index.js",
       "functionToCall": "createTextureSamplerScene",
       "referenceImage": "gltfTextureSampler.png"
@@ -247,19 +232,16 @@
     {
       "title": "Asset Containers",
       "playgroundId": "#P3U079#19",
-      "renderCount": 20,
       "referenceImage": "assetContainer.png"
-    },   
+    },
     {
       "title": "GLTF Mesh Primitive Attribute Test",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GLTFMeshPrimitiveAttributeTest/index.js",
       "functionToCall": "createScene",
       "referenceImage": "gltfMeshPrimAttribTest.png"
     },
     {
       "title": "PBR glossy",
-      "renderCount": 20,
       "replace": "engine.setHardwareScalingLevel, //engine.setHardwareScalingLevel",
       "scriptToRun": "/Demos/PBRGlossy/index.js",
       "functionToCall": "CreatePBRGlossyScene",
@@ -267,14 +249,12 @@
     },
     {
       "title": "PBR rough",
-      "renderCount": 20,
       "scriptToRun": "/Demos/PBRRough/index.js",
       "functionToCall": "CreatePBRRoughScene",
       "referenceImage": "pbrrough.png"
     },
     {
       "title": "Reflection probes",
-      "renderCount": 10,
       "scriptToRun": "/Demos/RefProbe/reflectionProbe.js",
       "functionToCall": "CreateReflectionProbeTestScene ",
       "referenceImage": "refprobe.png"
@@ -296,44 +276,37 @@
     },
     {
       "title": "MultiSample render targets",
-      "renderCount": 10,
       "playgroundId": "#12MKMN#0",
       "referenceImage": "MultiSample render targets.png"
     },
     {
       "title": "Default rendering pipeline",
-      "renderCount": 20,
       "playgroundId": "#5XB8YT#2",
       "referenceImage": "DefaultRenderingPipeline.png"
     },
     {
       "title": "Billboard",
-      "renderCount": 20,
       "playgroundId": "#UJEIL#13",
       "referenceImage": "Billboard.png"
     },
     {
       "title": "setParent",
-      "renderCount": 20,
       "playgroundId": "#JD49CT#2",
       "referenceImage": "setParent.png"
     },
     {
       "title": "GUI",
-      "renderCount": 20,
       "scriptToRun": "/Demos/GUI/gui.js",
       "functionToCall": "createScene",
       "referenceImage": "GUI.png"
     },
     {
       "title": "Up Vector",
-      "renderCount": 20,
       "playgroundId": "#2FNBTG#27",
       "referenceImage": "upVector.png"
     },
     {
       "title": "Procedural textures",
-      "renderCount": 10,
       "scriptToRun": "/Demos/Procedural/proceduralTexture.js",
       "functionToCall": "CreateProceduralTextureTestScene",
       "referenceImage": "procedural.png",
@@ -342,7 +315,6 @@
     },
     {
       "title": "Instances",
-      "renderCount": 10,
       "scriptToRun": "/Demos/Instances/instances.js",
       "functionToCall": "CreateInstancesTestScene",
       "referenceImage": "instances.png",
@@ -351,7 +323,6 @@
     },
     {
       "title": "Instanced Bones",
-      "renderCount": 10,
       "scriptToRun": "/Demos/InstancedBones/bones2.js",
       "functionToCall": "CreateBones2TestScene",
       "referenceImage": "instancedBones.png",