camera.rendertocubemap 渲染到立方图

2015-1-4 06:17| 发布者: 杨炎| 查看: 4220| 评论: 0|原作者: 蛮牛|来自: unity3d脚本manual

摘要: camera.rendertocubemap 渲染到立方图functionrendertocubemap(cubemap:cubemap,facemask: int = 63) : booldescription描述render into a cubemap from this camera.从这个相机渲染到一个立方贴图。this is mostly ...

camera.rendertocubemap 渲染到立方图

functionrendertocubemap(cubemap:cubemap,facemask: int = 63) : bool


render into a cubemap from this camera.


this is mostly useful in the editor for "baking" static cubemaps of your scene. see wizard example 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 ofcubemapfaceenum. 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: this is a unity pro feature.

注意:这是一个unity 专业版属性

// render scene from a given point into a static cube map.


// place this script in editor folder of your project.


// then use the cubemap with one of reflective shaders!

//然后用一个reflective shaders 来使用这个立方贴图

class rendercubemapwizard extends scriptablewizard {

var renderfromposition :transform;

var cubemap :cubemap;

function onwizardupdate () {

helpstring = "select transform to render from and cubemap to render into";

isvalid = (renderfromposition != null) && (cubemap != null);


function onwizardcreate () {

// create temporary camera for rendering


var go = newgameobject( "cubemapcamera", camera );

// place it on the object


go.transform.position = renderfromposition.position;

go.transform.rotation =quaternion.identity;

// render into cubemap

//渲染到立方贴图 cubemap );

// destroy temporary camera


destroyimmediate( go );


@menuitem("gameobject/render into cubemap")

static function rendercubemap () {


"render cubemap", "render!");