找回密碼
 注冊帳號

掃一掃,訪問微社區

camera.rendertocubemap 渲染到立方圖

2015-1-4 06:17| 發布者: 楊炎| 查看: 3752| 評論: 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

description描述

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).

相機的位置,清除標志和裁剪面距離將被使用來渲染到立方貼圖表面,facemask是一比特域,表示那個立方貼圖面應該被渲染,每個位對應于一個面。比特數是cubemapface枚舉的整型值。默認的所有六個立方貼圖面都被渲染(默認值63的低6位是打開的)。

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

如果渲染失敗這個函數將返回false,某些顯卡不支持這個函數。

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.

//放置這個腳本到工程的editor文件夾中

// 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

//渲染到立方貼圖

go.camera.rendertocubemap( cubemap );

// destroy temporary camera

//銷毀臨時相機

destroyimmediate( go );

}

@menuitem("gameobject/render into cubemap")

static function rendercubemap () {

scriptablewizard.displaywizard.(

"render cubemap", "render!");

}

}

相關閱讀

文章點評
相關文章
女校游泳队彩金