I’ve been entrenched in the Houdini world for the last year, and I’m just getting back to Touch. I’m also now realizing I want to integrate some of my Houdini methods into Touch. The main thing that I’ve been missing in the Point Wrangle.
For anyone not familiar with Houdini, it’s a little snippet of super fast code that works on all the points of a SOP on the GPU. Which means it’s very fast and efficient.
Unless I’m mistaken, the closest thing that exists in Touch in GLSL, and it has a similar method of working on each pixel concurrently.
So this is a way to easily add a snippet of GLSL code where you only have to pay attention to the parts you care about.
At the moment it works with any float, vec2, vec3, or vec4 attribute. Just prepend the attribute name with ‘@’ in the code
Some example code:
// This will make your SOP deform in a wave @P.y += sin(@P.x) // If you set up some variables, you can now have it animated with control of speed and amplitude @P.y += sin(@P.x + absFrame * speed) * amp; // Color your model based on it's position @Cd = @P;
The easiest way to figure out what’s going on is to download the attached toe file.
If you are setting it up from scratch, then do the following
- Add code to a Text DAT
@P.y = sin(@P.x*10 + absFrame * speed) * amp;
@N = vec3(1,0,0)
Add any variables you want to use to a Constant CHOP (like absFrame, speed, amp, etc.) There is a VARIABLES chop that is included in the toe file
After changing variables, go to the Wrangle BASE parameters. There will be a Wrangle tab. Click on the Setup Variables button.
The main thing I’m unsure of is the efficiency of the method. You feed it a SOP and a text DAT with your code, and it will do a SOP -> CHOP -> TOP (with GLSL pixel shader applied) -> CHOP -> SOP
Is this a viable method? I’m sure there’s some GPU -> CPU conversions that I’m unaware of that will slow the whole thing down.
Take a look at the example files, and let me know if there’s anything big reason this won’t work, or any suggestions you have.
The wrangle will now automatically split incoming geo into sections to get around a resolution limit of the GLSL TOP. Thanks to flowb for the starting point of splitting the geo up
Inside the tox, you can find the logic for applying the GLSL code at wrangle / splitGeo0 / applyGLSL
The tox will also now output your final code as well as any errors that may be reported.
Super useful update.
This should now work with any vector3 attribute
Now works with float, vec2, vec3, vec4 attributes
Fixed major bug where an attribute could not be calculated bsaed on another attribute
I’ve attached a toe and a tox file.
I highly recommend using the toe file to see how everything is set up