Camera

Unreal Experiment

Just a quick test scene in Unreal. It has no home, so I decided to let it live here. The camera gear was modelled by me years ago for the Sketchup Film and Stage release, I was really gratified to discover that all of those models I made are still in use and part of the collection of .skp files at 3D Warehouse.

Getting a camera position in Vex, using optransform and cracktransform

In an earlier post I used a very unwieldy approach to get the position of a null in vex. Since then I have used a method where an object_merge SOP is set to transform “into this object” and then a point function can easily read the first point in the null to arrive at a center position. The problem with this is that you are reading the icon geometry for the object and in the case of a null this is ok, but the camera icon has each point offset from it’s origin.

Enter optransform and cracktransform. The optransform function will let you set a path to the camera (or whatever else you may want to use) and then populates a matrix with the target’s transforms. You can then extract out the position as a vector using the cracktransform function… this function if pretty powerful and at first confusing but essentially it has a switch which let’s you specify the portion of the matrix you need.

In the example above I used these functions to get the camera position and then used that position to compute a direction in “camera space’ to allow a ray SOP to project scattered points onto an object as a camera projection. Sounds complex, but it’s not. Here’s the wrangle which uses optransform and cracktransform to get the camera position:

vector @cdir;
vector @raydir;
matrix camMatrix = optransform(chs("camera")); 
//get a matrix with the camera's transforms.
@cdir = cracktransform(0, 0, 0, {0,0,0}, camMatrix);
//extract out the camera position as a vector
@raydir = normalize(@P-@cdir);
//get a vector to project pointo from camera

Example – Camera Planes and Projections in ICE

Here’s a quick example of a number of handy tricks in ICE.

A compound I shared earlier on the softimage mailing list is used to create a grid of particles on a camera plane at a definable resolution, as if each particle was a pixel. The basic camera attributes like FOV etc are respected. This bit uses a little simple trig to identify the corners of the camera frustum at any distance from the camera, which can be incredibly useful. I’ll try to make some time to go over this in a future post.

A simple raycast is then used to project particles onto geometry and to color those particles based on the depth of the projection.

example_cameraDataInICE

A lot can be done with the (super) simple techniques in this scene, trust me. Perhaps the simplest and yet most useful is to cull particles outside the camera frustum prior to writing a cache – if you are dealing with a shot that has a locked down camera this can be used to reduce cache data by massive amounts. If you are dealing with a stereo production and have access to depth maps, you can use that information to cull particles which are “behind” footage elements, or even have particles react to the “surface” of footage elements. Very cool! Knowing where a particle or object is in camera “screen-space” is easy and has a lot of use, too.

File: Softimage 2013, ~2.5MBĀ example_cameraDataInICE