Explorar o código

More dependencies in scene.isReady

David Catuhe %!s(int64=7) %!d(string=hai) anos
pai
achega
e7f3bf3820

+ 1 - 1
.vscode/launch.json

@@ -142,7 +142,7 @@
             "name": "Launch Build Validation (Chrome)",
             "type": "chrome",
             "request": "launch",
-            "url": "http://localhost:1338/tests/validation/index.html",
+            "url": "http://localhost:1338/tests/validation/index.html?Highlights",
             "webRoot": "${workspaceRoot}/",
             "sourceMaps": true,
             "preLaunchTask": "run",

+ 26 - 2
src/Layer/babylon.highlightlayer.ts

@@ -456,7 +456,7 @@
                     emissiveTexture = (<any>material).emissiveTexture;
                 }
 
-                if (this.isReady(subMesh, hardwareInstancedRendering, emissiveTexture)) {
+                if (this._isReady(subMesh, hardwareInstancedRendering, emissiveTexture)) {
                     engine.enableEffect(this._glowMapGenerationEffect);
                     mesh._bind(subMesh, this._glowMapGenerationEffect, Material.TriangleFillMode);
 
@@ -549,7 +549,31 @@
          * @param emissiveTexture the associated emissive texture used to generate the glow
          * @return true if ready otherwise, false
          */
-        private isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<Texture>): boolean {
+        public isReady(subMesh: SubMesh, useInstances: boolean): boolean {
+            let material = subMesh.getMaterial();
+            let mesh = subMesh.getRenderingMesh();
+
+            if (!material || !mesh || !this._meshes) {
+                return false;
+            }
+
+            let emissiveTexture: Nullable<Texture> = null;
+            let highlightLayerMesh = this._meshes[mesh.uniqueId];
+
+            if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
+                emissiveTexture = (<any>material).emissiveTexture;
+            }
+            return this._isReady(subMesh, useInstances, emissiveTexture);
+        }
+
+        /**
+         * Checks for the readiness of the element composing the layer.
+         * @param subMesh the mesh to check for
+         * @param useInstances specify wether or not to use instances to render the mesh
+         * @param emissiveTexture the associated emissive texture used to generate the glow
+         * @return true if ready otherwise, false
+         */
+        private _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<Texture>): boolean {
             let material = subMesh.getMaterial();
 
             if (!material) {

+ 12 - 3
src/babylon.scene.ts

@@ -1901,7 +1901,7 @@
                     hardwareInstancedRendering = engine.getCaps().instancedArrays && (<Mesh>mesh).instances.length > 0;
                 }
 
-                let mat = mesh.material;
+                let mat = mesh.material || this.defaultMaterial;
                 if (mat) {
                     let currentAlphaTestingState = engine.getAlphaTesting();
 
@@ -1909,7 +1909,7 @@
                         for (var subMesh of mesh.subMeshes) {
                             let effectiveMaterial = subMesh.getMaterial();
                             if (effectiveMaterial) {
-                                engine.setAlphaTesting(effectiveMaterial.needAlphaTesting());
+                                engine.setAlphaTesting(effectiveMaterial.needAlphaTesting() && !effectiveMaterial.needAlphaBlendingForMesh(mesh));
                                 if (!effectiveMaterial.isReadyForSubMesh(mesh, subMesh, hardwareInstancedRendering)) {
                                     engine.setAlphaTesting(currentAlphaTestingState);
                                     return false;
@@ -1917,7 +1917,7 @@
                             }
                         }
                     } else {
-                        engine.setAlphaTesting(mat.needAlphaTesting());
+                        engine.setAlphaTesting(mat.needAlphaTesting() && !mat.needAlphaBlendingForMesh(mesh));
                         if (!mat.isReady(mesh, hardwareInstancedRendering)) {
                             engine.setAlphaTesting(currentAlphaTestingState);
                             return false;
@@ -1939,6 +1939,15 @@
                         }
                     }
                 }
+
+                // Highlight layers
+                for (var layer of this.highlightLayers) {
+                    for (var subMesh of mesh.subMeshes) {
+                        if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
+                            return false;
+                        }
+                    }
+                }
             }
 
             return true;

BIN=BIN
tests/validation/ReferenceImages/normals.png


BIN=BIN
tests/validation/ReferenceImages/selfShadowing.png


+ 0 - 1
tests/validation/config.json

@@ -106,7 +106,6 @@
     },
     {
       "title": "Highlights",
-      "": 10,
       "scriptToRun": "/Demos/Highlights/highlights.js",
       "functionToCall": "CreateHighlightsScene",
       "referenceImage": "highlights.png",