Procedural Textures
Generate textures programmatically:
// Create a wood procedural texture
const woodTexture = new BABYLON.WoodProceduralTexture("woodTex", 512, scene);
woodTexture.ampScale = 100.0;
woodTexture.woodColor = new BABYLON.Color3(0.49, 0.25, 0.08);
material.diffuseTexture = woodTexture;
Create custom procedural textures with shaders:
// Create a custom procedural texture with a fragment shader
const customProceduralTexture = new BABYLON.ProceduralTexture(
"customTex",
512, // Size
"customShader", // Shader name
scene,
null,
true, // Generate mipmaps
true // Is fragment only
);
// Set shader parameters
customProceduralTexture.setFloat("time", 0);
customProceduralTexture.setVector2("resolution", new BABYLON.Vector2(512, 512));
// Update time in the render loop
scene.onBeforeRenderObservable.add(() => {
customProceduralTexture.setFloat("time", performance.now() / 1000);
});