Skip to content

Material Mixer: three.js Material Generator ​

Build a procedural material for three.js or PlayCanvas by switching on effects and dragging sliders. Start from a preset or press Surprise me, then adjust it. Mixing, downloading and sharing all run in your browser.

What you get ​

Choose three.js code or PlayCanvas code above the code panel. Either way the download is one JavaScript file with a createMaterial function, built from the same effects and settings. Patterns are computed in 3D from the position on the model, which means a mesh needs no UV unwrap to use them. Pattern sizes are tuned for a model about 2 units across. On much larger geometry, lower a layer's Density, or keep the geometry small and scale the mesh. The preview renders with three.js.

three.js ​

createMaterial(THREE) returns a MeshPhysicalMaterial, so lights, environment maps and tone mapping work as they do for any other three.js material, and the surface receives shadows. The shadow it casts follows the original mesh, so holes, Dissolve, Push the surface out and the Motion effects don't change it.

js
import * as THREE from 'three'
import { createMaterial } from './molten-rock.js'

const mesh = new THREE.Mesh(new THREE.SphereGeometry(1, 128, 96), createMaterial(THREE))

// Animated materials need the time in seconds once per frame.
renderer.setAnimationLoop((milliseconds) => {
  mesh.material.userData.tick(milliseconds / 1000)
  renderer.render(scene, camera)
})

You can still assign map, normalMap, roughnessMap and metalnessMap to the material. Layers apply after them, and a pattern at full Color strength hides the color map, so lower it to let the texture show.

The file patches the built-in physical shader through onBeforeCompile, so it does not run under WebGPURenderer.

PlayCanvas ​

createMaterial(pc) returns a StandardMaterial with the effects added through the engine's shader chunks. It is lit like any other StandardMaterial, and the surface receives shadows. Holes and Dissolve also cut the shadow it casts, while the Motion effects and Push the surface out don't change it. Highlights come out a little tighter than in the three.js preview.

js
import * as pc from 'playcanvas'
import { createMaterial } from './molten-rock.js'

const material = createMaterial(pc)
entity.render.meshInstances.forEach((meshInstance) => { meshInstance.material = material })

// Animated materials need the time in seconds once per frame.
app.on('update', () => material.tick(performance.now() / 1000))

You can still assign diffuseMap, normalMap, glossMap and metalnessMap, then call material.update(). For a roughness map, also set material.glossInvert = true. Layers apply after the maps, and a pattern at full Color strength hides the diffuse map.

The file sets GLSL shader chunks, and we ran it on WebGL2 only. WebGPU is untested.

Testing ​

We compiled and rendered the materials with three.js r181 and r183 on WebGLRenderer, and with the PlayCanvas engine 2.23.3 on WebGL2, on one Mac. Test on your target devices before you ship.

Saving and sharing ​

A downloaded file remembers every effect that is switched on, whichever engine it is for. Use Open to load it again and those controls come back. Neither a file nor a link chooses the engine, so pick it again above the code panel. Copy link packs the same settings into the address, so anyone who opens the link sees the material and can keep editing it.

Using it in a game ​

Build a game with it opens Game Creator and starts a new project for the engine you chose, with the material saved in it as a file. Say what the game should be under Use it in a game first, or leave the box empty for a small game built around the material. That step needs a Cinevva account. Building uses your plan's credits, and a free account has a limited number of free iterations per game. Everything else on this page works without an account.

In a three.js or PlayCanvas project you can also ask for a material in chat, for example "make the shield a blue force field". The assistant can build it with the same effects and settings as this page.

Use Shader Creator for full-screen effects such as portals and animated backgrounds, and Particle Creator for particle effects such as flames and smoke. To change the materials of a model you already have, use the 3D Material Editor.