Render passes, or render elements, are the raw elements generated by the rendering engine and is composited together for you to the final output render. Some of these elements are Lighting, Shadows, Reflections, Specular and Global Illumination just to mention a few. We can extract and customize these elements and put everything together our self in most post-production softwares that supports compositing of layers. Going about it this way will give us much greater control over the look of the final result.
Now start up 3ds Max and open up the scene RenderPassesTutorial.max. Let's start by adding the render passes we want to extract, so open up the Render Setup dialog (F10), browse to the Render Elements tab and click Add...
You will get a list of all the available elements for the current renderer. Select the following elements and click OK; VRayDiffuseFilter, VRayExtraTex, VRayGlobalIllumination, VRayLighting, VRayMtlId, VRayObjectSelect, VRayReflection, VRayShadows, VRaySpecular and VRayZDepth. These are the ones we need to recreate the final render. Well... we don't actually need the MtlId and ZDepth for this, but it's nice in case we want to add more effects later on. As we're using V-Ray's inbuilt frame buffer, we don't need to enable any of the elements; they will still render out fine.
Let's now tweak the elements that will need some adjustments.
Select the VRayZDepth element and go down to the VRayZDepth parameters. Here you'll find two values, zdepth min and zdepth max. What ZDepth does is creating a grayscale image that represents an image’s depth information where white is closest to the camera and black farthest away. This is exactly what the zdepth min and max is for; defining what the nearest and farthest distance in our scene is.
To easiest find these values, select our camera and show the Environment Ranges. As you can see, some yellow planes appear on our camera. Adjust the near and far ranges till it covers about the entire visible scene. In this case the values 1100 near and 2700 far seem just about right. Copy the values into the zdepth min/max in the VRayZDepth parameters and disable the camera Environment Ranges again.
VRayExtraTex (Ambient Occlusion)
So we want a ambient occlusion (AO) pass, but V-Ray doesn't support extracting it as a element, so we're forced to use a different approach. Luckily, we have a map type which can render out AO and a render element which applies a map to every object in our scene. I'm talking about the VRayDirtmap and the VRayExtraTex element.
Select the VRayExtraTex element and open the Material Editor (M). Under the VRayExtraTex parameters, we'll find a texture slot. Drag and drop (or copy/paste) the pre-made AO map from the Material Editor to that slot as an instance.
At the bottom of the parameters list there's a button called Exclude... which will apply the map to every object in the scene excluding the ones we've selected here. It's a nice feature, but we won't really need it for this project.
VRayObjectSelect (Muzzle flash pass)
To create a glow effect to the muzzle flash and bullet trail effects, we'll need to somehow filter out those two objects alone in their own pass. We can achieve this with the VRayObjectSelectelement.
First we'll need to assign a unique Object Id to our effects, so bring up the Select From Scene dialog by pressing H and select the Muzzle Flashand Bullet Trailobjects (or just manually select from the viewport :P). Hit OK and set their Object Idin Object Propertiesto 2(2 is a unused id in our scene).
Once done with this, we have to go back to the Render Setup again and find our VRayObjectSelect element. Under the VRayObjectSelect parameters there is a field called object id. Type in the same id here as we gave the effects just a second ago (which is "2", in case you've already forgot it).
This element will render out every materials with the same material ID with a unique color. I.e. materials with id 1 will be completely red while materials with id 2 will be yellow. This is to differentiate the various objects in our scene. No tweaking necessary, all materials already have their own unique ID as that's not really part of the tutorial.
This will extract the basic unshaded diffuse color for all objects. No tweaking necessary.
This will extract illumination caused by indirect light (bounced light). No tweaking necessary.
This will extract illumination caused by light objects in our scene. No tweaking necessary.
This will extract the reflections on materials. No tweaking necessary.
This will extract scene shadows. Notice that shadows will be inverted (shadows are white). No tweaking necessary.
This will extract the specularity levels on materials. No tweaking necessary.
You can at any time make a quick render test by pressing F9. This will make 3ds Max render out the current frame without saving it. Since we are using the V-Ray frame buffer, we now have all render elements in one window which is way more organized than Max's default one window per element solution.
Before we start rendering out our passes, we have to define where we want to save the files. So open up the Render Setupdialog and browse to the V-Ray tab. Open up the V-Ray:: Frame buffer dropdown and enable render to V-Ray raw image file. Click the Browse... button and find/create a folder to save the image sequence in. Switch the save as typeto OpenEXR (*.exr) and hit Save.
The OpenEXR file format is a HDR image format developed by Industrial Light & Magic that can store a huge range of channels. This means we can store all our elements into one single image file (per frame) to keep everything clean.
Unless you want to make some additional changes to the render quality and resolution, we're now ready to start rendering. Do not check 3ds Max's default Render Outputoption. V-Ray will save everything to OpenEXR images so it's not needed and will only create unnecessary files.
Just ignore the warning and continue the render process.
After 3ds Max has finished rendering out our image sequence, let's fire up After Effects and import our files. Right-click the project files manager and import a new file.
Browse to the folder you put the render output to and select the first file in the sequence (<Name>0000.exr). Before you click open, make sure OpenEXR Sequence is checked to import all images in the sequence as a movie file.
Apply the imported sequence to the project by dragging and dropping it into the timeline, make 8 additional copies of the same layer and name them as following: (Ignore Inverted Alpha. That was an experiment on my end)
This is because the OpenEXR file holds all our render elements.
Now to extract those channels…
As you can see, all our elements are blended together in the EXR file. To extract channels from the source file we have to add the EXtractoR (EXR+extractor, get it?) effect to each layer and choose the RGBA (Red, Green, Blue, Alpha) channels we want. Effect → 3D Channel → EXtractoR
In the effect controls, click on the Channel Info (marked) to bring up the EXtractoR channel dialog and select the appropriate RGB channels for that layer. Leave Alpha as (copy). Repeat for all layers.
Ambient Occlusion and ZDepth are both grayscale. That means red, green and blue are identical, so use the same EXR channel for all three channels.
We now have to set the layers blending mode to make the elements blending together as we want.
This part is easier with the blending mode visible directly on the layer. If it's missing, you can turn it on by right-clicking the layer bar and enable Modes.
Finding the best mix of blending modes is pretty much just trial and error. You should try experimenting with different modes and layer orders to get the best result for your project.
Hint:Temporary turn off the Muzzle Flash and Background layer to see the effect.
Here's what I ended up with:
The [Background.psd] image is a simple background image I quickly made in Adobe Photoshop.
If you've followed my steps and added a background image, you will now have something similar to this:
It's time to finish our compositing by adding some effects to our layers.
Let's start with the Muzzle Flashlayer. As you can see, it's using the default EXR alpha channel for transparency. What we'll first need to do is removing the black areas, so right-click the layer and add the Luma Key effect.
It's a good idea to turn off the Background layer while you're working with the Muzzle Flash. This is to better see the effects.
What Luma Key does is removing the darkest or lightest parts of the layer, making it transparent to the layers below. Set the Key Type to Key Out Darkerand increase the Threshold until all that's left is the muzzle flash. Finally add a Gaussian Blur (Blur & Sharpen → Gaussian Blur) and a Glow (Stylize → Glow) effect to finalize the muzzle flash. Take a look at the image to see what values I'm using for each effect.
Now let's get back to the background layer. Because It's not taking use of any alpha channels, we need to give one to it. Add the Set Channels effect to it and set the Source Layer 4 to any layer based on the EXR file (I'm using the Diffuse Filter).
We're now using the EXR file's alpha channel as the background's alpha channel. But wait, the alpha should be inverted to work the way we want it to! There's no effect that'll simply do that for us, but luckily, there's an animation preset that does exactly what we want. Open up the animation presets browser.
You'll get a new window containing all the presets. Navigate to Image - Utilities → Invert Alpha.ffx and double-click it to add it to our layer.
Let's get over to the Shadows layer. Because shadows are inverted, we want to add a Invert (Channel → Invert) effect to make it blend properly with the Multiply blend mode.
This concludes this little tutorial.
Thank you for taking the time to read through it.
If you feel like adding more effects, color correction and such, feel free to experiment to get the best result.