Explorar o código

changing the shadows configuration and updating ufo

Raanan Weber %!s(int64=7) %!d(string=hai) anos
pai
achega
3a7144b7ca

+ 64 - 0
Viewer/dist/sphereExample.html

@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html lang="en">
+
+    <head>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+        <meta http-equiv="X-UA-Compatible" content="ie=edge">
+        <title>BabylonJS Viewer - Sphere</title>
+        <style>
+            babylon,
+            #viewport {
+                max-width: 800px;
+                max-height: 500px;
+                width: 100%;
+                height: 600px;
+            }
+        </style>
+    </head>
+
+    <body>
+        <babylon id="babylon-viewer" extends="extendedDefault"></babylon>
+        <div id="viewport" touch-action="none"></div>
+        <script src="viewer.js"></script>
+        <script>
+            BabylonViewer.viewerManager.onViewerAdded = function (viewer) {
+                console.log('Using viewerManager.onViewerAdded: ', 'viewer - ' + viewer.getBaseId());
+
+                viewer.onInitDoneObservable.add(() => {
+                    let meshModel = new BabylonViewer.ViewerModel(viewer, {
+                        "material": {
+                            "albedoColor": {
+                                "r": 1,
+                                "g": 1,
+                                "b": 1
+                            },
+                            "reflectivityColor": {
+                                "r": 1,
+                                "g": 1,
+                                "b": 1
+                            },
+                            "microSurface": 0
+                        }
+                    });
+
+                    let sphereMesh = BABYLON.Mesh.CreateSphere('sphere-', 20, 1.0, viewer.sceneManager.scene);
+                    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;
+                    sphereMesh.material = material;
+                    meshModel.addMesh(sphereMesh, true);
+                })
+
+            }
+
+        </script>
+    </body>
+
+</html>

+ 1 - 1
Viewer/dist/ufoExample.html

@@ -27,7 +27,7 @@
             </model>
             <lights>
                 <light2 shadow-ortho-scale="0.5">
-                    <position x="0" y="6" z="6"></position>
+
                 </light2>
             </lights>
         </babylon>

+ 1 - 0
Viewer/src/configuration/configuration.ts

@@ -352,6 +352,7 @@ export interface ILightConfiguration {
     shadownEnabled?: boolean; // only on specific lights!
     shadowConfig?: {
         useBlurExponentialShadowMap?: boolean;
+        useBlurCloseExponentialShadowMap?: boolean;
         useKernelBlur?: boolean;
         blurKernel?: number;
         blurScale?: number;

+ 9 - 16
Viewer/src/configuration/types/extended.ts

@@ -4,7 +4,7 @@ export let extendedConfiguration: ViewerConfiguration = {
     version: "3.2.0",
     extends: "default",
     camera: {
-        radius: 1.8,
+        radius: 2,
         alpha: -1.5708,
         beta: Math.PI * 0.5 - 0.2618,
         wheelPrecision: 300,
@@ -22,26 +22,24 @@ export let extendedConfiguration: ViewerConfiguration = {
             intensityMode: 0,
             radius: 0.135,
             spotAngle: 59.9967,
-            shadowBufferSize: 512,
-            shadowFieldOfView: 80.977,
-            shadowFrustumSize: 8.0,
-            shadowMinZ: 1.0,
-            shadowMaxZ: 10.0
         },
         "light2": {
             type: 1,
             shadowEnabled: true,
-            target: { x: 0, y: -0.5, z: -1 },
-            position: { x: 1.49, y: 1.39, z: -1.33 },
+            target: { x: 0, y: 0, z: 1 },
+            position: { x: 1.49, y: 2.39, z: -1.33 },
             diffuse: { r: 0.867, g: 0.816, b: 0.788 },
             intensity: 2.887,
             intensityMode: 0,
             shadowBufferSize: 1024,
-            shadowFrustumSize: 3.0,
+            shadowFrustumSize: 4.0,
+            shadowFieldOfView: 80.977,
             shadowMinZ: 0.1,
             shadowMaxZ: 12.0,
+            shadowOrthoScale: 0.5,
             shadowConfig: {
-                blurKernel: 32
+                blurKernel: 32,
+                useBlurExponentialShadowMap: true
             }
         },
         "light3": {
@@ -53,12 +51,7 @@ export let extendedConfiguration: ViewerConfiguration = {
             intensity: 3.052,
             intensityMode: 0,
             radius: 0.5,
-            spotAngle: 42.85,
-            shadowBufferSize: 512,
-            shadowFieldOfView: 80,
-            shadowFrustumSize: 8.0,
-            shadowMinZ: 0.2,
-            shadowMaxZ: 10.0
+            spotAngle: 42.85
         }
     },
     ground: {

+ 7 - 6
Viewer/src/viewer/sceneManager.ts

@@ -685,8 +685,10 @@ export class SceneManager {
 
                 let shadowGenerator = <BABYLON.ShadowGenerator>light.getShadowGenerator();
                 if (isShadowEnabled && lightConfig.shadowEnabled && this._maxShadows) {
+                    let bufferSize = lightConfig.shadowBufferSize || 256;
+
                     if (!shadowGenerator) {
-                        shadowGenerator = new ShadowGenerator(512, light);
+                        shadowGenerator = new ShadowGenerator(bufferSize, light);
                         // TODO blur kernel definition
                     }
 
@@ -699,15 +701,14 @@ export class SceneManager {
                             renderList && renderList.push(focusMeshes[index]);
                         }
                     }
-                    let bufferSize = lightConfig.shadowBufferSize || 256;
                     var blurKernel = this.getBlurKernel(light, bufferSize);
 
-                    shadowGenerator.useBlurCloseExponentialShadowMap = true;
-                    shadowGenerator.useKernelBlur = true;
+                    //shadowGenerator.useBlurCloseExponentialShadowMap = true;
+                    //shadowGenerator.useKernelBlur = true;
                     shadowGenerator.blurScale = 1.0;
-                    shadowGenerator.bias = this._shadowGeneratorBias;
+                    //shadowGenerator.bias = this._shadowGeneratorBias;
                     shadowGenerator.blurKernel = blurKernel;
-                    shadowGenerator.depthScale = 50 * (light.shadowMaxZ - light.shadowMinZ);
+                    //shadowGenerator.depthScale = 50 * (light.shadowMaxZ - light.shadowMinZ);
                     //override defaults
                     extendClassWithConfig(shadowGenerator, lightConfig.shadowConfig || {});
                 } else if (shadowGenerator) {

BIN=BIN
Viewer/tests/validation/ReferenceImages/BrainStem.png


BIN=BIN
Viewer/tests/validation/ReferenceImages/BrainStemAnimation1.png


BIN=BIN
Viewer/tests/validation/ReferenceImages/BrainStemTransformation.png


BIN=BIN
Viewer/tests/validation/ReferenceImages/Control.png


BIN=BIN
Viewer/tests/validation/ReferenceImages/Diffuse.png


+ 0 - 15
Viewer/tests/validation/config.json

@@ -49,21 +49,6 @@
             "referenceImage": "BrainStem.png"
         },
         {
-            "title": "BrainStem Animation",
-            "configuration": {
-                "extends": "extended",
-                "skybox": {
-                    "cubeTexture": {
-                        "url": "/dist/assets/environment/DefaultSkybox_cube_radiance_256.dds",
-                        "gammaSpace": false
-                    }
-                }
-            },
-            "animationTest": true,
-            "model": "/dist/assets/BrainStem/BrainStem.gltf",
-            "referenceImage": "BrainStemAnimation1.png"
-        },
-        {
             "title": "BrainStem transformation",
             "configuration": {
                 "extends": "extended",

+ 0 - 1
Viewer/tests/validation/validation.js

@@ -226,7 +226,6 @@ function runTest(index, done) {
         currentViewer.onModelLoadedObservable.add((model) => {
             currentViewer.onFrameRenderedObservable.add(() => {
                 if (test.animationTest && !currentFrame) {
-                    console.log("animation", model.getAnimationNames()[0]);
                     model.playAnimation(model.getAnimationNames()[0]);
                 }
                 if (currentFrame === waitForFrame) {