aardappel / lobster

The Lobster Programming Language
http://strlen.com/lobster
2.25k stars 119 forks source link

meshgen: subtractive/negative geometry #208

Closed janEntikan closed 1 year ago

janEntikan commented 1 year ago

The only way to get, for example, a crater in a sphere is by adding a negative sphere that removes from- , instead of adding to the generated geometry.

image (some image I found online, left is additive, right is subtractive)

This would add considerable artistic flexibility.

aardappel commented 1 year ago

Ah, as I just mentioned in discord:

This could in theory be supported, but is probably a bit tricky given the additive nature of how things are currently implemented (i.e. it does not "sample" the composite implicit function for each point in the grid once, it actually "adds" each single implicit function to the grid one by one)

And that to some extend also makes it simpler since it would not have to worry about ordering of operations in the case of cutting, since that is already fixed by the mg_ call evaluation order.

aardappel commented 1 year ago

Concretely, you'd add a var to ImplicitFunction that indicates add (1) or substract (-1), then somehow update dv in FillGrid taking that value into account (how? that I wouldn't know off the top of my head). Then add an mg_substract(on:bool) that turns it on or off for the shapes while on.