Version: 2017.3

BillboardAsset

class in UnityEngine

/

Hereda de:Object

Cambiar al Manual

Descripción

BillboardAsset describes how a billboard is rendered.

Billboards are a level-of-detail (LOD) method of drawing complicated 3D objects in a simpler manner if they are further away. Because the object is further away, there is often less requirement to draw the object at full detail due to its size on-screen and low likelihood of being a focal point in the Camera view. Instead, the object can be pre-rendered to a texture, and this texture used on a very simple Camera-facing Mesh of flat geometry (often simply a quadrilateral) known as a billboard. At great distances an object does not significantly change its orientation relative to the camera, so a billboard looks much like the object it represents from frame to frame, without having to be redrawn from the model. The BillboardAsset class allows the creation of billboards that are rendered from several directions, allowing a BillboardAsset to efficiently represent an object at low level of detail from any approximately-horizontal viewpoint.

A BillboardAsset is usually created by importing SpeedTree assets. You can also create your own once you know how the billboard is described.

SpeedTree billboard geometry is usually more complex than a plain quadrilateral. By using more vertices to cut out the empty part of the billboard image, rendering performance can potentially be improved due to the graphics system not having to draw as many redundant transparent pixels. You have access to the geometry data via BillboardAsset.vertices and BillboardAsset.indices.

All vertices are considered in UV-space (see Fig. 1 below), because the geometry is due to be textured by the billboard images. UV vertices are easily expanded to 3D-space vertices by knowing the billboard's width, height, bottom, and what direction the billboard is currently facing. Assuming we have a billboard located at (0,0,0) looking at negative Z axis, the 3D-space coordinates are calculated as:

X = (u - 0.5) * width
Y = v * height + bottom
Z = 0

Figure 1: How UV vertices are expanded to 3D vertices

In order to display something similar to the real 3D mesh being billboarded, SpeedTree billboards select an appropriate image from several pre-rendered images according to the current view direction. The images in Figure 2 below are created by capturing the rendered image of the 3D tree at different view angles, evenly distributed around the Y-axis. The first image always starts at positive X axis direction (or 0° if you imagine a unit circle from above).

Figure 2: How the eight billboard images are baked

All images should be atlased together in one single texture. Each image is represented as a Vector4 of {left u, top v, width in u, height in v} in the atlas. You have access to all the images via BillboardAsset.imageTexCoords. SpeedTree Modeler always exports a normal texture alongside the diffuse texture for even better approximation of the lighting, and it shares the same atlas layout with the diffuse texutre.

Once the BillboardAsset is constructed, use BillboardRenderer to render it.

Variables

bottomHeight of the billboard that is below ground.
heightHeight of the billboard.
imageCountNumber of pre-rendered images that can be switched when the billboard is viewed from different angles.
indexCountNumber of indices in the billboard mesh.
materialThe material used for rendering.
vertexCountNumber of vertices in the billboard mesh.
widthWidth of the billboard.

Constructores

BillboardAssetConstructs a new BillboardAsset.

Funciones Públicas

GetImageTexCoordsGet the array of billboard image texture coordinate data.
GetIndicesGet the indices of the billboard mesh.
GetVerticesGet the vertices of the billboard mesh.
SetImageTexCoordsSet the array of billboard image texture coordinate data.
SetIndicesSet the indices of the billboard mesh.
SetVerticesSet the vertices of the billboard mesh.

Miembros heredados

Variables

hideFlags¿Debería el objeto estar oculto, guardado con la escena o modificable por el usuario?
nameEl nombre del objeto.

Funciones Públicas

GetInstanceIDDevuelve el id de la instancia del objeto.
ToStringReturns the name of the GameObject.

Funciones Estáticas

DestroyElimina un gameobject, componente o asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadHace que el objeto target no sea destruido automáticamente cuando se cargue una nueva escena.
FindObjectOfTypeDevuelve el primer objeto activo cargado de tipo type.
FindObjectsOfTypeDevuelve una lista de todos los objetos activos cargados de tipo type.
InstantiateClona el objeto original y devuelve el clon.

Operadores

bool¿Existe el objeto?
operator !=Compare si dos objetos se refieren a un objeto diferente.
operator ==Compara dos referencias de objeto para ver si se refieren al mismo objeto.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961