Pārlūkot izejas kodu

Adding cell shading example

Julien Moreau-Mathis 8 gadi atpakaļ
vecāks
revīzija
9693e24267
2 mainītis faili ar 29 papildinājumiem un 1 dzēšanām
  1. 7 1
      materialsLibrary/index.html
  2. 22 0
      materialsLibrary/test/addCell.js

+ 7 - 1
materialsLibrary/index.html

@@ -49,6 +49,7 @@
 	<script src="test/addsky.js"></script>
 	<script src="test/addsky.js"></script>
 	<script src="test/addgrid.js"></script>
 	<script src="test/addgrid.js"></script>
     <script src="test/addpbr.js"></script>
     <script src="test/addpbr.js"></script>
+	<script src="test/addCell.js"></script>
 	
 	
 	<script>
 	<script>
 	BABYLONDEVTOOLS.Loader.load(function() {
 	BABYLONDEVTOOLS.Loader.load(function() {
@@ -202,13 +203,15 @@
                 var grid = prepareGrid();
                 var grid = prepareGrid();
 
 
 				var shadowOnly = new BABYLON.ShadowOnlyMaterial();
 				var shadowOnly = new BABYLON.ShadowOnlyMaterial();
+
+				var cell = prepareCell();
 				
 				
 				// Default to std
 				// Default to std
 				var currentMaterial = std;
 				var currentMaterial = std;
 				sphere.material = std;				
 				sphere.material = std;				
 				sphere.receiveShadows = true;
 				sphere.receiveShadows = true;
 
 
-				gui.add(options, 'material', ['standard', 'simple', 'water', 'fire', 'lava', 'normal', 'terrain', 'pbr', 'fur', 'triPlanar', 'gradient', 'sky', 'grid', 'shadowOnly']).onFinishChange(function () {
+				gui.add(options, 'material', ['standard', 'simple', 'water', 'fire', 'lava', 'normal', 'terrain', 'pbr', 'fur', 'triPlanar', 'gradient', 'sky', 'grid', 'shadowOnly', 'cell']).onFinishChange(function () {
 					water.enableRenderTargets(false);
 					water.enableRenderTargets(false);
 					skybox.material = skyboxMaterial;
 					skybox.material = skyboxMaterial;
 					currentMesh.isVisible = true;
 					currentMesh.isVisible = true;
@@ -258,6 +261,9 @@
                         case "grid":
                         case "grid":
                             currentMaterial = grid;
                             currentMaterial = grid;
                             break;
                             break;
+						case "cell":
+							currentMaterial = cell;
+							break;
 						default:
 						default:
 							currentMaterial = std;
 							currentMaterial = std;
 							break;
 							break;

+ 22 - 0
materialsLibrary/test/addCell.js

@@ -0,0 +1,22 @@
+window.prepareCell = function() {
+    var cell = new BABYLON.CellMaterial("cell", scene);
+	cell.diffuseTexture = new BABYLON.Texture("../assets/textures//amiga.jpg", scene);
+	cell.diffuseTexture.uScale = cell.diffuseTexture.vScale = 3;
+	cell.computeHighLevel = true;
+
+    registerRangeUI("cell", "Hight Level Cell", false, true, function(value) {
+        cell.computeHighLevel = value;
+    }, function() {
+        return cell.computeHighLevel;
+    });
+
+    registerColorPicker("cell", "Diffuse Color", "#FFFFFF", function(value) {		
+		cell.diffuseColor.r = value.r/255;
+		cell.diffuseColor.g = value.g/255;
+		cell.diffuseColor.b = value.b/255;
+	}, function() {
+		return cell.diffuseColor;
+	});
+
+    return cell;
+};