- actualRenderingPath
- allCameras
- aspect
- backgroundColor
- cameraToWorldMatrix
- clearFlags
- CopyFrom
- cullingMask
- current
- depthTextureMode
- depth
- farClipPlane
- fieldOfView
- layerCullDistances
- main
- nearClipPlane
- OnPostRender
- OnPreCull
- OnPreRender
- OnRenderImage
- OnRenderObject
- OnWillRenderObject
- orthographicSize
- orthographic
- pixelHeight
- pixelRect
- pixelWidth
- projectionMatrix
- rect
- renderingPath
- RenderToCubemap
- RenderWithShader
- Render
- ResetAspect
- ResetProjectionMatrix
- ResetReplacementShader
- ResetWorldToCameraMatrix
- ScreenPointToRay
- ScreenToViewportPoint
- ScreenToWorldPoint
- SetReplacementShader
- targetTexture
- velocity
- ViewportPointToRay
- ViewportToScreenPoint
- ViewportToWorldPoint
- worldToCameraMatrix
- WorldToScreenPoint
- WorldToViewportPoint
Camera.RenderToCubemap 渲染到立方图
function RenderToCubemap (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 of CubemapFace enum. 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 = new GameObject( "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.<RenderCubemapWizard>(
"Render cubemap", "Render!");
}
}
•function RenderToCubemap (cubemap : RenderTexture, faceMask : int = 63) : bool
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.
这个用于实时反射到立方贴图渲染纹理。这是非常耗时的,尤其是所有六个立方贴图面在每一帧中都被渲染。
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).
相机的位置,清除标志和裁剪面距离将被使用来渲染到立方贴图表面,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 专业版属性
// Attach this script to an object that uses a Reflective shader.
// Realtime reflective cubemaps!
//附加这个脚本到使用了Reflective shader的物体上
//实时反射立方贴图
@script ExecuteInEditMode
var cubemapSize = 128;
var oneFacePerFrame = false;
private var cam : Camera;
private var rtex : RenderTexture;
function Start () {
// render all six faces at startup
//在启动时渲染所有六个面
UpdateCubemap( 63 );
}
function LateUpdate () {
if (oneFacePerFrame) {
var faceToRender = Time.frameCount % 6;
var faceMask = 1 << faceToRender;
UpdateCubemap (faceMask);
} else {
UpdateCubemap (63); // all six faces 所有六个面
}
}
function UpdateCubemap (faceMask : int) {
if (!cam) {
var go = new GameObject ("CubemapCamera", Camera);
go.hideFlags = HideFlags.HideAndDontSave;
go.transform.position = transform.position;
go.transform.rotation = Quaternion.identity;
cam = go.camera;
cam.farClipPlane = 100; // don't render very far into cubemap //不要渲染较远的部分
cam.enabled = false;
}
if (!rtex) {
rtex = new RenderTexture (cubemapSize, cubemapSize, 16);
rtex.isPowerOfTwo = true;
rtex.isCubemap = true;
rtex.hideFlags = HideFlags.HideAndDontSave;
renderer.sharedMaterial.SetTexture ("_Cube", rtex);
}
cam.transform.position = transform.position;
cam.RenderToCubemap (rtex, faceMask);
}
function OnDisable () {
DestroyImmediate (cam);
DestroyImmediate (rtex);
}