First, let's define some terms:
- Pass – A “once-over” on the rendering to produce a specific effect. You can think of a pass as a “sweep” through the image to do one specific thing.
- Render pass – A pass that renders the entire image and stores one or more scene elements, for example, just the lighting or reflections.
- Render Element – The results of a render pass that can be combined in a post-process to adjust the final image. It is a regular 2D image, where each pixel has RGB numerical values.
- Render Mask – It makes it easy to choose just a part of the image you'd like to rerender. It's more exact and offers more control than Render Region.
- Compositing – The combining and adjustment of render elements and/or other elements such as live footage or background plates.
- Beauty pass – The combining and editing of certain render elements to create a traditional rendered image.
- Multiple Matte Passes
- Unshaded solid color images with red, green, and blue colors.
- Each color allows control of the selected geometry or materials to which the color has been assigned.
- Ambient Occlusion Pass – A shading and rendering technique used to calculate how exposed each point in a scene is to ambient lighting.
- Z-Depth Pass – A black-and-white image that shades an object based on the distance from the camera.
The reasoning behind the compositing process is the following: for high-end work such as feature films, rendering straight out of the 3D modeling software/V-Ray may be insufficient to achieve the desired visual quality.
- Rendered image might need adjustment to match live-action lighting, color temperature, etc.
- The director might want to try different sky backgrounds, combinations of landscape elements, etc.
- Common adjustments include color correction, improvement of contrast, adding or enhancing Lens Effects.
- Making changes to render elements is faster and easier than re-rendering.
Compositing with render elements provides the solution.
- Render elements layered on top of one another to generate the final image.
- Render elements can be adjusted individually to produce a specific look.
Compositing of render elements is done in the VFB or outside the 3D modeling app/V-Ray in a compositing program.
- Software programs designed for compositing include After Effects, Nuke, Fusion, Photoshop.
- Render elements are exported from V-Ray and imported into compositing software.
In compositing, each render element is usually “added” or “multiplied” with previous layers.
- In compositing, black = 0 and white = 1
- Colored pixel + black pixel = no change
- Colored pixel + white pixel = brighter colored pixel (up to pure white pixel)
- Colored pixel x black pixel = black pixel
- Colored pixel x white pixel = no change
All Render Elements can be exported together in one multi-channel EXR file, or each Render Element can be rendered in its own image file for layering in compositing software. Here, we cover how to achieve these approaches programmatically.
Here's a list of the available render elements which V-Ray provides to the user:
Basic: Alpha, Diffuse
Beauty: Atmosphere, Background, Caustics, Global Illumination, Lighting, Reflection, Refraction, Specular, Subsurface Scattering, Self-Illumination
- Advanced: Shadows, Raw Shadow, Unclamped Color, Coat Filter, Coat Glossiness, Coat Reflection, Raw Coat Reflection, Lighting Analysis, Metalness, Render Time, Sheen Filter, Sheen Glossiness, Sheen Reflection, Raw Sheen Reflection, Toon, Toon Lighting, Toon Specular
Matte: Cryptomatte, Material ID, Material Select, Matte Shadow, Multimatte, MultiMatte ID, Object ID, Object Select, Render ID, Wire Color
Geometry: Bump Normals, Normals, Velocity, Z-Depth
Utility: Coverage, Distributed Render ID, Denoiser, Extra Texture, Illuminance, Sample Rate, Sampler Info, V-Ray Render Options
Here's a quick example of how render elements can be retrieved from the renderer
object. A more thorough example can be found on the Beauty page:
renderer.renderElements.getAll() # returns an array of render elements with the following structure: # { # 'name': 'shadow', # 'type': 'shadow', # 'binaryFormat': '3_floats', # 'defaultPixelFormat': '3x4_bytes_float_RGB', # 'pixelFormat': '3x4_bytes_float_RGB', # 'plugin': vrayRE_Shdow', # 'alphaChannelPlugin': 'Not set' # }
std::vector<RenderElement> REs = renderer.getRenderElements().getAll(RenderElement::SHADOW); for (auto re : REs) { void* data = NULL; cout << "Name: " << re.getName() << endl; cout << "Binary format: " << re.getBinaryFormat() << endl; cout << "Pixel format: " << re.getDefaultPixelFormat() << endl; cout << "Size of data: " << re.getData(&data) << endl; } /* sample output: Name: shadow Binary format: 3 (corresponds to BF_3FLOAT) Pixel format: 203 (corresponds to PF_RGB_FLOAT) Size of data: 9000000 (12 bytes x size in pixels) */
RenderElements REs = renderer.RenderElements; foreach(RenderElement re in REs.GetAll()) { Console.WriteLine("Name: " + re.Name); Console.WriteLine("Binary format: " + re.BinaryFormat); Console.WriteLine("Pixel format: " + re.DefaultPixelFormat); byte[] data = re.GetData(); Console.WriteLine("Size of data: " + data.Length); } /* sample output Name: shadow Binary format: FLOAT3 Pixel format: RGB_FLOAT Size of data: 9000000 */
renderer.renderElements.getAll(); /* returns an array of render elements with the following structure: RenderElement { name: 'shadow', type: 'shadow', binaryFormat: '3_floats', pixelFormat: '3x4_bytes_float_RGB', defaultPixelFormat: '3x4_bytes_float_RGB', rgbOrder: false, plugin: Plugin { _name: 'vrayRE_Shadow', _type: 'RenderChannelColor', name: 'shadow', alias: 105, color_mapping: 1, consider_for_aa: 0, filtering: 1, derive_raw_channels: 1, vfb_color_corrections: 1 } */