pixelgate Posted December 12, 2014 Share Posted December 12, 2014 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 Quote Link to comment Share on other sites More sharing options...
eetu Posted December 12, 2014 Share Posted December 12, 2014 These are not very recent (to put it mildly:), but might be of interest regarding lorenz: http://forums.odforce.net/topic/1665-lorenz-attractor/ http://www.preset.de/2007/0711/lorenz/ Quote Link to comment Share on other sites More sharing options...
pixelgate Posted December 12, 2014 Author Share Posted December 12, 2014 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? Quote Link to comment Share on other sites More sharing options...
magneto Posted December 12, 2014 Share Posted December 12, 2014 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 Quote Link to comment Share on other sites More sharing options...
pixelgate Posted December 13, 2014 Author Share Posted December 13, 2014 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 Quote Link to comment Share on other sites More sharing options...
edward Posted December 13, 2014 Share Posted December 13, 2014 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. Quote Link to comment Share on other sites More sharing options...
pixelgate Posted December 14, 2014 Author Share Posted December 14, 2014 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. Quote Link to comment Share on other sites More sharing options...
edward Posted December 16, 2014 Share Posted December 16, 2014 I'm not sure I'm following. You can have any arbitrary attribute data on your points. Quote Link to comment Share on other sites More sharing options...
pixelgate Posted December 16, 2014 Author Share Posted December 16, 2014 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) Quote Link to comment Share on other sites More sharing options...
edward Posted December 16, 2014 Share Posted December 16, 2014 Have you tried passing them by reference? Quote Link to comment Share on other sites More sharing options...
pixelgate Posted December 20, 2014 Author Share Posted December 20, 2014 Where could I pass what by reference? I did not see such an option in the copy sop. I have made a render with 10million points now. As it still uses only one core, calculating is terrily slow but I can live with it for now Quote Link to comment Share on other sites More sharing options...
edward Posted December 24, 2014 Share Posted December 24, 2014 All variables to functions in VEX are passed by reference unless you specified const. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.