In today's quicktip tutorial, Pratik Gulati continues on from where he left off in his extremely popular Modeling from Photographic Reference post, and takes a look at how to setup camera projections in 3DsMax using the Camera Map Per Pixel shader. Let's take a look...
Create a model! We won't be discussing the modeling process here, as it's something I have already covered in my previous post. So at this point I'll assume that you have either completed my previous tutorial, or you can comfortably model from photographic reference. We'll now move on to discuss the shader, material and rendering setup.
For this tutorial I'll be using the setup below, which is very similar to that used in my previous tutorial (Premium subscribers can download the full scene file and follow along.) To produce the projection we'll be using the Camera Map Per Pixel shader. This shader lets you project an image through a scene camera onto the geometry to which the shader is applied, and it is incredibly useful for things such as matte painting. Whilst quick to setup and not without it's limitations, this technique is incredibly powerful and can garner incredible results with a minimum of fuss!
Press M on your keyboard to open up the Material Editor.
Click on the grey box next to Diffuse to open up the Material Map Browser.
Assign a Camera Map Per Pixelshader to the diffuse channel of the material as shown. The settings for the shader are explained below :
- Camera - This needs to be the static camera through which our texture will be projected. Click it once to turn it on, and then choose the camera from your scene by selecting it in a viewport. Once assigned, the camera's name appears on the button. This camera is then also used to render the Texture and ZBuffer Mask components detailed below.
- Texture - You can assign any kind of map to this channel, however typically this is where you put the file you want to project - in our case the background image we used to model the scene.
- ZBuffer Mask - You can remove certain areas of your model from the project in two ways. Here, you can assign an image file that contains Z-depth data which, when used with the ZFudge value, can 'crop' out parts of the projection based on their distance from the camera.
- Mask - The second method to remove areas from your projection is to use this mask channel. This uses a greyscale image in which the black areas of the mask create transparent pixels in your projection, white areas create opaque pixels, and gray areas are partially transparent dependant on the gray value itself.
- Remove Back Face Pixels - When on, this setting excludes faces from the projection if they point more than a certain angle away from the camera. The angle is defined by the Angle Threshold value, and this setting defaults to on.
Before applying our new material we have to select all of the polygonal objects in the scene that we wish to project onto, and Attach them together, creating a single object.
With our material applied the setup is now complete. The most important thing however is that you must not move the projection camera once it has been setup. If you move it, the image we're projecting will move with it, skewing and warping across the model's surface. The solution? Rename the cam to something like CAM_PROJECTION and then duplicate it, calling the duplicate something like CAM_ANIMATED. You can now very clearly see which cam is which, after which you can start to animate the position of the CAM_ANIMATED camera over time, and then render out either stills or animations such as the one previewed above.
Camera mapping in any application does have it's limitations - in this case we can only move and rotate our animated camera so far before we start to see the image seams, or a notable decline in image quality. The Camera Map Per Pixel shader itself does not handle the following situations :
- 1) Animated objects-The objects on which we are projecting should be still and not animating
- 2) The projection does not use UVW mapping.
- 3) Animated textures-we cant use animated textures in the scene
And that's it! I hope you enjoyed the tutorial and if you have any questions feel free to ask!