LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

This version of Unity is unsupported.

Camera.RenderToCubemap

Switch to Manual
public method RenderToCubemap(cubemap: Cubemap, faceMask: int = 63): bool;

Parameters

cubemapThe cube map to render to.
faceMaskA bitmask which determines which of the six faces are rendered to.

Returns

bool False if rendering fails, else true.

Description

Render into a static cubemap from this camera.

This function is mostly useful in the editor for "baking" static cubemaps of your Scene. See wizard example below. If you want a realtime-updated cubemap, use RenderToCubemap variant that uses a RenderTexture with a cubemap dimension, see below.

Camera's position, clear flags and clipping plane distances will be used to render into cubemap faces. faceMask is a bitfield indicating which cubemap faces should be rendered into. Each bit that is set corresponds to a face. Bit numbers are integer values of CubemapFace enum. By default all six cubemap faces will be rendered (default value 63 has six lowest bits on).

This function will return false if rendering to cubemap fails. Some graphics hardware does not support the functionality.

Note also that ReflectionProbes are a more advanced way of performing realtime reflections. Cubemaps can be created in the editor by selecting the Create->Legacy option.

See Also: Cubemap assets, Reflective shaders.

no example available in JavaScript

public method RenderToCubemap(cubemap: RenderTexture, faceMask: int = 63): bool;

Parameters

faceMaskA bitfield indicating which cubemap faces should be rendered into.
cubemapThe texture to render to.

Returns

bool False if rendering fails, else true.

Description

Render into a cubemap from this camera.

This is used for real-time reflections into cubemap render textures. It can be quite expensive though, especially if all six cubemap faces are rendered each frame.

The Camera's position, clear flags and clipping plane distances will be used to render into cubemap faces. faceMask is a bitfield indicating which cubemap faces should be rendered into. Each bit that is set corresponds to a face. Bit numbers are integer values of CubemapFace enum. By default all six cubemap faces will be rendered (default value 63 has six lowest bits on).

This function will return false if rendering to cubemap fails. Some graphics hardware does not support the functionality.

Note that the RenderTexture must have RenderTexture.dimension set to TextureDimension.Cube. This is illustrated in the example following.

See Also: RenderTexture.isCubemap, Reflective shaders.

no example available in JavaScript

Parameters

cubemapThe texture to render to.
faceMaskA bitfield indicating which cubemap faces should be rendered into. Set to the integer value 63 to render all faces.
stereoEyeA Camera eye corresponding to the left or right eye for stereoscopic rendering, or neither for non-stereoscopic rendering.

Returns

void False if rendering fails, else true.

Description

Render one side of a stereoscopic 360-degree image into a cubemap from this camera.

Setting the stereoEye parameter to Camera.MonoOrStereoscopicEye.Left or Camera.MonoOrStereoscopicEye.Right renders the left or right eye point-of-view of a stereo 360 image with proper world space transform. Setting stereoEye to Camera.MonoOrStereoscopicEye.Mono renders a monoscopic view of the Scene. After rendering the separate left and right cubemaps, you can convert them into equirectangular panoramic images that occupy one texture.

When rendering either side of a stereoscopic view, the camera uses its stereoSeparation value as the inter-pupillary distance (IPD), unless VR Support is enabled. When using a VR camera, the VR device IPD overrides the stereoSeparation value.

Unity uses the Camera's position, clear flags and clipping plane distances to render into the cubemap faces. The camera is rotated for each face. faceMask is a bitfield indicating which cubemap faces should be rendered into. Each bit that is set corresponds to a face. Bit numbers are integer values of CubemapFace enum. For 360 stereo image capture, all six cubemap faces should be rendered (set facemask to 63).

This function will return false if rendering to the cubemap fails. Some graphics hardware does not support the functionality.

Note that the RenderTexture must have RenderTexture.dimension set to TextureDimension.Cube.

See Also: RenderTexture.isCubemap, Cubemap.

no example available in JavaScript