Show HN: Render Arbitrary 3D Boolean Functions 8 points by unixpickle 4 days ago | hide | past | web | favorite | 6 comments

 This 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.
 You 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.
 Good 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.
 As 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.
 A neural network would have some nice properties for sure, although it'd also have plenty of bad ones. For one thing, I'd guess that the NN wouldn't be great for rendering in real-time, since it's liable to be orders of magnitude slower than the JS function it's approximating. Granted you could use a GPU--but then again, you could probably compile the JS function into a kernel and get a speedup there too.If you sample the boolean function enough to train a neural network on it, you've likely sampled more than enough to build a very accurate mesh using marching cubes or other algorithms. Meshes are especially easy to render, plus they can tell you quite a lot.
 I 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.

Applications are open for YC Summer 2020

Search: