|
9 år sedan | |
---|---|---|
.. | ||
dist | 9 år sedan | |
proceduralTextures | 9 år sedan | |
test | 9 år sedan | |
config.json | 9 år sedan | |
gulp-srcToVariable.js | 9 år sedan | |
gulpfile.js | 9 år sedan | |
package.json | 9 år sedan | |
readme.md | 9 år sedan |
## Using a procedural texture from the library
You can find multiple procedural textures 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 texture:
var fire = new BABYLON.FireProceduralTexture2("firePT", 256, scene);
sphere.material.diffuseTexture = fire;
To add a new procedural texture, you have to create your own folder in proceduralTextures folder. Then you need to add a .ts file and one .fragment.fx files:
To build all procedural textures and generate the dist folder, just run:
gulp
To integrate your new procedural texture to the build process, you have to edit the config.sjon file and add an entry in the "proceduralTextures" section of the file:
{
"proceduralTextures": [
{
"file": "proceduralTextures/fire/babylon.fireProceduralTexture.ts",
"shaderFiles": [
"proceduralTextures/fire/fireProceduralTexture.fragment.fx"
],
"output": "babylon.fireProceduralTexture.js"
}
],
"build": {
"distOutputDirectory": "dist/"
}
}
To test your procedural texture, 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 procedural texture and reference it in the UI system:
gui.add(options, 'material', ['none','fire']).onFinishChange(function () {
switch (options.material) {
case "fire":
currentMaterial = fireMaterial;
break;
case "none":
default:
currentMaterial = std;
break;
}
currentMesh.material = currentMaterial;
window.enableMaterial(options.material);
});
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