|
@@ -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
|
|
|
+```
|