Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by Diego · Dec 09, 2009 at 04:08 AM · shaderterraincustom-shader

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Lance Sun · Dec 09, 2009 at 03:50 PM

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".

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by cregox · Jun 06, 2012 at 08:09 PM

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);
     }
 }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Shader LOD wont work on custom grass shader 0 Answers

Better shader effects on terrain - Bumpmapping or Specular? 2 Answers

change terrain built in shaders 1 Answer

Can't use material with shaders which need tangent geometry on terrain. 1 Answer

Noob Question - Custom trees and aliasing 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges