3d-wood-material
3D Wood Material
Mechanism: one small periodic noise field, mip-filtered, is read at several different stretches and scales inside the fragment shader, so ring position, latewood, pores, fibres, rays and tool marks all come from the same wandering grain and feed colour, roughness and relief together, each fading out by its own screen footprint.
Boundary. This skill is the wood surface itself. For whole-scene light, rays and scoring wood renders, use 3d-wood-lighting-scorecard. For image-based PBR sets (downloaded maps, texel budgets, KTX2 delivery) use 3d-high-resolution-textures; reach for it when you need a photographed or scanned species. For silhouette, bevel and LOD geometry use 3d-high-poly-models; this skill only needs a rounded arris (below). Cloth, metal and paper have their own siblings.
Run demo.html first (Kibori bench, four species, four finishes, macro views, and a switch that swaps in the failure). PROMPT.md recreates it.
Recipe
- Patch, do not replace. Build
MeshPhysicalMaterial({color:0xffffff, roughness:max(0.43,r), ior:1.43, specularIntensity:0.72})and edit it inonBeforeCompile:#include <map_fragment>multipliesdiffuseColorby the wood colour,#include <roughnessmap_fragment>setsroughnessFactor=clamp(roughness*W.rough,0.35,1),#include <normal_fragment_maps>replaces the normal with a screen-space bump of the wood heightW.h. Lighting, shadows, IBL and tone-mapping stay stock. The vertex stage only passes object-space positionvOPand the object normal. - Bake one field. A 1024²
RepeatWrapping,LinearMipmapLinear,NoColorSpacerender target of periodic gradient noise (period 64, three octaves:.rbase,.gfbm 0.60/0.27/0.13,.ba shifted copy). Reading it astexture(p/64)costs one tap. All timber shares it; per-board difference is a seed offset, not a texture. - Grain axis.
uAxis0/1/2 picks the log axis;alongis that coordinate andcross2the other two.endgrain = pow(|n·axis|, 6)flips pores from streaks to open cells and dulls the colour on cut faces. - Rings. Drift the pith with two slow fields,
radius=|(cross2+(-drift, offAxis+0.48))*(1,0.56)|,growth=radius*ringFreqplus fbm wobble (±1.25rings),ring=floor(growth),phase=fract. Each ring draws its own width fromannualnoise:lateWidth=0.065+annual*0.21. Latewood is a steepsmoothstep(0.94-w, 0.97-w, phase)cut off by1-smoothstep(0.965,1,phase). SmalloffAxisgives cathedral arcs; largeoffAxisgives straight quarter-sawn lines. - Detail layers, each faded by its own footprint (
fwidthof growth,length(dFdx,dFdy)of the pore, fibre and ray coordinates):