Show HN: Render Arbitrary 3D Boolean Functions
8 points by unixpickle 5 years ago | 6 comments- unixpickle 5 years agoThis is a web demo for creating 3D models in JavaScript. It uses a variant of ray casting that can render any function mapping `(x, y, z) -> bool` in real-time.
It's easy to define very interesting 3D models as boolean functions. In my opinion, it's much easier than creating triangle meshes or composing a bunch of primitive shapes. I had fun making the examples, and I'm curious to see what other people can come up with.
- GistNoesis 5 years agoYou probably should mention the rendering of signed distance fields. The representation is quite similar `(x, y, z) -> double`, and allows for high generative power and more performant ray marching algorithm. You can also get the normal by automatic differentiation.
- unixpickle 5 years agoGood idea, I'll add a reference to SDFs. Didn't think about the normal-via-autodiff aspect, which would be quite useful.
It seems to me that SDFs are very hard to program from scratch, compared to simple boolean functions. Obviously they are easy to implement for compositions of simple shapes, but for things like my text example (and maybe the corkscrew example, although of course that is still a fairly simple mathematical shape), it's less obvious how to implement an SDF by hand.
- GistNoesis 5 years agoAs a intermediate solution between boolean and SDFs, you can also use some implicit representation defined by a neural network. It could be marched by your current algorithm.
And you can train the neural network with your mathematical boolean function by sampling the space to provide positive and negative samples.
With the neural network representation, you can also build your mesh by iteratively picking points and specifying whether they are in or outs. Or you can specify the distance or the normal. They are much more flexible. They can even do the rendering.
Various representations are always useful to have so you can pick the right one for your current problem.
- GistNoesis 5 years ago
- unixpickle 5 years ago
- GistNoesis 5 years ago
- photon_off 5 years agoI don't have any feedback or strong opinions on this, but the concept of mapping (x,y,z)=>bool and having it produce a 3d object is new to me. This is a very cool demonstration; thank you for sharing.