Camera Projection Rendering
June 12th, 2007 by Helge MatheeWhen 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.

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.

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.

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.

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.

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.

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

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.

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.

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

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.

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.

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.





June 12th, 2007 at 5:54 am
Nice one Helge really useful thx.
June 12th, 2007 at 7:52 am
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.
June 12th, 2007 at 10:42 am
This is fantastic, Helge! Basic stuff that goes a really long way.
-T
June 12th, 2007 at 2:03 pm
Added version 1.3. Includes a texture repeat control as well as U and V based blending.
June 12th, 2007 at 3:50 pm
thanks a lot…
that will come in very handy in many situations…
does it work in 64 bit version?
June 12th, 2007 at 5:31 pm
Nice Helge! You always have the best toys.
June 12th, 2007 at 5:42 pm
For some reason i cant see the last 4 images. Would it be a problem with my sys?
June 12th, 2007 at 8:01 pm
thanks for sharing helge…
i am missing some images also, bullit