Point Position
Applications

Maya XGen

I worked on XGen for the first time during the development period of Angry Birds Blues, I was lucky to be able to build the grass for the show. XGen expression were used to achieve the look.
One very useful variable I like to use in the XGen expressions is $P (the surface point at which the primitive is being evaluated).
This can be used to create some interesting tool. For example, by knowing the position and radius of an object, we can create a spherical mask with this expression.

length($P - $locator_position) < $locator_radius;



We can build something more complex like creating a mask that fits the camera frustum.


Think of $P as world space which means it can be converted to camera space then screan space using some matrix formulas.
We can use the following to rotate $P (world space) so that it matches the camera rotation.

Translation is simply done by subtracting $P by the camera translation. Now we can give it a perspective that respects the camera FOV using this formula:


Python can be used to query info about any camera and pass to any XGen description using XGen API.



If we execute the python code every frame by passing them here:

We get this.



Note : XGen culling options are not being used here. This result is achieved by expressions only.

NUKE

Everything you've seen can be applied to any DCC that provide some representation of a coordinate space. This can be an image like a render of point poisition AOV.

This is a gizmo I built in Nuke that takes a render of point position AOV and convert it from world space to screen space just like I did with XGen except this time instead of create a frustum mask of black and white values, I created a gradient red and grean map (0 to 1) so that I can take advantage ot the STMap node in Nuke like I did with the speedline tool.

That allows us to project any image to our renders without the need to import the geos. all we need is a point position AOV and a camera.

This gizmo was used in Angry Birds Blues to project lights and shadows etc.
The applications are endless.