Billboard Questions

Off topic discussion. Talk about gaming and life in general. Be awesome to each other.
Post Reply
User avatar
LorrMaster42
Posts: 66
Joined: Thu Dec 24, 2015 12:09 am

Billboard Questions

Post by LorrMaster42 » Sun Feb 25, 2018 12:35 am

Currently trying to experiment with something which requires me to use billboards. Unfortunately there isn't a whole lot of documentation with them, so I've run into some trouble getting them to render.

I created a billboardAsset using the code below, gave it a material with an image on it, and then placed a billboardRenderer in the world to make the image appear, but the billboard remains invisible. I think that I might be assigning the texture coordinates incorrectly, but I'm not sure.

Code: Select all

        
        BillboardAsset billboard = new BillboardAsset();
        billboard.height = height;
        billboard.width = width;

        Vector2[] vec = new Vector2[4];
        vec[0] = new Vector2(0,0);
        vec[1] = new Vector2(1, 0);
        vec[2] = new Vector2(0, 1);
        vec[3] = new Vector2(1, 1);
        billboard.SetVertices(vec);

        ushort[] ind = new ushort[6];
        ind[0] = 0;
        ind[1] = 1;
        ind[2] = 2;
        ind[3] = 1;
        ind[4] = 2;
        ind[5] = 3;
        billboard.SetIndices(ind);

        Vector4[] texCoord = new Vector4[1];
        texCoord[0] = new Vector4(1, 1, 1, 1);
        billboard.SetImageTexCoords(texCoord);

        AssetDatabase.CreateAsset(billboard, "Assets/Scripts/Game/Entities_2/Bill.asset");

User avatar
Interkarma
Posts: 3488
Joined: Sun Mar 22, 2015 1:51 am

Re: Billboard Questions

Post by Interkarma » Sun Feb 25, 2018 2:18 am

I'll move this one to Community as it seems more like a general Unity programming question than specifically help with Daggerfall Unity. :)

Daggerfall Unity uses its own custom billboard classes. For general billboards, there's DaggerfallBillboard. Foliage and other flats in wilderness use a special batch billboard shader that can render many thousands of trees, etc. in a single call.

My billboard classes are tightly integrated with Daggerfall Unity's own material requirements and texture conversion API, but please feel free to use any of their code in your own projects if it's useful. :)

User avatar
LorrMaster42
Posts: 66
Joined: Thu Dec 24, 2015 12:09 am

Re: Billboard Questions

Post by LorrMaster42 » Sun Feb 25, 2018 4:44 am

Thanks! I checked your code and realized that I just needed to create a simple mesh instead of whatever BillboardAssets in Unity are.

Post Reply