Jump to content
olivier

Particle rasterization to voxel grid

Recommended Posts

Hi,

Sorry if this is obvious, I'm looking to rasterize a particle set onto a voxel grid in order to source quantities (density, temperature for example) on a per frame basis into a voxel fluid sim.

1. How do you guys suggest I do this?

2. I would ideally want to control the splatting/weighting kernel onto the grid, can I do this through some existing DOPs, is there a way to do this through VOPs?

3. A last request would be to find out how to perform the particle sim and voxel fluid sim in lock step so that the particle sim would read the fluid quantities computed at the previous frame before computing its next sim state at the current frame (btw, the particle sim is a traditional sim, not a SPH sim).

Please don't hesitate to answer partially, any help is appreciated,

Thanks in advance,

Olivier

PS: First post here, this forum is great!

Share this post


Link to post
Share on other sites

Hello, and welcome!

I did something similar once, I don't have the file at home, but i do remember some of it :)

Firstly, I didn't even want to do it lock-step. I've felt that it's a better workflow to first get

the particle sim to behave as needed, write it to disk, and then it's fast to iterate on the

next phase.

For density, you can just simply copy metaballs to your particles, and then append an

Iso Offset SOP to convert to a volume. You have pretty good control of the kernel, but

this might not be the fastest way if you have really a lot of points.

I guess this could work with other attributes too, if you scale the metaball values by

the relevant attribute at each point - never tried this though.

The other way is with a Volume VOP SOP. You can open the previously saved particle sim

frame as a pointcloud inside the Volume VOP SOP, and get a filtered sample with a

Point Cloud Filter VOP. You have less control over the filter/kernel (mainly just a search

radius), but this method should scale well up to "a lot" of particles.

For bringing the resulting volumes into the DOPs simulation - I don't remember for sure,

probably you'd need to dive inside the smoke object and change the relevant "initial SOP"s

from "Set Default" to "Set Always". Depending on what you want to do, e.g. adding to the

current sim state or just setting the current state, you might need to do some tomfoolery

in microsolverland (probably involving SOP Scalar Field & Gas Calculate)

eetu.

PS. I haven't done this for long, someone might well have better ideas, take this with a grain of salt :)

Share this post


Link to post
Share on other sites

Thanks Eetu, I'll give that a try. It seems like the Volume VOP SOP might be the way to go.

O.

Hello, and welcome!

I did something similar once, I don't have the file at home, but i do remember some of it :)

Firstly, I didn't even want to do it lock-step. I've felt that it's a better workflow to first get

the particle sim to behave as needed, write it to disk, and then it's fast to iterate on the

next phase.

For density, you can just simply copy metaballs to your particles, and then append an

Iso Offset SOP to convert to a volume. You have pretty good control of the kernel, but

this might not be the fastest way if you have really a lot of points.

I guess this could work with other attributes too, if you scale the metaball values by

the relevant attribute at each point - never tried this though.

The other way is with a Volume VOP SOP. You can open the previously saved particle sim

frame as a pointcloud inside the Volume VOP SOP, and get a filtered sample with a

Point Cloud Filter VOP. You have less control over the filter/kernel (mainly just a search

radius), but this method should scale well up to "a lot" of particles.

For bringing the resulting volumes into the DOPs simulation - I don't remember for sure,

probably you'd need to dive inside the smoke object and change the relevant "initial SOP"s

from "Set Default" to "Set Always". Depending on what you want to do, e.g. adding to the

current sim state or just setting the current state, you might need to do some tomfoolery

in microsolverland (probably involving SOP Scalar Field & Gas Calculate)

eetu.

PS. I haven't done this for long, someone might well have better ideas, take this with a grain of salt :)

Share this post


Link to post
Share on other sites
Thanks Eetu, I'll give that a try. It seems like the Volume VOP SOP might be the way to go.

O.

One thing you might try is eetu's idea of copying metaballs to the points, but then skip the part of generating a volume with IsoOffset, and instead write out the metaball geometry to files. Then use a Gas Field VOP inside of DOPs to update the density field directly each timestep, but instead of using point clouds, just use the MetaWeight VOP (or vex function) to get the metaball weight at any point, clamp to 1, and max with the current density. This is quite fast, and still lets you control / preview the shape of the kernel in SOPs (see attached image).

Ideally you could use the op:/ syntax to just pull the metaball or point geometry straight from SOPs into DOPs, but I've never had much luck getting the geometry to cook consistently when doing that. Not a problem for the non-lock step case, but problematic for the lock-step.

For lockstep, one thing you might look at is having the Smoke object solved by a Smoke Solver, and your particle object solved by a POPSolver in the same DOP network. Then each timestep, use a Fetch Data DOP to pull the Geometry out of the Particle object and attach it to the Smoke object, and use a GasParticleToField DOP to transfer a density attribute from the geometry to the density field. In the POP Net you should be able to pull in fields from the Smoke object with the DOP Import SOP.

I'll try to throw together an example, since getting the various sims talking to each other is always a bit tricky. Obviously try to get the non-lockstep approach working first.

post-2001-1238464743_thumb.png

Share this post


Link to post
Share on other sites
I'll try to throw together an example, since getting the various sims talking to each other is always a bit tricky. Obviously try to get the non-lockstep approach working first.

OK, attached is an example of doing them in lockstep. Here the particles are advected by the velocity from the smoke sim, and the smoke sim pulls density from the particle's density attribute using GasParticletoField. The forces in the smoke sim are then affected by density, etc. So a big cycle of a system.

Things to notice:

1) There's a lot of motion because I left the default temperature field in there which stirs things up a lot with buoyancy.

2) It behaves a little better if you increase the substeps on the entire DOPNet and up the resolution of the smoke sim.

3) Play with the "Accumulate" vs "Extrapolate" on the Gas ParticleToField DOP.

4) The density lags behind the particles by one timestep - just the nature of the Fetch Data DOP. You can get around this by having the particles and smoke being part of the same DOP Object, and solving it first with the POP Solver and then the SmokeSolver, although that can be a little restrictive.

5) Look inside the Advect POP asset to see how it pulls velocity data from the current smoke sim.

To copy metaballs to the particles and use that as a source in this setup, you'd need to follow up with a SOP Solver, then figure out a good way to pull the result back into the Smoke Sim, which is where the problem with the op:/ syntax I mentioned above comes in. There's probably a way to do it - let me know if you're trying it and having problems.

Good luck.

particles_into_smoke.hip

Share this post


Link to post
Share on other sites

I've done this before just using a Gas Particle To Field DOP in my simulation too.. I've just got to look at John's now ;)

Cheers,

Jason

particlesource.hip

Share this post


Link to post
Share on other sites
To copy metaballs to the particles and use that as a source in this setup, you'd need to follow up with a SOP Solver, then figure out a good way to pull the result back into the Smoke Sim, which is where the problem with the op:/ syntax I mentioned above comes in. There's probably a way to do it - let me know if you're trying it and having problems.

This is actually something I've been wondering about, so I went ahead and created an example. See the comments in the file, but basically I added an extra piece of data to the Particle object called MetaballGeometry, then use a SOP Solver to create the metaball geo each timestep. Then I read that in using a GasFieldVop in the smoke sim and use the metaweight to update the density field.

It works pretty well and is pretty fast, but there's one hacky thing related to getting the metaball geo into the GasFieldVOP. You should be able to ObjectMerge the metaball geo back into a SOP network and reference it from the GasFieldVop using the op: syntax but this crashes 9.5 (works in H10 beta for what it's worth), although you're getting the previous frame's geometry. My gross hack is to write to the same temporary file each timestep as part of the SOP Solver with a File SOP set to "Write" and the just read the file in explicitly in the GasFieldVOP. But to get that to work, you have to turn on autoflushing of the VEX geometry cache with "geocache -a 1". I put a script solver in the DOPNet that just calls that on initialization, so it should Just Work (I think).

The nice thing about this is you can create whatever metaball geo you want from the particles in the SOP solver and it will work as a source for the density.

Edit: I put a quick render of doing this in 3D at 64x64x64 here. I should have done some substepping and the render kinda blows, but you get the idea. Kind of a neat effect.

particles_into_smoke_metaballs.hip

Edited by johner

Share this post


Link to post
Share on other sites

Thanks for taking the time guys :) I'm going to dive into your setups asap. That movie looks great John!

Have a nice day,

Olivier

Share this post


Link to post
Share on other sites

This is actually something I've been wondering about, so I went ahead and created an example. See the comments in the file, but basically I added an extra piece of data to the Particle object called MetaballGeometry, then use a SOP Solver to create the metaball geo each timestep. Then I read that in using a GasFieldVop in the smoke sim and use the metaweight to update the density field.

So, this is embarassing. On the Houdini mailing list, Louis Dunlevy pointed out that there's direct support for using particle systems as a fluids source in DOPs, which was news to me. Looking it up in the journal, sure enough:

Wednesday, March 18, 2009

Houdini 10.0.224: You can now use particle systems as sources and sinks with fluid simulations. Also, if use non-sdf is enabled, they can act as collision objects. The pscale of the particle system is used for the particle radius and the Alpha used as a density scale. Particles will be expanded by a voxel-sized bandwidth amount to avoid point-sampling artifacts when particles are smaller than the grid spacing.

Which, of course, was added two weeks before I posted the convoluted setup above. Basically it appears SESI added support to the BuildRelationshipMask DOP for creating the "source" field from a particle system, using a couple of particle attributes to control the density of the field created. And since it's a source you can use particles for fuel as well, change the Source Velocity Type to Point Velocity and transfer velocity from the particles to the fluid, etc. Really cool stuff.

So, um, ignore everything I said above. Attached are the same simple examples (2d and 3d) of using particles as a density (and temperature) source and being advected at the same time, this time using the particles as a source, which is much faster, better, etc. There's a couple of nodes in there to use the source as temperature also and a high dissipation with Gas Dissipate, so each particle behaves like a little hot gas ball, but the basic setup is really straightforward.

Also, a quick flipbook of the 3d example in the viewport.

Edit: oh yeah, Louis also pointed out that the Add SOP can now convert points to particle systems, meaning you can use the same setup using regular points as a source

particles_into_smoke_2d.hip

particles_into_smoke_3d.hip

Edited by johner

Share this post


Link to post
Share on other sites

Thanks for this thread guys ... lifesaver :D

So, I've only looked through these scenes a bit and gotten the info I need. Can anyone summarize or give a general workflow for how exactly point/particle data can be used with volume-data-feilds in DOPs? There seem to be a few different approaches accomplishing similar things (which is very Houdini like). But, what's best for what? Seems like on first impression that for most things a particle object/solver is overkill when the geometry data can be read in directly and converted.

Share this post


Link to post
Share on other sites

Hey Andrew, Personally I think the DOPs approach is the way to go over something like point clouds or metaballs, Gas Particle to Field is quick and gives great results. It uses pscale to control the sampling radius and can extrapolate the values beyond that. You can use a Gas Intermittent Solve to get this data once or once per frame. I use this even in SOPs, through an asset with a Timeless DOPnet inside. It's a pretty rad way to get curve tangents into a vector volume for advection too.

Share this post


Link to post
Share on other sites

Amazing! Thank you for good thread!

Do you guys know is there a way to create cluster with gas part to fluid? Or cluster inside DOP with sopsolver or something (density don't have to be created with gasparticletofield)

I'm exploring dop at the moment and what I had in mind is that from each impact of rbd, create source for popobject and fetch that data to smokeobject.. So, if I want to create more then one source, I get into an issue with smokeobject size ..

 

I posted thread a day ago, if you have a moment, take a look.

Thanks in advance! 
Best Regards, M
 

 

Share this post


Link to post
Share on other sites

Amazing! Thank you for good thread!

Do you guys know is there a way to create cluster with gas part to fluid? Or cluster inside DOP with sopsolver or something (density don't have to be created with gasparticletofield)

I'm exploring dop at the moment and what I had in mind is that from each impact of rbd, create source for popobject and fetch that data to smokeobject.. So, if I want to create more then one source, I get into an issue with smokeobject size ..

 

I posted thread a day ago, if you have a moment, take a look.

Thanks in advance! 
Best Regards, M
 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×