x


Is it Possible to have Trees with Billboarded Leaves?

We are creating a game that has an anime look, and the most well known way to achieve trees that "Look" like anime is by having them be billboarded images.

Is there any way to be able to have trees that worked like this, but were still able to be used as Trees in the unity terrains? any way to change the soft occlusion leaves shader to allow for billboarding of the leaves?

Here's an example:

http://dl.dropbox.com/u/99545/other%20peoples%20stuff/naruto-ultimate-ninja-storm-200809150039558732-test.jpg

more ▼

asked Dec 09 '09 at 04:08 AM

Diego gravatar image

Diego
54 1 1 6

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

A few separate answers:

Any GameObject in Unity can be used as a tree in terrain. Create the tree as you would like it, with any shader assigned to it, and any collision assigned to it. Then simply go into the terrain config and pick this model as your tree.

Unity uses a couple of different builtin shaders for its trees, but unlike the other builtin shaders, the billboard shader is hidden and won't appear in the shader dropdown list. To use the billboard shader on your custom tree, you'll need to download the shader source and add them to your project. Get it here. Copy TerrainShaders\Trees\BillboardTree.shader to your project and edit it. Change the shader name from "Hidden/TerrainEngine/BillboardTree" to "TerrainEngine/BillboardTree".

Now, the next part is a little harder. When you model the leaves, all 4 verts of each quad need to be in the exact same position. Also for the leaves you need 2 uv sets. The first set is used for normal texturing. The second uv set is for "billboard extrusion", where U is the world distance to move the vertex right, and V is up. (use negative UV values to move left and down). You should write some maxscript/mel to help you do this, rather than ask the artist to conjure this tech voodoo by hand.

If you want swaying trees, copy and rename the appropriate hidden builtin shader into your project; and the art needs to be specially made so that the alpha of the per-vertex color value specifies the "sway amount".

more ▼

answered Dec 09 '09 at 03:50 PM

Lance Sun gravatar image

Lance Sun
1k 12 16 41

(comments are locked)
10|3000 characters needed characters left

Granted you have all leaves with their pivot properly centered, you can use CameraFacingBillboard.

Or you can use "my" version of it:

using UnityEngine;
using System.Collections;

public class CameraFacingBillboard : MonoBehaviour {
    public Camera facingCamera;
    public Vector3 objectInitialOrientation = Vector3.back;
    private GameObject myContainer;

    void Start () {
       if (facingCamera == null) {
         facingCamera = Camera.main;
       }

       myContainer = new GameObject();
       myContainer.name = "rot_" + transform.gameObject.name;
       myContainer.transform.position = renderer.bounds.center; // grab renderer center rather than possibly missplace pivot
       myContainer.transform.parent = transform.parent;
       transform.parent = myContainer.transform;
    }

    void Update () {
       myContainer.transform.LookAt(myContainer.transform.position + facingCamera.transform.rotation * objectInitialOrientation,
         facingCamera.transform.rotation * Vector3.up);
    }
}
more ▼

answered Jun 06 '12 at 08:09 PM

Cawas gravatar image

Cawas
1.3k 31 38 54

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1649
x1465
x56

asked: Dec 09 '09 at 04:08 AM

Seen: 2955 times

Last Updated: Jun 11 '12 at 08:06 PM