Thursday, 18 April 2019

PYRO DIY 2019

The pyro setup tools have changed a little bit in Houdini 17..

Here's a refreshed outline of what you need to make a setup from scratch.

  1. Create something to emit the pyro. You'll eventually be turning it into a volume, so keep that in mind.
  2. Plug your emitter object/points into a Pyro Source node. 
  3. Optional, but usually a good idea - Connect an attribute randomise node and randomise Density and Temperature
  4. Use a Point Wrangle to randomise pscale with your favourite function (or don't)
  5. Connect a Volume Rasterise Attribute node and specify  Density, Temperature and V (for velocity) as the things you want to rasterise. Now you have some volumes which will act nicely as sources for smoke. Label them with nulls (SOURCE)
  6. Before we jump into simulating, there are two more things we need to make to help along things. A box that encompasses the volume of the entire sim and a box that roughly covers the volume of the first frame of your sim. Label them with nulls( BOUND and START for example)
  7. Create a dopnetwork. Inside, make a Pyro Solver. This is the brains of it all.
  8. The first input into the solver should be a Smoke Object. For testing purposes use a higher division size, maybe 0.1, which represents 10cm as a single voxel. In the "size" boxes, use an expression bbox("../../START",D_XSIZE) and respectively the D_YSIZE, D_ZSIZE 
  9. For the centre, use the expression centroid("../../START", D_X) and D_Y, D_Z
  10. The rest of the Properties tab can usually be left as default.
  11. In the Creation tab, set the Creation Frame to the first frame where your source appears. You may or may not want to have Solve on Creation Frame ticked on. See what works for you.

  12. The second input into the solver is the Gas Resize Fluid Dynamic.
  13. The Max Bounds tab is what we're interested in first. Set the type to "From Object" and navigate to the BOUND object you created in step 6. This stops the simulation from going nuts and out of bounds.
  14. Back in the Bounds tab, you might have to play around with the padding values. Generally the closer to zero, the less extra work the solver has to do.
  15. Let's skip a few inputs of the solver. The last input will be the source volumes. Add a Volume Source node and navigate to your SOURCE object (step 5) You could have this connected to the Dopnetwork as one of the inputs, but lately I tend to keep those clear (you might have many sources etc..)
  16. In the Volume tab, press the + button. You'll want to add the "density", "temperature" and "v" from your SOURCE. Label the target fields "density", "temperature" and "vel" respectively. The first two are scalar values & vel is a vector one.You could leave out temperature and velocity if your sim doesn't really require it, but I find a little bit of temperature helps gets the sim moving.
  17. Hit play, or click on a frame (this is faster, as having to display each frame slows down Houdini a little) in the timeline & wait a little bit. Something should have happened!

  18. The sim probably looks a little simple. We can disturb the velocity or temperature to make it look more interesting now. This is what the third input is for. You can plug in Gas Disturbance, Gas Turbulence and a few other nodes to do the trick here.
AND THAT'S IT.. A simple and clean pyro setup.

Copying different objects to points

Sometimes you need to copy a bunch of different objects to points. Eg. You have 5 variations of wood splinters and you're emitting them from a snapping plank.
Instead of using the slower copy stamp with random point values, you can use a ForEach loop and a Switch node..and of course a point wrangle.

Connect the objects to the Switch node. In a point wrangle, give each point an (random) integer value (eg "instanceID") ranging from 0 to the number of objects you have.
Make a ForEach network and connect the Point wrangle into the top. Create a null node directly after the start of the Foreach Begin. This will be a "temporary holder" node. It will carry the instanceID value to the Switch node. I've called it PT
The clever bit happens in the Switch node. In the parameter window, click on the cog wheel and add a Spare Input. This will create a new dialog box called Spare Input 0. Type in:

../PT

This will point the spare input to our temporary null & its instanceID value.
In the Select Input dialog box, type

point(-1, 0, "instanceID", 0)

here we are telling the Switch node to get a point attribute from input -1 (which is the spare dialog....which is pointing to the PT temporary null..). The attribute in question is instanceID.. NICE.
A purple arrow going from PT to Switch should have appeared now. This represents that link we've just made.

All that is left to do is to create a Copy To Points node & put the Switch output into the objects input & plug PT into the points input. Finally plug the output of all of that into the Foreach End.

Tuesday, 16 April 2019

Check names for duplicates

point wrangle snippet from Mike

int find = findattribval(0,"point","name",s@name);
int count = findattribvalcount(0,"point","name",s@name);
i@find = find;
i@count = count;

Friday, 12 April 2019

solver sop and moving geometry

So, the Solver SOP doesn't behave as "I" expected with animated (ie. moving) points/geo.

You need to manually update the position if you want your geo to still move!
SOOOOOOOOOO. Inside the solver, copy the P (for position) attribute from Input 1 to Prev Frame...

Weird stuff. But hey.

removing RBD from a sim

Sometimes you need to remove an RBD from a sim completely. Eg, you're using a block to push something and then need it to get out of the way...

Make sure you have a group for it on SOP level. It will probably be a point group, as you're most likely using packed geo.

Now use a SOP solver in your DOP network. Attach it to a multisolver, alongside your Bullet/RBD solver..
Inside the SOP solver, blast the group that you created earlier. Use a switch node or some other timing device (you could use a point wrangle with removepoint I think)  to trigger the group's deletion.
Eg. Switch node  could use $F>1000. Here it will switch from "all the geo" to "all the geo minus the group" input.

Select a random point from a group each frame

Some code snippets from Walter to use points from a group randomly, for emission (or other things)

In a Detail Attribute Wrangle-

int npts = npoints(0);
float keep = rand(@Time + 235.624) * npts;
i@keep = int(keep);

Every time step, a random point id is chosen as the "keep" point.

Then in a blast, we kill everything but the kept point

`detail(0, "keep", 0)`

Don't forget to invert the blast selection

Saturday, 6 April 2019

Bullets solver, setting or changing attributes

Bullet solver is a bit strange in Houdini. It might not update values as you expect. Eg, you're trying to change the @active value using a sop-solver.
One solution is to use the Bullet mode in the RBD Solver. This usually works..But it might be slower? I think it has a multi solver built into it..

Another way to make it work is by utilising a multi solver and the Geometry Wrangle. This will let you access the SOP level stuff (there is an input tab you can mess around with)

So, your input RBD goes into the first input of the multi solver, then your Bullet Solver and any Geo Wrangles go into the purple input of the multi solver..