Unity terrain trees would be great, but as you mentioned there is this billboard bug that hasn’t been fixed yet (for a long time)… Using low poly tree meshes is fine, but not having a billboard functionality also kills performance. Someone in another thread wrote you should create your own billboards for every tree and use LOD group component to change between mesh and billboard. However, getting a proper billboard with lightning etc. is not that easy.
It is really not fun atm to setup VR environments with a lot of vegetation in Unity. I just hope they will fix it soon.
I’ve been trying to find a solution for awhile now and I think I finally found one. Get a package from PolyPixel like the country side or Lakeside cabin one, they come with many great trees ( country side has more ). They don’t have animations for wind, so pair it with the advanced foliage shader. Once you’ve done that everything looks and works fantastic. I have a 4kmX4km world generated with Gaia with dx11 grass shader using their realistic grass and I have finally hit target fps with a very large amount of trees. Also the billboards are great and work fine since it’s not unity trees.
I scripted my own billboards that rotate around Y axis to look at cam. I had to optimize for mobile, so all trees are batched quads and managed in a single update loop (each tree does not have its own script), half get managed one frame half the other resulting in trees getting rotation updates at 30Hz. They also have stationary blob shadows and 3D collider approximations. They also make rustling noises when driving into them or scraping past them. I’m happy with them.
Terrain Tree billboards are uniquely broken, I think they fixed it for other billboard types. You have to use LOD’s and setup a prefab to show at the lowest level instead of billboards.
The issue has actually always been there. It’s an artifact of the billboarding orientation, but its just actually noticeable in VR.
Unity really need to fix this, I see this question popup so many times on the forums. It’s insane that while Unity has gotten a money boost several times for VR, this is still an issue. It’s unbelievable funny but sad the same time.
@FiveFingerStudios
Unfortunately I’ve done away with grass and use the new CTS terrain shader to give normal maps to my grass textures. DirectX11 Grass Shader is the only one that looks decent enough in VR, but it is also way too expensive to render. It can be used in small patches, but until the guy decides to try and optimize it it will never be a large terrain grass solution. Nothing else looks even kind of decent unfortunately.
As far as billboards go, use Gaia and put non unity terrain trees in with lods ( even billboards ) and they will work perfectly without scripting. It’s only unity terrain trees that have the issue that I’ve found…
Oh and shame on Unity for not fixing billboards in VR, SHAME!!! Reflections still don’t work either, it’s absolute bullshit that they advertise Unity as VR friendly. They’re just sitting on their piles of money.
What shader are you using on the trees? I’ve been using Legacy/Transparent/Cutout/Unlit, but the game starts lagging at a certain number of trees. I’m developing for Gear VR.
I was using cutout, because I thought it would be faster with less overdraw, but cutout breaks the weird cell batching that mobile GPUs employ.
So it’s faster to use a simple alpha shader, like you I used unlit as my tree textures have baked lighting from approx above. Also try and atlas all your trees into one megatexture.
I was really suprised how much faster alpha ran than cutout.
Not sure how many trees you need, but I never put more than 100 of these in any one scene, it could handle more but I am also throwing many other alpha quads around, weapon FX etc. If it was just trees then 200 is fine.
Also to reduce script cost:
Manage all trees in one update loop, make a tree manager script for all trees.
Update each trees yaw every N frames to reduce engine calcs (below is every 4th frame).
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// UPDATE
const int K_MOD_FRAMES = 4;
int iMod = 0;
int iTree = 0;
static Vector3 vLookAt = new Vector3();
static Vector3 vUp = Vector3.up;
void Update()
{
if (!v.tCamera)
{
if (Camera.main)
{
v.tCamera = Camera.main.transform;
}
else
{
return;
}
}
vLookAt = v.tCamera.position;
vLookAt.y = 0.0f;
iMod = ++iMod % K_MOD_FRAMES;
for (iTree = iMod; iTree < v.GRP_tBillboards.childCount; iTree += K_MOD_FRAMES)
{
v.GRP_tBillboards.GetChild(iTree).LookAt(vLookAt, vUp);
}
}
2017.3 beta 1 release notes include this tantalizing snippet:
XR: Improved VR Terrain Trees: fixed billboard trees rotating all the time as viewer moves in VR, better transition of 2D to 3D trees, fast “sort-independent” trees with alpha-to-coverage blending and MSAA , billboard texture aliasing improvements (733507, 946544)
I’m trying to work with a client that uses Sketchup and a tree library for it. I’ve been able to import the models in and found that even with a handfull of trees the fps has dropped down to around 20fps using the vive. I even found to the point were if I went from 0 trees to 1 the framerate dropped by half.
I’ve been turning off shadows and tried some of these shader options, but I’m not really bringing my framerate up. I also looked at Alt-tree, but the sketchup trees don’t really seem to play nicely with that. Any suggestions there?
XR: Fixed billboard trees moving around in VR as viewer moves or rotates. Also fix VR issue of morphing tree vertices “growing” as camera moves closer to trees (733507, 946544)