Sébastien Vandenberghe 9 vuotta sitten
vanhempi
commit
cd82cca957

+ 21 - 0
materialsLibrary/materials/pbr/Demo/gulpfile.js

@@ -0,0 +1,21 @@
+var gulp = require("gulp");
+var webserver = require('gulp-webserver');
+
+gulp.task('copyReference', function () {
+    return gulp.src(["..../../../dist/preview release/babylon.max.js", 
+        "../../../dist/babylon.pbrMaterial.js"]).pipe(gulp.dest("refs"));
+});
+
+/**
+ * Web server task to serve a local test page
+ */
+gulp.task('default', ['copyReference'], function() {
+  gulp.src('.')
+    .pipe(webserver({
+      livereload: false,
+      open: 'http://localhost:1339/index.html',
+      port: 1339,
+      fallback: 'index.html'
+    }));
+});
+

+ 42 - 0
materialsLibrary/materials/pbr/Demo/index.html

@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>PBR Demo</title>
+	<script src="refs/babylon.max.js"></script>
+    <script src="refs/babylon.pbrMaterial.js"></script>
+
+	<style>
+		html, body {
+			width: 100%;
+			height: 100%;
+			padding: 0;
+			margin: 0;
+			overflow: hidden;
+		}
+
+		#renderCanvas {
+			width: 100%;
+			height: 100%;
+		}
+
+		#fps {
+			position: absolute;
+			background-color: black;
+			border: 2px solid red;
+			text-align: center;
+			font-size: 16px;
+			color: white;
+			top: 15px;
+			left: 10px;
+			width: 60px;
+			height: 20px;
+		}
+	</style>
+</head>
+<body>
+	<div id="fps">0</div>
+	<canvas id="renderCanvas"></canvas>
+
+	<script src="index.js"></script>
+</body>
+</html>

+ 92 - 0
materialsLibrary/materials/pbr/Demo/index.js

@@ -0,0 +1,92 @@
+(function initDemo() {
+    if (!BABYLON.Engine.isSupported()) {
+        return;
+    }
+
+    var canvas = document.getElementById("renderCanvas");
+    var engine = new BABYLON.Engine(canvas, true);
+    var divFps = document.getElementById("fps");
+
+    // Scene + camera.
+    var scene = new BABYLON.Scene(engine);
+    var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 4, Math.PI / 2.5, 200, BABYLON.Vector3.Zero(), scene);
+    camera.attachControl(canvas, true);
+    camera.minZ = 0.1;
+    
+    // Register a render loop to repeatedly render the scene
+    engine.runRenderLoop(function () {
+        scene.render();
+        divFps.innerHTML = engine.getFps().toFixed() + " fps";
+    });
+
+    // Light
+    // Not necessary but add known spec effect...
+    new BABYLON.PointLight("point", new BABYLON.Vector3(20, 20, 10), scene);
+    
+    // Environment Texture
+    var hdrTexture = new BABYLON.HDRCubeTexture("textures/room.hdr", scene, 512);
+    
+    // Skybox
+    var hdrSkybox = BABYLON.Mesh.CreateBox("hdrSkyBox", 1000.0, scene);
+    var hdrSkyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
+    hdrSkyboxMaterial.backFaceCulling = false;
+    hdrSkyboxMaterial.reflectionTexture = hdrTexture.clone();
+    hdrSkyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
+    hdrSkyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
+    hdrSkyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
+    hdrSkyboxMaterial.disableLighting = true;
+    hdrSkybox.material = hdrSkyboxMaterial;
+    hdrSkybox.infiniteDistance = true;
+
+    // Create meshes
+    var sphereGlass = BABYLON.Mesh.CreateSphere("sphere", 48, 30.0, scene);
+    sphereGlass.translate(new BABYLON.Vector3(1, 0, 0), -50);
+    
+    var sphereMetal = BABYLON.Mesh.CreateSphere("sphere", 48, 30.0, scene);
+    sphereMetal.translate(new BABYLON.Vector3(1, 0, 0), 50);
+
+    var woodPlank = BABYLON.MeshBuilder.CreateBox("plane", { width: 45, height: 1, depth: 90 }, scene);
+
+    // Create materials
+    var glass = new BABYLON.PBRMaterial("glass", scene);
+    glass.reflectionTexture = hdrTexture;
+    glass.refractionTexture = hdrTexture;
+    glass.linkRefractionWithTransparency = true;
+    glass.indexOfRefraction = 0.52;
+    glass.alpha = 0;
+    glass.directIntensity = 0.0;
+    glass.environmentIntensity = 0.5;
+    glass.cameraExposure = 0.5;
+    glass.cameraContrast = 1.7;
+    glass.microSurface = 1;
+    glass.reflectivityColor = new BABYLON.Color3(0.1, 0.1, 0.1);
+    glass.albedoColor = new BABYLON.Color3(0.3, 0.3, 0.3);
+    sphereGlass.material = glass;
+
+    var metal = new BABYLON.PBRMaterial("metal", scene);
+    metal.reflectionTexture = hdrTexture;
+    metal.directIntensity = 0.3;
+    metal.environmentIntensity = 0.7;
+    metal.cameraExposure = 0.6;
+    metal.cameraContrast = 1.6;
+    metal.microSurface = 0.96;
+    metal.reflectivityColor = new BABYLON.Color3(0.9, 0.9, 0.9);
+    metal.albedoColor = new BABYLON.Color3(1, 1, 1);
+    sphereMetal.material = metal;
+    
+    var wood = new BABYLON.PBRMaterial("wood", scene);
+    wood.reflectionTexture = hdrTexture;
+    wood.directIntensity = 1.5;
+    wood.environmentIntensity = 0.5;
+    wood.specularIntensity = 0.3;
+    wood.cameraExposure = 0.9;
+    wood.cameraContrast = 1.6;
+    
+    wood.reflectivityTexture = new BABYLON.Texture("textures/reflectivity.png", scene);
+    wood.useMicroSurfaceFromReflectivityMapAlpha = true;
+    
+    wood.albedoColor = BABYLON.Color3.White();
+    wood.albedoTexture = new BABYLON.Texture("textures/albedo.png", scene);
+    woodPlank.material = wood;
+    
+})();

+ 13 - 0
materialsLibrary/materials/pbr/Demo/package.json

@@ -0,0 +1,13 @@
+{
+  "name": "BabylonJSPBRDemo",
+  "version": "2.4.0",
+  "description": "Quick PBR DEMO",
+  "main": "",
+  "repository": { "url": "https://github.com/BabylonJS/Babylon.js/" },
+  "readme": "https://github.com/BabylonJS/Babylon.js/edit/master/readme.md",
+  "license": "(Apache-2.0)",
+  "devDependencies": {
+    "gulp": "^3.8.11",
+    "gulp-webserver": "^0.9.1"
+  }
+}

+ 19 - 0
materialsLibrary/materials/pbr/Demo/readme.md

@@ -0,0 +1,19 @@
+# PBR DEMO
+
+A Quick Demo of the PBR helping to catch some of its capabilities.
+
+## How to run
+
+Only two steps are needed:
+
+First, install the node dependencies:
+
+```
+npm install
+```
+
+Then you can start your local server:
+
+```
+gulp
+```

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 38437 - 0
materialsLibrary/materials/pbr/Demo/refs/babylon.max.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1784 - 0
materialsLibrary/materials/pbr/Demo/refs/babylon.pbrMaterial.js


BIN
materialsLibrary/materials/pbr/Demo/textures/albedo.png


BIN
materialsLibrary/materials/pbr/Demo/textures/reflectivity.png


BIN
materialsLibrary/materials/pbr/Demo/textures/room.hdr