Game Development Reference
In-Depth Information
This is a very effective way to add convincing shadows to objects without
adding too much processing overhead.
2.7.5 Billboards
Billboarding is a technique that uses planes to fake a lot of background
scenery. A billboard is a plane usually having a partially transparent texture
applied to give it the appearance of being a shape other than a square.
Common uses for billboards are grass, clouds, and distant trees.
To give the illusion that the billboard is viewable from all angles, the plane
orientates itself constantly so that it is always facing the player.
Unity Hands On
Billboards
Step 1. Open a new Unity project and add a ground plane and an FPC
(for which you will need to import the Character Controller package).
Step 2. Download Chapter Two/basicPlane.blend and grass.psd from
the Web site and add to your project.
Step 3. Add a Directional Light game object and rotate it down to
give some shading to the ground plane.
Step 4. Add the basicPlane to the Scene and rotate it by 90° around
the x axis to make it stand upright. If you can't see the surface after
rotating, orient your view so that you are on the other side of the
plane.
Step 5. Create a new material called grass. Set the shader to
Transparent/Diffuse. Use the previously downloaded grass texture on
it.
Step 6. Add this material to the basicPlane object. It will need to be
dragged and dropped onto the Plane child object that is attached to
basicPlane as this holds the mesh.
Step 7. Play. Walk around the scene with the FPC and examine the
plane. From a distance it looks good. As you approach it and move
around, it becomes apparent that the image is flat and not viewable
from the underside.
Step 8. To update the plane so that it always faces the player, create
a new JavaScript file called billboard and attach it to the basicPlane.
Enter the code in Listing 2.23 .
Listing 2.23 Script to Create a Billboard from a Plane
function Update()
{
transform.LookAt(Camera.current.transform);
}
 
Search Nedrilad ::




Custom Search