[Sidefx-houdini-list] baking coverage into point particles

Mark Elendt mark at sidefx.com
Thu Dec 10 12:08:19 EST 2009

On Thursday Dec 10 at 08:28, Michael K. O'Brien wrote:
> > Or do you need it geometrically?
> > If you have a DSM/DCM, you should be able to sample the data in a VEX
> > SOP.
> That sounds promising, I'll have to figure that out. I'm not really all that
> familar with Mantra. Are there any things I need to worry about?

The tricky thing will be to get the point into the space of the shadow
map.  Aside from that, the VEX code would be something like:

    bake_coverage(string map=""; export float coverage=0;
	    float spread=0, bias=0, quality=1)
	if (map != "")
	    vector	pp = transform_into_light_space(P);
	    vector	opacity;
	    opacity = shadowmap(map, pp, spread, bias, quality);
	    coverage = max(opacity);

If you have a deep camera map, you can get other variables out of the
map too (using the "channel" keyword argument to the shadowmap

The shadowmap call expects mantra NDC coordinates:
    P.x in (0, 1)
    P.y in (0, 1)
    P.z the z-distance from the light source
all in the space of the light.

You might be able to transform based on the Houdini light, or
alternatively, you can use teximport() to extract the projection
values out of the DSM.  I don't know of any code out there that does
the automatic transformation though.

> > There may be other solutions (with either VEX ray-intersection (yes
> > there is ray intersection in SOPs) or the Ray SOP).
> > 
> > How many points?
> 100k ish.

Mark Elendt

More information about the Sidefx-houdini-list mailing list