[yt-users] Particles in volume rendering

Matthew Turk matthewturk at gmail.com
Mon Aug 2 08:49:16 PDT 2010


Hi Stella,

>   Does anyone know an easy way to include particles positions (i.e. as small
> spheres) in a volume rendering? It occurred to me that I could add high
> values to the locations of the particles within the field that is being
> rendered and then define the transfer function in order to pick them out.
>  However, I'm not sure how to modify the field data to do this. Any
> suggestions?

That idea would work, for getting out the particle positions -- but it
might not give the best results.

Unfortunately, adding on an actual scenegraph to the software volume
renderer is quite the task -- right now it's set up just to stride
over every grid, accumulating rays.  One could imagine inserting a
break in this for a specific object, but then you'd need to add on the
appropriate culling and so on.

More easily you could use a particle deposition mechanism, like the
CIC_Deposit, for the particles.  Unfortunately you can't define a
radius for this, but it might work for relatively large numbers of
particles ... but I'm not sure that's the domain you're interested in.
   For only a few particles, it will not look very good is my guess.
The way the fields are set up, you could have this be a field table
that is updated along with the others, and it could be an additive
process.

So I guess ... right now particle rendering probably won't work with
the software volume renderer in the way you describe without some
work.  But you can probably get something out of it.  I think the best
bet for this kind of thing is some kind of compositing mechanism,
which is typically easier to implement in hardware or OpenGL...

Although, actually, if you're willing to muck about with the field
data (like you mentioned above) you could define a new field that just
sets its scale to the distance from any particle.  In the limit of
relatively few particles, you could define this with a derived field
that simply iterates over the list and takes the max.  Which I guess
is what you proposed initially!

Maybe something like:

def _ParticleSpheres(field, data):
    tr = na.ones(data["Ones"].shape)
    for particle in some_list_of_particles:
        my_radius = ...
        tr += my_radius * some_function
    return tr

Or something?  I'm not sure the right way to get it out of this.  But
then you could add an isocontour at the value of some_function at the
distance you want.

Anyway, sorry for the speculative email, but I hope it's been at least
a little helpful!

-Matt



More information about the yt-users mailing list