This mostly came out of building Objekt 62
It has a ~40 km procedural dune world rendered through Three.js/TSL, while gameplay needs immediate CPU queries against that same terrain for collision, placement, vehicles, slope, etc. I ended up with the terrain math authored once against a small adapter surface so JS gameplay and the TSL renderer weren’t maintaining two different versions of the world.
That made me wonder if the pattern itself was useful enough to extract, and also where the assumptions in it actually stop being true.
Matter Field is that experiment.
The deal is deliberately narrow: author a closed-form field once against a restricted math vocabulary, then materialize that same definition as JS f64 for gameplay/Workers/server use, native TSL for WebGPU/WebGL2, and dual numbers for gradients.
The other part is that I don’t assume shared source means CPU/GPU float equality. It doesn’t. So there is an f32 diagnostic path plus hardware-scoped drift receipts over named samples instead of a “parity = true” claim.
Restriction is basically the point. No arbitrary JS, no data-dependent branches inside the field, no pretending every operation has portable-enough behavior just because both sides can spell it.
TypeGPU is obviously the closest overlap. I tried that path too and there is an optional TypeGPU integration in the repo. For a WebGPU-first app doing broader compute/resources/pipelines, TypeGPU may just be the better answer. Matter Field is testing a narrower contract around fields specifically: native TSL + WebGL2 fallback, immediate JS queries, generic CPU gradients, a restricted numeric surface, and measured drift.
I also don’t think this beats the normal approaches universally. If a texture/heightmap can be the authority, great. If the formula is small enough that maintaining CPU/GPU twins isn’t painful, also fine. Readback can be fine if latency doesn’t matter.
The case I’m interested in is more specifically: a procedural field evaluated densely on the GPU, queried sparsely and synchronously by gameplay, and complicated/changeable enough that having two independent implementations starts to feel sketchy.
Current examples are terrain/contact, swell/buoyancy, wind/forces, and a moving queryable volume. The receipts are finite regression evidence on named hardware, not global bounds, and they don’t claim the analytic field equals the rendered triangles between vertices either.
Objekt 62, which is where the architecture came from:
What I’d value from this forum specifically: is this actually a useful contract once you’ve lived with this problem, or is one of the standard approaches basically always the better engineering choice? Also very interested in what field/op/workload immediately makes the restriction not worth it.