Jump to content

Frustrated with VEX - Where to start?


pixelgate

Recommended Posts

Hi

 

I'm attending to a course which is calles 'physics for computer games'. We use java+jogl to write the demo applications. Recently, we had to implement the 'Lorenz Attractor' by using the 'Runge Kutta' algorithm.

 

I thought of building something like this in Houdini too. Perhaps I could render out nice images :)

 

Yet I stumbled across a lot of problems, mailnly because of the very poor documentation regarding where which syntax is accepted. I wanted create the points with a vex script in the AttribWrangle node. After countless hours of searching, I have found information that it is not possible to use structs and array returns in functions inside the AttribWrangle node. 

 

Does anyone now how I should proceed? I have read about using VEX inline and outer code section for defining structs and those functions which require an array as the return value. But I don't know Houdini well enough to decide whether this would be the right place for it nor do I have enough time to try a lot (learning for some tests).

 

Thank you & best regards,

pixelgate

Link to comment
Share on other sites

Thank you for there two samples. The age doesn't matter, both of them look good!

 

As far as I know, VEX is much faster then python, therefore I would rather use VEX if it is possible. 

The other version uses a pop network and all the magic is in the position node. Unfortunately, it is hard to 'translate' python/vex/java code to such an expression.

 

I discovered using 'New Operator Type' -> VEX Builder Type gives me something where I could define outer and inner code. This sounds similar to using inline code in a VOP environment. Could this be something I should try or is VEX not suited for such tasks at all? 

Link to comment
Share on other sites

Just use the AttribWrangle if you want to create geometry or create it beforehand and then modify it with any VEX SOP. You can also use Python. In this case I don't think you can take advantage of VEX's parallel nature. The Lorenz algorithm is iterative I think which relies of the previous point.

 

When you are using VEX in a similar manner to Python, there is no significant performance difference in my experience. In some cases Python is even slightly faster as it has methods to get all point positions/attributes at once for example, while VEX doesn't and adding all these up manually in an array in VEX takes a lot of time.

 

I hope SESI addresses this in H14 :)

Link to comment
Share on other sites

Thank you for the clarification. I wrote the script quick&dirty using python. 

 

Is there a way to use multithreading if I wanted to create multiple lines with different starting positions?

Using the copy sop or an additional for loop in the python script gives me the same result, yet it is terribly slow as it dows not calculate the independant lines simultaneously. For example, calculating 3 million points (20 lines, 150000 points each) takes 43 seconds and is only using 15% of the cpu.

 

Best regards,

pixel

Link to comment
Share on other sites

Just create something like a million points and then use an Attribute Wrangler to do the iterations for each point. This is the approach I recently tried for doing a fractal flame : http://forums.odforce.net/topic/21346-wrenninge-book-yujie-shu-thesis-and-apophysis-question/page-2#entry127636 ... In this case, you can even create line segments between successive iterations.

Link to comment
Share on other sites

Thank you for the suggestion edward. I think it would enhance the simulation time a bit but the problem is I cannot use array returns and structs in a Attribute Wrangle node.

This example might be implemented with Vectors but the Runge Kutta algorithm can be used for simulation all kind of fields which might require more than a simple Vector3 as the initial Value.

Link to comment
Share on other sites

The problem is I cannot use VEX syntax inside the attribute wrangle node like structs and functions which return an array. If you look at the documentation, there language constructs ought to be legal but it does not work within the attribute wrangle node. 

 

-Structs would be nice to have as it would be almost object oriented -> easier to understand  https://www.sidefx.com/docs/houdini13.0/vex/lang#structs

-Arrays are needed for the runge kutta algorithm https://www.sidefx.com/docs/houdini13.0/vex/arrays  (vector[] rgb_array() example)

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...