Jump to content

How to get the same result with the new for_each node like in the old foreach node?


Recommended Posts

Recently, I've been learning a Houdini destruction tutorial called "CGSociety - Destruction in Houdini".
But, I got stuck with the new For_each node. I can't get the same result like in the old foreach node.
Does anyone know How to get the same result in the new for_each node?

Houdini17.5
Thank you!:)

604b4091d1de5__20210312182045.thumb.png.23f89064c44324bb8df3481f1ce8c968.png

hip file:

crack_pattern_generator_question.hipnc

Edited by yinyuY
Link to comment
Share on other sites

Heyo,
I took a look at your hip file and I think I've made it work how you want it.
The main issue was twofold, number one was that your "new" for_each loop (I say "new" since this loop has been around for a while now) was set to "Fetch input" and "Merge iterations" on the begin and end nodes respectively. Essentially what this does is that it runs the whole loop x amount of times (x being the number of iterations you enter in the foreach_end1 node), independently and then merges the results at the end, meaning that you end up with x amount of copies of the original geometry which is not what you want since you just want to perform an operation on the geometry multiple times. To fix this just change the options in the foreach_begin1 and foreach_end1 nodes to "Fetch Feedback" and "Feedback Iterations" respectively. What this essentially does is that it only gets the geometry once but runs it in a "loop de loop" x amount of times. So whenever the geometry has processed once through the loop and gets to the foreach_end1 node it gets sent back as it is currently to the foreach_begin1 node and gets processed again, repeat x amount of times.
The second issue was that your delete node was using the old expression you used in the delete node inside the old foreach node and as such the value inside was not changing. The whole point of the expression in the delete node is for the delete node to delete everything except one of your fracture points and for the clip nodes to then use that one point to fracture the geometry. This only works properly if the point used to fracture the geometry changes every iteration of the loop, if not you will only be trying to create a fracture in the exact same place x amount of times. I fixed this by changing the expression to get the iteration number from the foreach_count1 node. This node creates detail attributes that are specific to this foreach loop like what iteration it is currently calculating or how many iterations there are in total. To get that info I just used the detail hscript expression that goes something like this: detail('path_to/node_that/has_the/attribute', 'name_of_attribute', 0) (the last 0 is what index of the value you want. If it is just a normal number just use 0. This is only really useful to change if the attribute is a vector attribute).


That all being said, while this is a completely valid approach to fracture geometry it does seem slightly "old fashioned". I've added a few other approaches in the hipfile below like using the "Boolean" node which just takes some cutter geometry and what geometry you want to cut. The other method I added was using the "Voronoi fracture" node which only requires the geometry to fracture and some points to create the fracture pattern. It's not as nice looking as your method or the boolean but it is a very fast and very stable way to fracture things.


Hopefully, the explanation is ok, it might be very long-winded and I don't know if it is beginner-friendly enough. Be sure to leave a reply if something is unclear and I'll try to get back to you with an answer.

Also of note, I used Houdini 18.0.460 to make this, so I'm not sure if there are going to be some issues when you open the file in Houdini 17.5. I think it will mostly be ok, it might complain about some parameters missing but I don't think anything critical should be removed. I guess for the best result you could even recreate what I made in the original Houdini 17.5 file to make sure there are no version compatibility issues.

Good luck! :D

crack_pattern_generator_question_mnb.hipnc

  • Like 1
Link to comment
Share on other sites

On 2021/3/17 at 5:43 PM, underscoreus said:
On 2021/3/17 at 5:43 PM, underscoreus said:

Heyo,
I took a look at your hip file and I think I've made it work how you want it.
The main issue was twofold, number one was that your "new" for_each loop (I say "new" since this loop has been around for a while now) was set to "Fetch input" and "Merge iterations" on the begin and end nodes respectively. Essentially what this does is that it runs the whole loop x amount of times (x being the number of iterations you enter in the foreach_end1 node), independently and then merges the results at the end, meaning that you end up with x amount of copies of the original geometry which is not what you want since you just want to perform an operation on the geometry multiple times. To fix this just change the options in the foreach_begin1 and foreach_end1 nodes to "Fetch Feedback" and "Feedback Iterations" respectively. What this essentially does is that it only gets the geometry once but runs it in a "loop de loop" x amount of times. So whenever the geometry has processed once through the loop and gets to the foreach_end1 node it gets sent back as it is currently to the foreach_begin1 node and gets processed again, repeat x amount of times.
The second issue was that your delete node was using the old expression you used in the delete node inside the old foreach node and as such the value inside was not changing. The whole point of the expression in the delete node is for the delete node to delete everything except one of your fracture points and for the clip nodes to then use that one point to fracture the geometry. This only works properly if the point used to fracture the geometry changes every iteration of the loop, if not you will only be trying to create a fracture in the exact same place x amount of times. I fixed this by changing the expression to get the iteration number from the foreach_count1 node. This node creates detail attributes that are specific to this foreach loop like what iteration it is currently calculating or how many iterations there are in total. To get that info I just used the detail hscript expression that goes something like this: detail('path_to/node_that/has_the/attribute', 'name_of_attribute', 0) (the last 0 is what index of the value you want. If it is just a normal number just use 0. This is only really useful to change if the attribute is a vector attribute).


That all being said, while this is a completely valid approach to fracture geometry it does seem slightly "old fashioned". I've added a few other approaches in the hipfile below like using the "Boolean" node which just takes some cutter geometry and what geometry you want to cut. The other method I added was using the "Voronoi fracture" node which only requires the geometry to fracture and some points to create the fracture pattern. It's not as nice looking as your method or the boolean but it is a very fast and very stable way to fracture things.


Hopefully, the explanation is ok, it might be very long-winded and I don't know if it is beginner-friendly enough. Be sure to leave a reply if something is unclear and I'll try to get back to you with an answer.

Also of note, I used Houdini 18.0.460 to make this, so I'm not sure if there are going to be some issues when you open the file in Houdini 17.5. I think it will mostly be ok, it might complain about some parameters missing but I don't think anything critical should be removed. I guess for the best result you could even recreate what I made in the original Houdini 17.5 file to make sure there are no version compatibility issues.

Good luck! :D

crack_pattern_generator_question_mnb.hipnc

I really appreciate the time you put in to help me. It works fine now. And the way you explain is very easy to understand even for a non-English speaker like me. :DBTW, the "Boolean" way you mentioned is really cool. I think it's much more useful than the "for each" way.
Thank you!

Edited by yinyuY
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...