Bladeren bron

Further validation tests

Raanan Weber 7 jaren geleden
bovenliggende
commit
8ef156ea58

+ 240 - 12
Viewer/tests/validation/config.json

@@ -2,10 +2,18 @@
     "root": "",
     "tests": [
         {
+            "title": "Control Default",
+            "createMesh": true,
+            "configuration": {
+                "extends": "default"
+            },
+            "referenceImage": "ControlDefault.png"
+        },
+        {
             "title": "Control",
             "createMesh": true,
             "configuration": {
-                "extends": "extended, shadowDirectionalLight"
+                "extends": "extended"
             },
             "referenceImage": "Control.png"
         },
@@ -14,7 +22,7 @@
             "createMesh": true,
             "createMaterial": true,
             "configuration": {
-                "extends": "extended, shadowDirectionalLight",
+                "extends": "extended",
                 "castShadow": true,
                 "model": {
                     "material": {
@@ -35,13 +43,224 @@
             "referenceImage": "Diffuse.png"
         },
         {
-            "title": "Specular {{glos * 20}} - {{spec * 20}}",
+            "title": "Emissive",
+            "createMesh": true,
+            "createMaterial": true,
+            "configuration": {
+                "extends": "extended",
+                "castShadow": true,
+                "model": {
+                    "material": {
+                        "albedoColor": {
+                            "r": 1,
+                            "g": 0,
+                            "b": 1
+                        },
+                        "reflectivityColor": {
+                            "r": 0.8,
+                            "g": 0.8,
+                            "b": 0.8
+                        },
+                        "microSurface": 0
+                    }
+                }
+            },
+            "referenceImage": "Emissive.png"
+        },
+        {
+            "title": "Transparency",
+            "createMesh": true,
+            "createMaterial": true,
+            "configuration": {
+                "extends": "extended",
+                "castShadow": true,
+                "model": {
+                    "material": {
+                        "albedoColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 1
+                        },
+                        "reflectivityColor": {
+                            "r": 0.5,
+                            "g": 0.5,
+                            "b": 0.5
+                        },
+                        "alpha": 0.5,
+                        "microSurface": 0.5
+                    }
+                }
+            },
+            "referenceImage": "Transparency.png"
+        },
+        {
+            "title": "Camera Contrast 0",
+            "createMesh": true,
+            "createMaterial": true,
+            "configuration": {
+                "extends": "extended",
+                "castShadow": true,
+                "model": {
+                    "material": {
+                        "albedoColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 1
+                        },
+                        "reflectivityColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 0
+                        },
+                        "microSurface": 1
+                    }
+                },
+                "camera": {
+                    "contrast": 0
+                }
+            },
+            "referenceImage": "CameraContrast0.png"
+        },
+        {
+            "title": "Camera Contrast 1",
+            "createMesh": true,
+            "createMaterial": true,
+            "configuration": {
+                "extends": "extended",
+                "castShadow": true,
+                "model": {
+                    "material": {
+                        "albedoColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 1
+                        },
+                        "reflectivityColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 0
+                        },
+                        "microSurface": 1
+                    }
+                },
+                "camera": {
+                    "contrast": 1
+                }
+            },
+            "referenceImage": "CameraContrast1.png"
+        },
+        {
+            "title": "Camera Exposure 0.001",
+            "createMesh": true,
+            "createMaterial": true,
+            "configuration": {
+                "extends": "extended",
+                "castShadow": true,
+                "model": {
+                    "material": {
+                        "albedoColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 1
+                        },
+                        "reflectivityColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 0
+                        },
+                        "microSurface": 1
+                    }
+                },
+                "camera": {
+                    "exposure": 0.001
+                }
+            },
+            "referenceImage": "CameraExposure0.png"
+        },
+        {
+            "title": "Camera Exposure 1",
+            "createMesh": true,
+            "createMaterial": true,
+            "configuration": {
+                "extends": "extended",
+                "castShadow": true,
+                "model": {
+                    "material": {
+                        "albedoColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 1
+                        },
+                        "reflectivityColor": {
+                            "r": 0,
+                            "g": 0,
+                            "b": 0
+                        },
+                        "microSurface": 1
+                    }
+                },
+                "camera": {
+                    "exposure": 1
+                }
+            },
+            "referenceImage": "CameraExposure1.png"
+        },
+        {
+            "title": "Specular With Env {{glos * 50}} - {{spec * 50}}",
             "createMesh": true,
             "createMaterial": true,
             "repeatVariables": "glos,spec",
-            "repeatTimes": "6,6",
+            "repeatTimes": "3,3",
             "configuration": {
-                "extends": "extended, shadowDirectionalLight",
+                "extends": "extended",
+                "castShadow": true,
+                "model": {
+                    "material": {
+                        "albedoColor": {
+                            "r": 1,
+                            "g": 0,
+                            "b": 1
+                        },
+                        "reflectivityColor": {
+                            "r": "{{spec / 2}}",
+                            "g": "{{spec / 2}}",
+                            "b": "{{spec / 2}}"
+                        },
+                        "microSurface": "{{glos / 2}}"
+                    }
+                }
+            },
+            "referenceImage": "SpecularEnv{{glos * 50}}-{{spec * 50}}.png",
+            "enableEnvironment": true
+        },
+        {
+            "title": "Main Color Env {{r * 50}} - {{g * 50}}",
+            "createMesh": true,
+            "createMaterial": true,
+            "repeatVariables": "r,g",
+            "repeatTimes": "3,3",
+            "configuration": {
+                "extends": "extended",
+                "castShadow": true,
+                "scene": {
+                    "mainColor": {
+                        "r": "{{r / 2}}",
+                        "g": "{{g / 2}}",
+                        "b": "1"
+                    }
+                }
+            },
+            "referenceImage": "MainColorEnv{{r * 50}}-{{g * 50}}.png",
+            "enableEnvironment": true
+        },
+        {
+            "title": "Specular {{glos * 25}} - {{spec * 25}}",
+            "createMesh": true,
+            "createMaterial": true,
+            "repeatVariables": "glos,spec",
+            "repeatTimes": "5,5",
+            "configuration": {
+                "extends": "extended",
                 "castShadow": true,
                 "model": {
                     "material": {
@@ -51,28 +270,37 @@
                             "b": 1
                         },
                         "reflectivityColor": {
-                            "r": "{{spec / 5}}",
-                            "g": "{{spec / 5}}",
-                            "b": "{{spec / 5}}"
+                            "r": "{{spec / 4}}",
+                            "g": "{{spec / 4}}",
+                            "b": "{{spec / 4}}"
                         },
-                        "microSurface": "{{glos / 5}}"
+                        "microSurface": "{{glos / 4}}"
                     }
                 }
             },
-            "referenceImage": "Specular{{glos * 20}}-{{spec * 20}}.png"
+            "referenceImage": "Specular{{glos * 25}}-{{spec * 25}}.png"
         },
         {
             "title": "BrainStem",
             "configuration": {
-                "extends": "extended, shadowDirectionalLight"
+                "extends": "extended"
             },
             "model": "/dist/assets/BrainStem/BrainStem.gltf",
             "referenceImage": "BrainStem.png"
         },
         {
+            "title": "BrainStem Environment",
+            "configuration": {
+                "extends": "extended"
+            },
+            "model": "/dist/assets/BrainStem/BrainStem.gltf",
+            "referenceImage": "BrainStemEnv.png",
+            "enableEnvironment": true
+        },
+        {
             "title": "BrainStem transformation",
             "configuration": {
-                "extends": "extended, shadowDirectionalLight",
+                "extends": "extended",
                 "camera": {
                     "disableAutoFocus": true
                 },

+ 1 - 1
Viewer/tests/validation/index.css

@@ -72,7 +72,7 @@ babylon {
     position: absolute !important;
     transform: translateX(-600px);
     width: 600px;
-    height: 400px;
+    height: 400px !important;
 }
 
 .renderImage {

+ 36 - 16
Viewer/tests/validation/validation.js

@@ -90,6 +90,22 @@ function saveRenderImage(data, canvas) {
     return screenshotCanvas.toDataURL();
 }
 
+function downloadDataUrlFromJavascript(filename, dataUrl) {
+
+    // Construct the 'a' element
+    var link = document.createElement("a");
+    link.download = filename;
+    link.target = "_blank";
+
+    // Construct the URI
+    link.href = dataUrl;
+    document.body.appendChild(link);
+    link.click();
+
+    // Cleanup the DOM
+    document.body.removeChild(link);
+}
+
 function evaluate(test, resultCanvas, result, renderImage, index, waitRing, done) {
     seed = 100000;
     var renderData = getRenderData(currentViewer.canvas, currentViewer.engine);
@@ -122,6 +138,7 @@ function evaluate(test, resultCanvas, result, renderImage, index, waitRing, done
 
     var renderB64 = saveRenderImage(renderData, currentViewer.canvas);
     renderImage.src = renderB64;
+    // downloadDataUrlFromJavascript(test.referenceImage, renderB64)
 
     done(testRes, renderB64);
 }
@@ -197,20 +214,25 @@ function runTest(index, done) {
     configuration.camera.behaviors = null;
 
     // make sure we use only local assets
-    configuration.skybox = {
+    /*configuration.skybox = {
         cubeTexture: {
-            url: "/dist/assets/environment/DefaultSkybox_cube_radiance_256.dds"
+            url: "DefaultSkybox_cube_radiance_256.dds"
         }
-    }
+    }*/
 
     //envirnonment directory
     configuration.lab = configuration.lab || {};
-    configuration.lab.environmentAssetsRootURL = "/dist/assets/environment/";
-    configuration.lab.environmentMap = false;
+    configuration.lab.assetsRootURL = "/dist/assets/environment/";
+    if (!test.enableEnvironment) {
+        configuration.lab.environmentMap = false;
+    } else {
+        console.log(configuration.lab.environmentMap)
+    }
 
     //model config
     configuration.model = configuration.model || {};
-    configuration.model.castShadow = !test.createMesh
+    //configuration.model.castShadow = !test.createMesh
+    configuration.model.entryAnimation = false;
 
     // create a new viewer
     currentViewer && currentViewer.dispose();
@@ -222,7 +244,7 @@ function runTest(index, done) {
     currentViewer.onInitDoneObservable.add(() => {
 
         var currentFrame = 0;
-        var waitForFrame = test.waitForFrame || 4;
+        var waitForFrame = test.waitForFrame || 0;
 
         if (test.model) {
             currentViewer.initModel(test.model);
@@ -242,7 +264,6 @@ function runTest(index, done) {
                 }
                 currentFrame++;
             });
-
         })
     });
 }
@@ -253,14 +274,13 @@ function prepareMeshForViewer(viewer, configuration, test) {
     let sphereMesh = BABYLON.Mesh.CreateSphere('sphere-' + test.title, 20, 1.0, viewer.sceneManager.scene);
     if (test.createMaterial) {
         let material = new BABYLON.PBRMaterial("sphereMat", viewer.sceneManager.scene);
-        material.environmentBRDFTexture = null;
-        material.useAlphaFresnel = material.needAlphaBlending();
-        material.backFaceCulling = material.forceDepthWrite;
-        material.twoSidedLighting = true;
-        material.useSpecularOverAlpha = false;
-        material.useRadianceOverAlpha = false;
-        material.usePhysicalLightFalloff = true;
-        material.forceNormalForward = true;
+        /* material.useAlphaFresnel = material.needAlphaBlending();
+         material.backFaceCulling = material.forceDepthWrite;
+         material.twoSidedLighting = true;
+         material.useSpecularOverAlpha = false;
+         material.useRadianceOverAlpha = false;
+         material.usePhysicalLightFalloff = true;
+         material.forceNormalForward = true;*/
         sphereMesh.material = material;
     }
     meshModel.addMesh(sphereMesh, true);

+ 1 - 1
Viewer/webpack.gulp.config.js

@@ -1,5 +1,5 @@
 module.exports = {
-    //context: __dirname,
+    context: __dirname,
     entry: [
         __dirname + '/src/index.ts'
     ]