---
title: "Beauty, Masks and Utilities"
canonical: "https://documentation.chaos.com/space/APPSDK/132874527/Beauty%2C%20Masks%20and%20Utilities"
format: markdown
---
## **Overview**

---

<details>
<summary>Python</summary>

```python
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'
# }
```
</details>

<details>
<summary>C++</summary>

```c++
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)
*/
```
</details>

<details>
<summary>C#.NET</summary>

```csharp
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
*/
```
</details>

<details>
<summary>Node.js</summary>

```javascript
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 } 
*/
```
</details>

## **Basic Render Elements**

---

### Diffuse

---

---

---

### **Alpha**

---

> ⚠️ When using transparent materials such as glass, make sure that the material is set up to treat the material as transparent with regard to the Alpha channel. For example, when using VRayMtl as the material, set the *Affect channels* parameter for Reflection (reflect_affect_alpha) and Refraction (refract_affect_alpha) to *Color+alpha* or *All channels*. Otherwise, the transparent surface will not be treated as transparent in the Alpha Render Element.

## **Atmosphere**

---

## **Background**

---

> ⚠️ When the background is behind a transparent or semi-transparent material such as glass or clear plastic, make sure the Alpha channel is enabled for the material for all render elements; otherwise, the background is not visible in the render element. For example, when using VRayMtl for a glass material, set the *Affect channels* parameter for both Reflection and Refraction to *All channels* to cause the background to appear in the Background Render Element behind the glass.

## **Caustics**

---

## **Self Illumination**

---

---

---

## **Subsurface Scattering**

---

## **Beauty Render Elements**

---

### Back to Beauty Compositing

### Advanced Back to Beauty

## **Global Illumination Render Elements**

---

#### Overview

- **Global Illumination Render Element** (VRayGlobalIllumination) - Stores the diffuse surface global illumination in a scene when Indirect Illumination is enabled. This pass is already attenuated by the diffuse contribution in the scene and can be used directly in the composite.
- **Raw Global Illumination Render Element **(VRayRawGlobalIlumination) - Stores the raw information for the indirect lighting information calculated in the scene, untouched by the diffuse contribution. This pass is used to fine-tune the GI in a scene before attenuating it with the diffuse contributions of the scene.

`Raw Global Illumination x Diffuse Filter = Global Illumination
`

#### Examples

> ⚠️ When Raw Global Illumination is needed in the composite, please also render the Global Illumination element (VRayGlobalIllumination) and the Raw GI element (VRayRawGlobalIlumination).

### Global Illumination

---

### Raw Global Illumination

---

## **Lighting Render Elements**

---

> ℹ️ - Lighting can be added or subtracted at a composite level using Lighting Render Elements.
> ℹ️ - Lighting can be color corrected.
> ℹ️ - When using Light Select, lights can be turned on and off at a composite level without rerendering.

### Lighting

---

### Light Select

---

Type: **RenderChannelLightSelect**

The Light Select Render Element represents the lighting contribution from one or more selected lights in the scene. Each Light Select channel can output selected lights' raw, diffuse, or specular contributions to the illumination or overall (normal) contribution. When multiple lights are selected, all the contributions from the selected lights are combined into a single render element. Multiple Light Select elements can be rendered for a single scene, and lights may be included in more than one Light Select element.

This element is similar to the Lighting Render Element. However, the Lighting element combines the effect of all lights in the scene, while the Light Select element allows for a user-selection light or set of lights to be broken out, showing their own individual effect(s) on the scene's illumination. Using these render elements, specific lights in the resulting render can be adjusted (color, temperature, brightness, etc.) in a composite without rerendering.

For example, by generating a Light Select element for all of the backlights in a scene, an artist may adjust the backlighting of the rendered scene easily in the composite without affecting the rest of the scene's illumination.

The following diagram shows the compositing formula to recreate all the light in a scene in its most basic form, but only when each light is accounted for in exactly one Light Select element for a particular mode. If a particular light is used in more than one Light Select element, this equation will result in brighter lighting than intended because that light will contribute to lighting more than once.


![image](media://66805d01-76ec-4048-bd65-3cf2af7c2ee1)

### Shadow Select

---

#### Example: Shadow Select

![image](media://769c8dcf-1022-4d27-b1f7-a68b29672b2e)

---

#### Example: Matte Objects Only

![image](media://afabcd51-d47c-46fe-bb76-b193211cda3a)


### Raw Lighting

---


### Total Lighting

---

`Raw Total Lighting x Diffuse Filter = Total Lighting`

### Raw Total Lighting

---

---

`Raw Lighting + Raw Global Illumination = Raw Total Lighting`

## **Reflection Render Elements**

---

> ℹ️ Reflection render elements can be added and subtracted from existing reflections within the scene. * To enable changes to the reflectivity of specific objects or materials during the compositing phase, use Matte Render Elements to isolate and select the objects and materials.

### Reflection

---

---

`Raw Reflection x Reflection Filter = Reflection `

### Raw Reflection

---

---

### Reflection Filter

---

---

### Reflection Glossiness

---

### Reflection Index

---

### Reflection Highlight Glossiness

---

## **Refraction Render Elements**

---

- **Refraction** – This element is a key component in the main Beauty Pass. It displays the proper refraction according to the values set in the material. It is easy to adjust this element for brightness, coloration, etc., of the refractions in your scene without the need to rerender. This element is often used by itself but can be further controlled by the other two refraction elements listed below.
- **Raw Refraction** – This element is a key component of the Refraction Render Element and contains the pure surface refraction before it is multiplied by the refraction filter color. This element must be multiplied by the Refraction Filter for proper refraction in the final composite as intended for the material.
- **Refraction Filter** – This element is a key component of the Refraction Render Element. The refraction filter properly attenuates the amount of refraction a surface is designed to have by virtue of the Refraction Amount parameter set for its material. The refraction filter must be multiplied by the raw refraction in the composite.
- **Refraction Glossiness **– Returns a float value that corresponds with the Reflection Glossiness value of an object's material.

### Notes

### Refraction

---

---

`Raw Refraction x Refraction Filter = Refraction`

### Raw Refraction

---

### Refraction Filter

---

> ⚠️ To properly calculate the refraction information in the Refraction Filter and Raw Refraction Render Elements, the Refraction Render Element must also be rendered simultaneously, even if it's not going to be used in the compositing process. Doing so enables the rendering calculations to include all the refraction information.

### Refraction Glossiness

---

## **Specular**

---

### Evaluating the Specular Render Element

### Underlying Compositing Formula

### **Parameters**

- **enableDeepOutput **– (Boolean) Specifies whether to include this render element in deep images. The default value is 1.
- **name **– (String) Displays the name of this render channel. The default value is ColorChannel.
- **alias **– (Int) An internal unique identifier for this channel type.
- **color_mapping** – (Boolean) True to apply color mapping to the channel; false otherwise.
- **consider_for_aa** – (Boolean) True to consider this render element for anti-aliasing (may slow down rendering).
- **filtering **– (Boolean) Whether the image filter is applied to this channel.
- **derive_raw_channels** – (Boolean) True if raw channels should be derived from the respective color and filter channel.
- **vfb_color_corrections **– (Boolean) False to disable ALL VFB color corrections(sRGB, curves, white balance, etc...) when saving the channel data to a file or showing it on a display. True to apply VFB color corrections when saving the channel data to a file or showing it on a display. If true, some color corrections might still be disabled, based on the type of file being saved.
- **denoise **– (Boolean) True to denoise the channel; false otherwise.**enableDeepOutput **– (Boolean) Specifies whether to include this render element in deep images. The default value is 1.
- **name **– (String) Displays the name of this render channel. The default value is ColorChannel.
- **alias **– (Int) An internal unique identifier for this channel type.
- **color_mapping** – (Boolean) True to apply color mapping to the channel; false otherwise.
- **consider_for_aa** – (Boolean) True to consider this render element for anti-aliasing (may slow down rendering).
- **filtering **– (Boolean) Whether the image filter is applied to this channel.
- **derive_raw_channels** – (Boolean) True if raw channels should be derived from the respective color and filter channel.
- **vfb_color_corrections **– (Boolean) False to disable ALL VFB color corrections(sRGB, curves, white balance, etc...) when saving the channel data to a file or showing it on a display. True to apply VFB color corrections when saving the channel data to a file or showing it on a display. If true, some color corrections might still be disabled, based on the type of file being saved.
- **denoise **– (Boolean) True to denoise the channel; false otherwise.

### Examples

### **Code example**


<details>
<summary>Python</summary>

```python
# Compatibility with Python 2.7.
from __future__ import print_function
 
# The directory containing the vray shared object should be present in the PYTHONPATH environment variable.
# Try to import the vray module from VRAY_SDK/python, if it is not in PYTHONPATH
import sys, os
VRAY_SDK = os.environ.get('VRAY_SDK')
if VRAY_SDK:
    sys.path.append(os.path.join(VRAY_SDK, 'python'))
import vray
 
SCENE_PATH = os.path.join(os.environ.get('VRAY_SDK'), 'scenes')
# Change the process working directory to SCENE_PATH in order to be able to load relative scene resources.
os.chdir(SCENE_PATH)
 
def addExampleRenderElements(renderer):
    reManager = renderer.renderElements
    # In Python and JS we use strings:
    print('All render element (channel) identifiers:')
    print(reManager.getAvailableTypes())
    # The RGB channel is always present. It is often referred to as "Beauty" by compositors
    # Alpha is also always included
    # --- BEAUTY ELEMENTS ---
    # "Beauty" elements are the components that make up the main RGB channel,
    # such as direct and indirect lighting, specular and diffuse contributions and so on.
    # Light bounced from diffuse materials (layers)
    reManager.add('diffuse')
    # Light from glossy reflections
    reManager.add('reflection')
    # Refracted light
    reManager.add('refraction')
    # Light from perfect mirror reflections
    reManager.add('specular')
    # Subsurface scattered light
    reManager.add('sss')
    # Light from self-illuimnating materials
    reManager.add('self_illumination')
    # Global illumination, indirect lighting
    reManager.add('gi')
    # Direct lighting
    reManager.add('lighting')
    # Sum of all lighting
    reManager.add('total_light')
    # Shadows, combined with diffuse. Shadowed areas are brighter
    reManager.add('shadow')
    # Reflected light if surfaces were fully reflective
    reManager.add('raw_reflection')
    # Refracted light if surfaces were fully refractive
    reManager.add('raw_refraction')
    # Attenuation factor for reflections. Refl = ReflFilter * RawRefl
    reManager.add('reflection_filter')
    # Attenuation factor for refractions. Refr = RefrFilter * RawRefr
    reManager.add('refraction_filter')
    # Intensity of GI before multiplication with the diffuse filter
    reManager.add('raw_gi')
    # Direct lighting without diffuse color
    reManager.add('raw_light')
    # Sum light without diffuse color
    reManager.add('raw_total_light')
    # Shadows without the diffuse factor
    reManager.add('raw_shadow')
    # Grayscale material glossiness values
    reManager.add('reflection_glossiness')
    # Glossiness for highlights only
    reManager.add('reflection_hilight_glossiness')
    # --- MATTE ELEMENTS ---
    # Matte elements are used for masking out parts of the frame when compositing.
    # Color is based on material ID, see MtlMaterialID plugin
    reManager.add('material_id')
    # Color is based on the objectID of each Node
    reManager.add('node_id')
    # --- GEOMETRIC ELEMENTS ---
    # Geometric data such as normals and depth has various applications
    # in compositing and post-processing.
    # The pure geometric normals, encoded as R=X, G=Y, B=Z
    reManager.add('normals')
    # Normals after bump mapping
    reManager.add('bump_normals')
    # Normalized grayscale depth buffer
    reManager.add('z_depth')
    # The per-frame velocity of moving objects
    reManager.add('velocity')
 
# Create an instance of VRayRenderer for production render mode. The renderer is automatically closed after the `with` block.
with vray.VRayRenderer() as renderer:
    renderer.renderMode = 'production'
     # Register a simple log callback. Always useful for debugging.
    def dumpMsg(renderer, message, level, instant):
        if level == vray.LOGLEVEL_ERROR:
            print("[ERROR]", message)
        elif level == vray.LOGLEVEL_WARNING:
            print("[Warning]", message)
        elif level == vray.LOGLEVEL_INFO:
            print("[info]", message)
        # Uncomment for testing, but you might want to ignore these in real code
        #else: print("[debug]", message)
    renderer.setOnLogMessage(dumpMsg)
    # Load scene from a file.
    renderer.load(os.path.join(SCENE_PATH, 'cornell_new.vrscene'))
    # Resize *after* loading the scene
    renderer.size = (320, 200)   
    # This will add the necessary channel plugins to the scene
    addExampleRenderElements(renderer)
    # Start rendering.
    renderer.startSync()
    # Render elements are available when the first bucket region is ready
    # Here, we simply wait for the entire image to be completed before we access the render elements
    renderer.waitForRenderEnd()
    # Access render elements via the VRayRenderer instance
    allRenderElements = renderer.renderElements.getAll()
    # List all available render elements and process each one
    for re in allRenderElements:
        print ('{0}. {1}, Format({2}), PixelFormat({3})'.format(re.type, re.name, re.binaryFormat, re.defaultPixelFormat))
        # Output render element's data as an image
        # Optionally, specify an image sub-region, or leave blank to get the entire image
        img = re.getImage()
        img.save(re.name + ".png")
        # Similar to the image output, get the raw bytes
        # Again, a sub-region can be specified, or the entire data can be obtained if left blank
        rawData = re.getData()
        # Do something with rawData...
```
</details>

<details>
<summary>C++</summary>

```c++
#define VRAY_RUNTIME_LOAD_PRIMARY
#include "vraysdk.hpp"
#include "vrayplugins.hpp"
#include "utils.h"

using namespace VRay;
using namespace VRay::Plugins;
using namespace std;

const char *BASE_PATH = getenv("VRAY_SDK");
string SCENE_PATH = (BASE_PATH ? string(BASE_PATH) : string(".")) + PATH_DELIMITER + "scenes";

void addExampleRenderElements(VRayRenderer &renderer) {
	RenderElements reManager = renderer.getRenderElements();
	// The RGB channel is always present. It is often referred to as "Beauty" by compositors
	// Alpha is also always included
	// Beauty Elements
	// Light bounced from diffuse materials (layers)
	reManager.add(RenderElement::DIFFUSE, NULL, NULL);
	// Light from glossy reflections
	reManager.add(RenderElement::REFLECT, NULL, NULL);
	// Refracted light
	reManager.add(RenderElement::REFRACT, NULL, NULL);
	// Light from perfect mirror reflections
	reManager.add(RenderElement::SPECULAR, NULL, NULL);
	// Subsurface scattered light
	reManager.add(RenderElement::SSS, NULL, NULL);
	// Light from self-illuminating materials
	reManager.add(RenderElement::SELFILLUM, NULL, NULL);
	// Global illumination, indirect lighting
	reManager.add(RenderElement::GI, NULL, NULL);
	// Direct lighting
	reManager.add(RenderElement::LIGHTING, NULL, NULL);
	// Sum of all lighting
	reManager.add(RenderElement::TOTALLIGHT, NULL, NULL);
	// Shadows, combined with diffuse. Shadowed areas are brighter
	reManager.add(RenderElement::SHADOW, NULL, NULL);
	// Reflected light if surfaces were fully reflective
	reManager.add(RenderElement::RAW_REFLECTION, NULL, NULL);
	// Refracted light if surfaces were fully refractive
	reManager.add(RenderElement::RAW_REFRACTION, NULL, NULL);
	// Attenuation factor for reflections. Refl = ReflFilter * RawRefl
	reManager.add(RenderElement::REFLECTION_FILTER, NULL, NULL);
	// Attenuation factor for refractions. Refr = RefrFilter * RawRefr
	reManager.add(RenderElement::REFRACTION_FILTER, NULL, NULL);
	// Intensity of GI before multiplication with the diffuse filter
	reManager.add(RenderElement::RAWGI, NULL, NULL);
	// Direct lighting without diffuse color
	reManager.add(RenderElement::RAWLIGHT, NULL, NULL);
	// Sum light without diffuse color
	reManager.add(RenderElement::RAWTOTALLIGHT, NULL, NULL);
	// Shadows without the diffuse factor
	reManager.add(RenderElement::RAWSHADOW, NULL, NULL);
	// Grayscale material glossiness values
	reManager.add(RenderElement::VRMTL_REFLECTGLOSS, NULL, NULL);
	// Glossiness for highlights only
	reManager.add(RenderElement::VRMTL_REFLECTHIGLOSS, NULL, NULL);
	// Matte elements
	// Color is based on material ID, see MtlMaterialID plugin
	reManager.add(RenderElement::MTLID, NULL, NULL);
	// Color is based on the objectID of each Node
	reManager.add(RenderElement::NODEID, NULL, NULL);
	// Geometric elements
	// The pure geometric normals, encoded as R=X, G=Y, B=Z
	reManager.add(RenderElement::NORMALS, NULL, NULL);
	// Normals after bump mapping
	reManager.add(RenderElement::BUMPNORMALS, NULL, NULL);
	// Normalized grayscale depth buffer
	reManager.add(RenderElement::ZDEPTH, NULL, NULL);
	// The per-frame velocity of moving objects
	reManager.add(RenderElement::VELOCITY, NULL, NULL);
}

int main() {
	// Change process working directory to SCENE_PATH to be able to load relative scene resources.
	changeCurrentDir(SCENE_PATH.c_str());
	// Load V-Ray SDK library.
	VRayInit init(NULL, true);
	// Create an instance of VRayRenderer for production render mode.
	// The renderer is automatically closed at the end of the current scope.
	VRayRenderer renderer;
	renderer.setRenderMode(VRayRenderer::RENDER_MODE_PRODUCTION);
	// It's recommended to always have a console log
	renderer.setOnLogMessage(logMessage);
	// Load scene from a file.
	renderer.load("cornell_new.vrscene");
	// Resize *after* loading the scene.
	renderer.setImageSize(320, 200);
	// This will add the necessary channel plugins to the scene
	addExampleRenderElements(renderer);
	// Start rendering.
	renderer.startSync();
	// Render elements are available when the first bucket region is ready
	// Here, we simply wait for the entire image to be completed before we access the render elements
	renderer.waitForRenderEnd();
	// Access render elements via the VRayRenderer instance
	std::vector<RenderElement> allRenderElements = renderer.getRenderElements().getAll(RenderElement::Type::NONE);
	// List all available render elements and process each one
	for (const RenderElement& re: allRenderElements) {
		printf("%d. %s, Format(%d), PixelFormat(%d)\
", re.getType(), re.getName().c_str(), re.getBinaryFormat(), re.getDefaultPixelFormat());
		// Output render the element's data as an image
		// Optionally, specify an image sub-region or leave blank to get the entire image
		LocalVRayImage img = re.getImage();
		img->saveToPng(re.getName() + ".png");
		// Similar to the image output, get the raw bytes
		// Again, a sub-region can be specified, or the entire data can be obtained if left blank
		void* data = NULL;
		RenderElement::GetDataOptions options;
		if (size_t dataSize = re.getData(&data, options)) {
			ofstream datFile(re.getName() + ".dat", ios::out | ios::binary);
			datFile.write(reinterpret_cast<const char*>(data), dataSize);
			datFile.close();
			RenderElement::releaseData(data);
		}
	}
	return 0;
}
```
</details>

<details>
<summary>C#.NET</summary>

```csharp
using System;
using System.IO;
using System.Collections.Generic;
using VRay;
using VRay.Plugins;

namespace _render_elements
{
	class Program
	{
		private static void addExampleRenderElements(VRayRenderer renderer)
		{
			RenderElements reManager = renderer.RenderElements;
			/// --- "BEAUTY" ELEMENTS --- ///
			/// "Beauty" elements are the components that make up the main RGB channel,
			/// such as direct and indirect lighting, specular and diffuse contributions, and so on.
			// The RGB channel is always present. It is often referred to as "Beauty" by compositors
			// Alpha is also always included
			// Light bounced from diffuse materials (layers)
			reManager.Add(RenderElementType.DIFFUSE, "", "");
			// Light from glossy reflections
			reManager.Add(RenderElementType.REFLECT, "", "");
			// Refracted light
			reManager.Add(RenderElementType.REFRACT, "", "");
			// Light from perfect mirror reflections
			reManager.Add(RenderElementType.SPECULAR, "", "");
			// Subsurface scattered light
			reManager.Add(RenderElementType.SSS, "", "");
			// Light from self-illuminating materials
			reManager.Add(RenderElementType.SELFILLUM, "", "");
			// Global illumination, indirect lighting
			reManager.Add(RenderElementType.GI, "", "");
			// Direct lighting
			reManager.Add(RenderElementType.LIGHTING, "", "");
			// Sum of all lighting
			reManager.Add(RenderElementType.TOTALLIGHT, "", "");
			// Shadows, combined with diffuse. Shadowed areas are brighter
			reManager.Add(RenderElementType.SHADOW, "", "");
			// Reflected light if surfaces were fully reflective
			reManager.Add(RenderElementType.RAW_REFLECTION, "", "");
			// Refracted light if surfaces were fully refractive
			reManager.Add(RenderElementType.RAW_REFRACTION, "", "");
			// Attenuation factor for reflections. Refl = ReflFilter * RawRefl
			reManager.Add(RenderElementType.REFLECTION_FILTER, "", "");
			// Attenuation factor for refractions. Refr = RefrFilter * RawRefr
			reManager.Add(RenderElementType.REFRACTION_FILTER, "", "");
			// Intensity of GI before multiplication with the diffuse filter
			reManager.Add(RenderElementType.RAWGI, "", "");
			// Direct lighting without diffuse color
			reManager.Add(RenderElementType.RAWLIGHT, "", "");
			// Sum light without diffuse color
			reManager.Add(RenderElementType.RAWTOTALLIGHT, "", "");
			// Shadows without the diffuse factor
			reManager.Add(RenderElementType.RAWSHADOW, "", "");
			// Grayscale material glossiness values
			reManager.Add(RenderElementType.VRMTL_REFLECTGLOSS, "", "");
			// Glossiness for highlights only
			reManager.Add(RenderElementType.VRMTL_REFLECTHIGLOSS, "", "");
			/// --- MATTE ELEMENTS --- ///
			/// Matte elements are used for masking out parts of the frame when compositing.
			// Color is based on material ID, see MtlMaterialID plugin
			reManager.Add(RenderElementType.MTLID, "", "");
			// Color is based on the objectID of each Node
			reManager.Add(RenderElementType.NODEID, "", "");
			/// --- GEOMETRIC ELEMENTS --- ///
			/// Geometric data such as normals and depth has various applications in compositing and post-processing.
			// The pure geometric normals, encoded as R=X, G=Y, B=Z
			reManager.Add(RenderElementType.NORMALS, "", "");
			// Normals after bump mapping
			reManager.Add(RenderElementType.BUMPNORMALS, "", "");
			// Normalized grayscale depth buffer
			reManager.Add(RenderElementType.ZDEPTH, "", "");
			// The per-frame velocity of moving objects
			reManager.Add(RenderElementType.VELOCITY, "", "");
		}

		static void Main(string[] args)
		{
			string SCENE_PATH = Path.Combine(Environment.GetEnvironmentVariable("VRAY_SDK"), "scenes");
			// Change process working directory to SCENE_PATH to be able to load relative scene resources.
			Directory.SetCurrentDirectory(SCENE_PATH);
			// Create an instance of VRayRenderer for production render mode. The renderer is automatically closed after the `using` block.
			using (VRayRenderer renderer = new VRayRenderer())
			{
				renderer.RenderMode = RenderMode.PRODUCTION;
				// Add a listener for any type of log message.
				renderer.LogMessage += new EventHandler<MessageEventArgs>((source, e) =>
				{
					// You can remove the if for testing, but you might want to ignore Debug in actual code
					if (e.LogLevel != LogLevelType.Debug)
					{
						Console.WriteLine(String.Format("[{0}] {1}", e.LogLevel.ToString(), e.Message));
					}
				});
				// Load scene from a file.
				renderer.Load("cornell_new.vrscene");
				// Resize *after* loading the scene.
				renderer.SetImageSize(320, 200);
				// This will add the necessary channel plugins to the scene
				addExampleRenderElements(renderer);
				// Start rendering.
				renderer.StartSync();
				// Render elements are available when the first bucket region is ready
				// Here, we simply wait for the entire image to be completed before we access the render elements
				renderer.WaitForRenderEnd();
				// Access render elements via the VRayRenderer instance
				IEnumerable<RenderElement> allRenderElements = renderer.RenderElements.GetAll(RenderElementType.NONE);
				// List all available render elements and process each one
				foreach (RenderElement re in allRenderElements)
				{
					Console.WriteLine("{0}. {1}, Format({2}), PixelFormat({3})\
", re.Type, re.Name, re.BinaryFormat, re.DefaultPixelFormat);
					// Output render the element's data as an image
					// Optionally, specify an image sub-region or leave blank to get the entire image
					VRayImage img = re.GetImage();
					img.SaveToPNG(re.Name + ".png");
					// Similar to the image output, get the raw bytes
					// Again, a sub-region can be specified, or the entire data can be obtained if left blank
					RenderElement.GetDataOptions options = new RenderElement.GetDataOptions();
					byte[] rawData = re.GetData(options);
					// Do something with rawData...
				}
			}
		}
	}
}
```
</details>

<details>
<summary>Node.js</summary>

```javascript
var path = require('path');
var vray = require(path.join(process.env.VRAY_SDK, 'node', 'vray'));
 
var SCENE_PATH = path.join(process.env.VRAY_SDK, 'scenes');
// Change process working directory to SCENE_PATHtoo be able to load relative scene resources.
process.chdir(SCENE_PATH);
 
var addExampleRenderElements = function(renderer) {
	var reManager = renderer.renderElements;
	// In Python and JS, we use strings:
	console.log('All render element (channel) identifiers:');
	console.log(reManager.getAvailableTypes());
	// The RGB channel is always present. It is often referred to as "Beauty" by compositors
	// Alpha is also always included
	// --- BEAUTY ELEMENTS ---
	// "Beauty" elements are the components that make up the main RGB channel,
	// such as direct and indirect lighting, specular and diffuse contribution, etc.
	// Light bounced from diffuse materials (layers);
	reManager.add('diffuse');
	// Light from glossy reflections
	reManager.add('reflection');
	// Refracted light
	reManager.add('refraction');
	// Light from perfect mirror reflections
	reManager.add('specular');
	// Subsurface scattered light
	reManager.add('sss');
	// Light from self-illuimnating materials
	reManager.add('self_illumination');
	// Global illumination, indirect lighting
	reManager.add('gi');
	// Direct lighting
	reManager.add('lighting');
	// Sum of all lighting
	reManager.add('total_light');
	// Shadows, combined with diffuse. Shadowed areas are brighter
	reManager.add('shadow');
	// Reflected light if surfaces were fully reflective
	reManager.add('raw_reflection');
	// Refracted light if surfaces were fully refractive
	reManager.add('raw_refraction');
	// Attenuation factor for reflections. Refl = ReflFilter * RawRefl
	reManager.add('reflection_filter');
	// Attenuation factor for refractions. Refr = RefrFilter * RawRefr
	reManager.add('refraction_filter');
	// Intensity of GI before multiplication with the diffuse filter
	reManager.add('raw_gi');
	// Direct lighting without diffuse color
	reManager.add('raw_light');
	// Sum light without diffuse color
	reManager.add('raw_total_light');
	// Shadows without the diffuse factor
	reManager.add('raw_shadow');
	// Grayscale material glossiness values
	reManager.add('reflection_glossiness');
	// Glossiness for highlights only
	reManager.add('reflection_hilight_glossiness');
	// --- MATTE ELEMENTS ---
	// Matte elements are used for masking out parts of the frame when compositing.
	// Color is based on material ID, see MtlMaterialID plugin
	reManager.add('material_id');
	// Color is based on the objectID of each Node
	reManager.add('node_id');
	// --- GEOMETRIC ELEMENTS ---
	// Geometric data such as normals and depth has various applications
	// in compositing and post-processing.
	// The pure geometric normals, encoded as R=X, G=Y, B=Z
	reManager.add('normals');
	// Normals after bump mapping
	reManager.add('bump_normals');
	// Normalized grayscale depth buffer
	reManager.add('z_depth');
	// The per-frame velocity of moving objects
	reManager.add('velocity');
}
 
// Create an instance of VRayRenderer for production render mode.
var renderer = vray.VRayRenderer();
renderer.renderMode = "production";
 // It's recommended to always have a console log callback
renderer.on("logMessage", function (message, level, instant) {
	if (level == vray.LOGLEVEL_ERROR)
		console.log("[ERROR] ", message);
	else if (level == vray.LOGLEVEL_WARNING)
		console.log("[Warning] ", message);
	else if (level == vray.LOGLEVEL_INFO)
		console.log("[info] ", message);
	// Uncomment for testing, but you might want to ignore these in real code
	//else console.log("[debug] ", message);
});
// Load scene from a file asynchronously.
renderer.load("cornell_new.vrscene", function(err) {
	if (err) throw err;
	// Resize *after* loading the scene.
	renderer.size = { width: 320, height: 200 };
	// This will add the necessary channel plugins to the scene
	addExampleRenderElements(renderer);
	// Start rendering.
	renderer.startSync();
	// Render elements are available when the first bucket region is ready
	// Here, we simply wait for the entire image to be completed before we access the render elements
	renderer.waitForRenderEnd(function() {
		// Access render elements via the VRayRenderer instance
		var allRenderElements = renderer.renderElements.getAll()
		// List all available render elements and process each one
		allRenderElements.forEach(function (re) {
			console.log(re.type + ". " + re.name + ", Format(" + re.binaryFormat + "), PixelFormat(" + re.defaultPixelFormat + ")");
			// Output render element's data as an image
			// Optionally, specify an image sub-region, or leave blank to get the entire image
			var img = re.getImage();
			img.saveSync(re.name + ".png");
			// Similar to the image output, get the raw bytes
			// Again, a sub-region can be specified, or the entire data can be obtained if left blank
			var rawData = re.getData();
			// Do something with rawData...
		});
		// Closes the renderer.
		renderer.close();
	});
});
```
</details>