I'm currently learning Houdini and vex. My test scene consist of a sphere which is projected unto a bigger sphere. Using the ray node, it works fine and the performance is fast. I then tried to do the same thing using an attribute wrangle node with vex intersect(…). It also works, but the performance is very slow.
While I understand why the vex code is slow, I don't understand why the ray node is this fast, and why it doesn't seem affected by the number of primitive from the collision geometry.
I would like to know how to do something in vex as fast (or faster ) as the ray node. Or at least understand why there's a difference in performance. I've attached a sample file to illustrate the problem.
Thanks for the help.
P.S. An easier question, why is the ray collision primitives connector dotted ?
it's most probably caching of the acceleration structure it seems that Ray SOP is able to detect that the collision geo is the same among all the iterations and therefore computes acceleration structure just once, while VEX intersect function is probably computing a new one each iteration just a guess though
Funny I've always used the Ray Sop node because I was lazy to do it in vex and I always regretted about the lost performance. Turns out that Ray Sop is way faster than intersect() function, even when you let it create and import all the attributes. I didn't try profiling with intersect_all() too, though. But I guess it would be the same story.
A little annoyance about the Ray Sop is that if you want the hitpos, you need to create a rest position attribute in the collider geo, and then import it with Import Attributes from hits in the Ray Sop.
Regarding the Vex intersect(), why it doesn't come with the tol and ttol arguments like intersect_all()? Is intersect() less precise than intersect_all()?
Andr A little annoyance about the Ray Sop is that if you want the hitpos, you need to create a rest position attribute in the collider geo, and then import it with Import Attributes from hits in the Ray Sop.
Ray gives you a hitprim and hitprimuv. That lets you get any attribute from the target geo, not just the rest position.
Use Attribute Interpolate or primuv with the hitprim and hitprimuv. It gives the interpolated value of whatever attributes you need, and it's extremely fast
Edited by Hallam Roberts - Sept. 20, 2024 21:26:38
the ray node has a huge flaw in my opinion. When you import an attribute from vertices, the attribute is averaged and promoted to points. That is, if you want to take a normal for your limited group of points and write them to vertices, where they should be, then ALL normals on your object will be averaged and promoted to points and all hard or custom normals will be destroyed, even if you then manually promote them back to vertices. You only needed to process a small group of points, but in the end ray spoiled your normals. And to get around this you will have to build an intertwined web of nodes with promotion and copying of attributes and groups and not get lost in it. Or you will spit on this and write a 5-line code on vex that will do everything right at once. In general, the classic Houdini - make a good node and deliberately make such a flaw that the node will work incorrectly in important situations and you will still have to learn VEX and write alternatives yourself.