Material Library
Babylon.js 7 includes pre-built materials for common effects:
// Import the materials library
// In HTML: <script src="https://cdn.babylonjs.com/materialsLibrary/babylonjs.materials.min.js"></script>
// Or in modules: import { GradientMaterial } from 'babylonjs-materials';
// Gradient material
const gradientMaterial = new BABYLON.GradientMaterial("gradient", scene);
gradientMaterial.topColor = BABYLON.Color3.Blue();
gradientMaterial.bottomColor = BABYLON.Color3.White();
gradientMaterial.offset = 0.5;
// Fire material
const fireMaterial = new BABYLON.FireMaterial("fire", scene);
fireMaterial.diffuseTexture = new BABYLON.Texture("textures/fire.png", scene);
fireMaterial.distortionTexture = new BABYLON.Texture("textures/distortion.png", scene);
fireMaterial.speed = 5.0;
// Cell (toon) shading material
const cellMaterial = new BABYLON.CellMaterial("cell", scene);
cellMaterial.diffuseColor = new BABYLON.Color3(0.8, 0.4, 0.4);
cellMaterial.computeHighLevel = true;
cellMaterial.diffuseTexture = new BABYLON.Texture("textures/amiga.jpg", scene);