Browse Source

Renaming shaders lib to materials lib

David Catuhe 9 years ago
parent
commit
d165b4dc50

+ 1 - 0
.gitignore

@@ -119,3 +119,4 @@ UpgradeLog*.XML
 
 # Do not ignore loaders/obj
 !loaders/*
+node_modules

+ 1 - 1
dist/preview release/what's new.md

@@ -1,6 +1,6 @@
 - 2.3.0:
   - **Major updates**
-    - Introducing [Shaders Library](https://github.com/BabylonJS/Babylon.js/shadersLibrary) ([deltakosh](https://github.com/deltakosh))
+    - Introducing [Materials Library](https://github.com/BabylonJS/Babylon.js/materialsLibrary) ([deltakosh](https://github.com/deltakosh))
     - New cache mecanism for StandardMaterial ([deltakosh](https://github.com/deltakosh))
     - New Solid Particle System ([jerome](https://github.com/jbousquie))
     - New `StandardMaterial.lightmapTexture` which can be controlled with `StandardMaterial.useLightmapAsShadowMap`. [Demo here](#NEEDDEMO) ([deltakosh](https://github.com/deltakosh))

+ 3 - 3
shadersLibrary/config.json

@@ -1,10 +1,10 @@
 {
   "materials": [
     {
-      "file": "shaders/simple/babylon.simpleMaterial.ts",
+      "file": "materials/simple/babylon.simpleMaterial.ts",
       "shaderFiles": [
-        "shaders/simple/simple.vertex.fx",
-        "shaders/simple/simple.fragment.fx"
+        "materials/simple/simple.vertex.fx",
+        "materials/simple/simple.fragment.fx"
       ],
       "output": "babylon.simpleMaterial.js"
     }

+ 1 - 1
shadersLibrary/dist/babylon.simpleMaterial.js

@@ -1,4 +1,4 @@
-/// <reference path="../../../babylon.d.ts"/>
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 
 var BABYLON;
 (function (BABYLON) {

shadersLibrary/gulp-srcToVariable.js → materialsLibrary/gulp-srcToVariable.js


+ 20 - 1
shadersLibrary/gulpfile.js

@@ -7,6 +7,7 @@ var concat = require("gulp-concat");
 var rename = require("gulp-rename");
 var cleants = require('gulp-clean-ts-extends');
 var replace = require("gulp-replace");
+var webserver = require('gulp-webserver');
 
 var config = require("./config.json");
 var extendsSearchRegex = /var\s__extends[\s\S]+?\};/g;
@@ -18,10 +19,14 @@ function shadersName(filename) {
       .replace('.fx', 'Shader');
 }
 
+gulp.task('copyReference', function () {
+    return gulp.src("../dist/preview release/babylon.max.js").pipe(gulp.dest("test"));
+});
+
 /*
 Compiles all typescript files and creating a declaration file.
 */
-gulp.task('default', function () {
+gulp.task('default', ["copyReference"], function () {
     var tasks = config.materials.map(function (material) {
         var js = gulp.src(material.file)
             .pipe(typescript({
@@ -42,3 +47,17 @@ gulp.task('default', function () {
 
     return tasks;
 });
+
+/**
+ * Web server task to serve a local test page
+ */
+gulp.task('webserver', function() {
+  gulp.src('.')
+    .pipe(webserver({
+      livereload: false,
+      open: 'http://localhost:1338/test/index.html',
+      port: 1338,
+      fallback: 'index.html'
+    }));
+});
+

+ 1 - 1
shadersLibrary/shaders/simple/babylon.simpleMaterial.ts

@@ -1,4 +1,4 @@
-/// <reference path="../../../babylon.d.ts"/>
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 
 module BABYLON {
     var maxSimultaneousLights = 4;

shadersLibrary/shaders/simple/simple.fragment.fx → materialsLibrary/materials/simple/simple.fragment.fx


shadersLibrary/shaders/simple/simple.vertex.fx → materialsLibrary/materials/simple/simple.vertex.fx


+ 2 - 1
shadersLibrary/package.json

@@ -17,6 +17,7 @@
     "merge2": "~0.3.5",
     "gulp-rename": "~1.2.2",
     "gulp-clean-ts-extends": "~0.1.1",
-    "gulp-replace": "~0.5.3"
+    "gulp-replace": "~0.5.3",
+    "gulp-webserver": "^0.9.1"
   }
 }

+ 18 - 12
shadersLibrary/readme.md

@@ -1,18 +1,18 @@
-# Shaders library
+# Materials library
 
-## Using a shader from the library
+## Using a material from the library
 
-You can find multiple shaders that just works with Babylon.js in *dist* folder. To use then, you only need to reference the associated .js file and use the new provided material:
+You can find multiple materials that just works with Babylon.js in *dist* folder. To use then, you only need to reference the associated .js file and use the new provided material:
 
 ```
 var simple = new BABYLON.SimpleMaterial("simple", scene);
 sphere.material = simple;
 ```
 
-## Adding a new shader to the library
+## Adding a new material to the library
 
-To add a new shader, you have to create your own folder in *shaders* folder. Then you need to add a .ts file an two .fx files:
-* The .ts is the TypeScript code of your shader
+To add a new material, you have to create your own folder in *materials* folder. Then you need to add a .ts file an two .fx files:
+* The .ts is the TypeScript code of your material
 * .fx files: GLSL code for vertex and fragment shaders
 
 The best way to start a new material is to copy/past the *simple* material. This material provides all the features required by a Babylon.js material:
@@ -27,9 +27,9 @@ The best way to start a new material is to copy/past the *simple* material. This
 
 But you can also start from scratch as you are not forced to support all these features.
 
-## Integrating the shader in the build process
+## Integrating the material in the build process
 
-To build all shaders and generate the *dist* folder, just run:
+To build all materials and generate the *dist* folder, just run:
 
 ```
 gulp
@@ -55,13 +55,13 @@ To integrate your new material to the build process, you have to edit the config
 }
 ```
 
-## Testing your shader
+## Testing your material
 
-To test your shader, you can use the /test/index.html file by adding a reference to your .js file. Then you will need to update the code to create an instance of your material and reference it in the UI system:
+To test your material, you can use the /test/index.html file by adding a reference to your .js file. Then you will need to update the code to create an instance of your material and reference it in the UI system:
 
 ```
-gui.add(options, 'shader', ['standard', 'simple']).onFinishChange(function () {
-					switch (options.shader) {
+gui.add(options, 'material', ['standard', 'simple']).onFinishChange(function () {
+					switch (options.material) {
 						case "simple":
 							currentMaterial = simple;
 							break;
@@ -75,3 +75,9 @@ gui.add(options, 'shader', ['standard', 'simple']).onFinishChange(function () {
 ```
 
 This page allows you to test your code with animated meshes, shadows, various kinds of lights and fog. Just use the UI on the right to turn features on and off.
+
+To serve this page, you can start:
+
+```
+gulp webserver
+```

File diff suppressed because it is too large
+ 36285 - 0
materialsLibrary/test/babylon.max.js


shadersLibrary/test/dat.gui.min.js → materialsLibrary/test/dat.gui.min.js


+ 4 - 4
shadersLibrary/test/index.html

@@ -3,7 +3,7 @@
 <head>
 	<title>Shaders Library</title>
 	<script src="dat.gui.min.js"></script>
-	<script src="../../babylon.max.js"></script>
+	<script src="babylon.max.js"></script>
 	<script src="../dist/babylon.simpleMaterial.js"></script>
 
 	<style>
@@ -125,7 +125,7 @@
 				//UI
 				var gui = new dat.GUI();
 				var options = {
-					shader: "standard",
+					material: "standard",
 					mesh: "sphere",
 					hemisphericLight: true,
 					pointLight: false,
@@ -135,8 +135,8 @@
 					fog: false
 				}
 
-				gui.add(options, 'shader', ['standard', 'simple']).onFinishChange(function () {
-					switch (options.shader) {
+				gui.add(options, 'material', ['standard', 'simple']).onFinishChange(function () {
+					switch (options.material) {
 						case "simple":
 							currentMaterial = simple;
 							break;

shadersLibrary/test/meshes/Rabbit.babylon → materialsLibrary/test/meshes/Rabbit.babylon


shadersLibrary/test/textures/amiga.jpg → materialsLibrary/test/textures/amiga.jpg