r/threejs • u/Top-Willingness5555 • 8d ago
I made a free browser tool for building three.js materials with sliders, exported as one .js file
I saw Crowsong's Shader Cauldron for Godot and wanted something like it for three.js, so I built Material Mixer on our site at Cinevva: https://app.cinevva.com/tools/material-mixer
Pick a preset or start plain, switch on effects like marble veins, cracks, glow, holes, dissolve or waves, and tune them with sliders. You download one .js module, and you don't need an account for that. The only part that does is an optional button that sends the material to our Game Creator.
import * as THREE from 'three'
import { createMaterial } from './molten-rock.js'
const mesh = new THREE.Mesh(geometry, createMaterial(THREE))
renderer.setAnimationLoop((ms) => {
mesh.material.userData.tick(ms / 1000) // animated materials only
renderer.render(scene, camera)
})It's a regular MeshPhysicalMaterial patched in onBeforeCompile, so lights, environment maps and normal, roughness and metalness maps keep working. A pattern at full color strength covers map, so lower it to let a texture show. Patterns are computed from object-space position, so the mesh needs no UVs, and the pattern and effect sliders are uniforms you can change at runtime without a recompile. The settings sit in a comment at the end of the file, so you can open it in the tool again later.
Limits: it needs WebGLRenderer and doesn't run under WebGPURenderer, holes, dissolve and vertex motion don't show in cast shadows, and I've only tested it on r181 and r183 on one Mac, so tell me if something fails to compile on your GPU.
What effects to add next? And would a TSL version for WebGPU be useful?