Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[FREE] Billboard Generator

Discussion in 'Assets and Asset Store' started by joshcamas, Nov 24, 2021.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268


    Here's a simple billboard generator I recently built! It generates a cross section mesh of your prefab, and includes the ability to bake extra data (in the gif above I baked a leaf mask, so I could color the leaves).

    Features
    • Generates a simple cross-section billboard for a prefab (auto picks last LOD of prefab to render if it exists)
    • Support for multiple "bake passes" - allows you to bake other data (masks, normals) that you want to use
    Simple Tutorial
    • Create a BillboardRenderSettings via "Create/Ardenfall/Foliage/Billboard Render Settings"
    • Add a new Billboard Texture. This will be your albedo+alpha texture.
    • Ensure the Billboard Texture's textureID matches the texture property in your billboard shader
    • Add a new Bake Pass. Keep the values as they are by default. (this pass is using the default shader, so no custom shader needed)
    • Create a BillboardAssets via "Create/Ardenfall/Foliage/Billboard Asset"
    • Add your foliage prefab to the Prefab field
    • Add your render settings to the Render Settings field
    • Click "Generate Billboard"
    • To see the results, click "Spawn Visual"
    Custom BakePasses
    • Lets create a custom bakepass to use normals in our billboard!
    • Add a new Billboard Texture to your Render Settings. Set the property id to "_Normals", and toggle off Alpha Is Transparency.
    • Add a new Bake Pass. Uncheck "A", since we have no need for the alpha channel (normals can be baked into 3 channels).
    • Create a new shader. This will be your "normal bake pass shader". Make your shader output the normals of each fragment. (Literally rendering the normals)
    • Insert this shader in the "Custom Shader" field in your new Bake Pass.
    • To use this normal texture, simply sample the texture "_Normals" in your billboard.
    Notes
    • When baking a pass, you may want to ensure certain properties of the rendered material is a certain value. You can do this via the Material Overrides field.
    • There is a builtin "Cutoff" value that is applied to the generated billboard material. This is optional, but if you want to use it the property name must be "_Cutoff".
    • You don't Have to use multiple bake passes per texture - you could easily pack multiple things (normals and occlusion, for example) into a single RGBA texture in a single bake pass. The multiple bake pass per texture feature is merely for convenience.
    • There are a few lines dedicated to URP - if you want to use this in builtin/HDRP it will take a little bit of work to port, but I promise it would only take a few minutes.
    Download
    https://github.com/joshcamas/unity3d-billboard-generator
     
    Sluggy and sirleto like this.
  2. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    840
    Saved me several hours of time with this. Thanks!
     
    joshcamas likes this.
  3. TomTrottel

    TomTrottel

    Joined:
    Aug 16, 2014
    Posts:
    18
    i am not getting it working, only blank texture material as result. doing something wrong, but no errors.