Camera Projection Rendering

June 12th, 2007 by Helge Mathee




When dealing with camera projections, which are very helpful for image based modeling, scene layout etc… you sometimes experience some limitations. The camera projection in XSI is not available as a sub-projection, neither can you limit the effect of the camera projection based on surface angle or distance. Another problem are quite weird looking stretches, if the angle of the surface becomes too steep.

After working on this for some time, I realized that those stretches cannot be avoided. I reimplemented the camera projection operator to get rid of them, but ended up with the same stretches and itches, but I found a workaround, which can be applied to image based modeling workflows, as well as mental ray rendering.

Also, of course, I will provide the result as a plugin.

Warning! A lot of images!

cam_proj_uv_01.jpg
The image above shows a default cube with a camera projection applied. As said before, you cannot limit the effect based on angle or distance. The method I propose supports both, as well as multiple camera.

cam_proj_uv_02.jpg
In this example I am using one camera, and limit the camera projection effect to an angle, so that only polygons facing the camera will get the camera space UVs.

cam_proj_uv_03.jpg
Another way of working with this projection, is to use multiple cameras driving one uv projection. This can be extremely helpful for image based modeling, as well as projection of multiple images when dealing with panoramas. You can limit the output of each camera in U and V, so that you can use stripe images, or cross images for example.

To apply the projection, just select the mesh and at least one camera (you can select up to eight cameras), and click the “camera projection” button on the ‘mt_camera_proj” toolbar provided with the addon.

cam_proj_uv_04.jpg
This image shows the distance based limiter in action. Basically, the angle isn’t limited, so all polygon receive UVs, but the distance of the projection is set to 8, so that only polygons in that distance are projected.

So far so good. We still end up with the strechtes though. This is due to triangulation and UV interpolation. There is also no difference in mental ray vs. real time rendering. The problems always show up.
cam_proj_shader_01.jpg

To get around this, the only way to improve accuracy while maintaining the same projection, is to add a shader, which will do the calculations all over again, without using the existing UVs. What’s really nice about this is, that the shader doesn’t actually require UVs, which makes it possible it to apply to groups, layers or even partitions for pass rendering.
cam_proj_shader_02.jpg

Here’s a rendertree showing the new shader in action. It requires an image, and outputs color.
cam_proj_shader_03.jpg

To enable multiple cameras for this use, the shader has all of the camera settings necessary, including field of view, aspect ratio, a position and rotation. Moreover, you can link all of the eight parameters to an existing camera by clicking the “Connect To Camera” button, and then pick a camera in the explorer.
cam_proj_shader_04.jpg
Furthermore there are settings for limits based on angle and distance, this time with a min and max, because, as we are looking at a shader, we can do smooth blends now. The parameter “layer_below” is used for the areas not covered by the projection, respectively for blending. This enables you to use multiple camera projections in a row, by plugging the previous one into the next one’s “layer_below” port.

cam_proj_shader_05.jpg
This image shows a camera projection render with angle based blending turned on.

cam_proj_shader_06.jpg
As we have all parameters of the shader as pluggable ports, you can use other shaders to drive parameters such as the angle limits for example. (pretty wild.. huh!)

Also, if you don’t want to camera-project an image, but a procedural shader, you can turn the “only_use_color” parameter on. In this mode the shader never pulls the texture, but outputs the calculated UV coordinates as a RGB encoded color.
cam_proj_shader_07.jpg

You can then use this color (after beeing converted to a vector) to drive any other texture generator (a ripple in this case). This makes it possible to camera project procedural textures at render time, without any UVs.
cam_proj_shader_08.jpg

The plugin can be found here:
MT_Camera_Proj_V1.4

The plugin contains a toolbar, the camera UV projection, as well as the projection shader (which is a texture shader).
Version 1.4 is motion blur capable.

This is applicable as well to panorama images, by overlaying multiple images….

so if you use a couple of cameras:

a shader setup like this:

you can turn a spherical geometry like this:

into a panorama like this (using 4 photographs):

Let me know of all of the cool stuff that comes out of this… I am pretty sure there are enough crazy people out there to come up with completely different uses for this! ;)

cheers.

8 Responses to “Camera Projection Rendering”

  1. Helli Says:

    Nice one Helge really useful thx.

  2. Helge Mathee Says:

    Oh forgot mention: You can use this shader as a depth blend + incidence as well, if you set it to “only_use_color” and convert the result to scalar.

  3. Todd Akita Says:

    This is fantastic, Helge! Basic stuff that goes a really long way.

    -T

  4. Helge Mathee Says:

    Added version 1.3. Includes a texture repeat control as well as U and V based blending.

  5. gumrah Says:

    thanks a lot…
    that will come in very handy in many situations…
    does it work in 64 bit version?

  6. Jason Dexter Says:

    Nice Helge! You always have the best toys.

  7. Bullit Says:

    For some reason i cant see the last 4 images. Would it be a problem with my sys?

  8. Steven Caron Says:

    thanks for sharing helge…

    i am missing some images also, bullit

Leave a Reply