用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:gl:gl.invertculling

GL.invertCulling 反转剔除

JavaScript ⇒ public static var invertCulling: bool;
C# ⇒ public static bool invertCulling;

Description 描述

Select whether to invert the backface culling (true) or not (false).

是否反转背面剔除(true或false)。

This flag can “flip” the culling mode of all rendered objects. Major use case: rendering reflections for mirrors, water etc. Since virtual camera for rendering the reflection is mirrored, the culling order has to be inverted. You can see how the Water script in Effects standard package does that.

这个标识可以翻转所有渲染对象的剔除模式。主要用途:用于渲染镜像反射,水等。因为相机渲染是镜像的,所以剔除顺序要反转下。你可以在standard package包参见Water脚本。

JavaScript:

#pragma strict
// When attached to the camera, this script
// will make all rendering be flipped "inside out",
// i.e. back faces of objects will be rendered instead
// of front faces.
@ExecuteInEditMode
public class ExampleScript {
	private var oldCulling;
	public function OnPreRender() {
		oldCulling = GL.invertCulling;
		GL.invertCulling = true;
	}
	public function OnPostRender() {
		GL.invertCulling = oldCulling;
	}
}

C#:

// When attached to the camera, this script
// will make all rendering be flipped "inside out",
// i.e. back faces of objects will be rendered instead
// of front faces.
using UnityEngine;
 
[ExecuteInEditMode]
public class ExampleScript : MonoBehaviour
{
	private bool oldCulling;
	public void OnPreRender()
	{
		oldCulling = GL.invertCulling;
		GL.invertCulling = true;
	}
	public void OnPostRender()
	{
		GL.invertCulling = oldCulling;
	}
}

GL

script/unityengine/classes/gl/gl.invertculling.txt · 最后更改: 2016/08/02 05:24 (外部编辑)