Strange behavior of Cookie (A minus B mode)

   5831   5   1
User Avatar
Member
3 posts
Joined: 8月 2012
Offline
Hi, I've just started experimenting with Houdini and as the first experiment I wanted to create Menger Sponge. Combine it from small cubes is quite easy but after third iteration there are too many cubes that it is hard to even move with scene.

I realized that there is many useless faces so I wanted to create Menger Sponge using subtracting. Create cube and drill holes in using cookie node. First iteration is ok but second and third produces very crazy things.

I tried ti merge all holes and drill all at once which may not work properly so I used cookie node on every iteration. The model looks really weird, non-deterministic…

I also tried many primitive types. What I am doing wrong? Is this bug or feature? I am quite confused what is hapenning.

I am including some saves of my tries.

Thanks in advance

Attachments:
MengerSponge-Merge.hip (69.3 KB)
MengerSponge-Cookie.hip (72.4 KB)

User Avatar
Member
9 posts
Joined: 11月 2006
Offline
The cookie sop is a bit of a nightmare - it's very much prone to numerical precision errors.
Firstly though, you need to make sure both inputs are closed, manifold, non-overlapping geometry - your second input contains lots of overlapping geometry.

I've attached a file that uses a foreach loop to subtract each cuboid, one at a time. I've also subdivided the first input cube, to avoid the cookie sop generating lots of long thin triangles (which also cause problems with the cookie sop).

Best of luck trying to remove the other two orientations of blocks… the cookie sop really doesn't like coincident faces, and you're gonna get a lot of them…

I really think your best bet is to try and generate it face at a time…

Attachments:
mengersponge-merge_stabby.hip (72.8 KB)

User Avatar
Member
3 posts
Joined: 8月 2012
Offline
Thanks for fast reply

I thought that cookie will have problem with overlapping geometry. But in my second attached example called “MengerSponge-Cookie.hip” I avoided them and it failes anyway.

Thx for example, I tried to extend it and it failed quite hard :-D I tried to subdivide the starting cube to “correct” number of divisions and it looked better. Than I added second cuts, everything was OK but with last cuts it was screwed (attachment).

I noticed that you use many “helper” nodes on the way which I don't know, I have to study more I guess.

Maybe, it would be better to create it from cubes but how to avoid lagging with many cubes on scene? Maybe edit with points?

Thanks

Attachments:
MengerSponge-Foreach.hip (87.2 KB)

User Avatar
Member
9 posts
Joined: 11月 2006
Offline
aah i forgot you posted two examples

Here's a quick and nasty version that builds it using points, then replaces the points with a square face. The middle ‘Number Range’ parameter on the foreach1 SOP controls the depth… I haven't dared turn it past four.

The way I've done it here creates points for hidden faces, then removes them. I'm absolutely certain there's a way to algorithmically determine which faces are visible, but it takes too much thinking

Attachments:
mengersponge-merge_stabby2.hip (125.1 KB)

User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
Here's my attempt at fixing stabby's first example. I think it just didn't go far enough. Here's what I did on top of it:
- Changes the Box SOPs to output Triangles so that we can easily see where the long thin problem ones are.
- This then showed me that the right input had long thing triangles which needed fixing. So I adjusted box5's to output a polygon mesh and set the axis divisions to 3,16,3 as well.

Turns out that this is the minimal set of things to fix this particular file. If you have coincident faces, it's also helpful to enable Do Jitter and increase the amount slowly until it resolves problem areas.

The other problem with doing this type of process is that you might introduce multiple pieces in the left input. If you have that, then you'll need to second level of nested ForEach SOP (make you change the default loop index values to something different).

Attachments:
mengersponge-merge_stabby_attempt_fix.hipnc (76.6 KB)

User Avatar
Member
3 posts
Joined: 8月 2012
Offline
Thank you guys very much. I like Stabby's solution to create only necessary faces, nice!

I tried to render it and here is the result (resized to 25%

Attachments:
MengerSponge-25.png (164.2 KB)

  • Quick Links