(Case 1227083) Tree Nature/Soft Occlusion shader in URP

Testers asked a couple of days ago to send reduced project. So I send and they confirmed that they received the project. Now waiting for the next steps.

Also for clarification, I found that terrain painted trees should receive light probes generated per tree (i believe)

Light probes for trees do not seem to be working for the URP Speedtree shaders, they work on URP Lit shaders etc and were working perfectly fine before on built-in renderer with speedtree shaders before.

From here: Unity - Manual: Terrain settings

1 Like

So the QA team managed to replicate the issue which is now on Issue Tracker. Feel free to cast votes :slight_smile:

I would think the cross-billboard technique could be optimized. Maybe add a few verts to the planes where there is empty space to reduce overdraw. I would probably stick with a basic masked shader for that as well, or even an opaque one. Have you checked the profiler to determine what the bottleneck is?

It is unlikely to be optimized to the level which camera facing billboards provide. It may bring numbers to tens of thousands at best but I would ever doubt that it could bring millions. No, didn’t checked but I guess bottleneck might be likely due to game objects, nested children and inefficient LODGroup component. I think only Megacity demo has reached comparable counts to billboarding renderer.

1 Like

Just did a quick profiler test on the simplest case where cross-billboards are used with the same SO shader as in camera facing billboards in built-in render pipeline. Seems to be most of bottleneck in Camera.Render. P.s. Needed to reduce tree count 10x in order to even run profiler :slight_smile:

6029213--650561--Screenshot 2020-06-27 at 10.32.51.png

Yeah that’s likely because of all the draw calls. You definitely want to have instancing enabled when drawing this many objects. You said it didn’t help much, but it should change where the bottleneck is. I’m guessing culling, but I don’t know how the terrain tree system does that. If thats the case, one thing you could try is putting the trees as detail objects instead of as trees. I think lod and culling might be calculated differently for those.

So for SO shader there are no instancing. So instead I checked for ST7 one. And the bottleneck still points to Drawing first and then to culling even we can see that number in ā€œSaved by batchingā€ in statistics popup is over 500k. Also enabled terrain.drawInstanced but doesn’t change the result. Camera facing billboards does not use culling so no need to handle that :slight_smile:6034556--651620--Screenshot 2020-06-29 at 10.52.00.jpg

1 Like

@chanfort Fixes for global illumination and lightprobes for Speedtree shaders in URP coming here

Also, did you have any findings on the performance of Speedtree 7 shaders vs alternatives in URP? If there are any alternatives that is!

That’s good news. I guess tree billboards issue might be looked later as well :slight_smile:

No, I didn’t compared much of performance differences between various shaders. I thing at the moment that usage of game objects, LOD groups and mesh renderers per tree instance might have overwhelming differences from shaders by several orders of magnitude. :slight_smile:

1 Like

Is there any way we can escalate the billboard issue you had? In my project using URP Preview version 9.0.0 preview.35 with Unity 2020.1.0b14 using Speedtree7 shaders the billboards are working perfectly? See in the link below

https://imgur.com/VWfbGU6

1 Like

Are these ST7 models together with ST7 shaders? If that’s the case then it should be fine. When I was trying I was using BOTD models with ST7 shaders. In such case they were black.

Ah yeah was using ST7 models with ST7 shaders. i don’t believe you can use BOTD models for anything commercial anyway, they will soon be lost and forgotten I’m sure.

Hmm, that’s interesting one, I though BOTD trees are under Unity Companion License so could be used in games :slight_smile:

But in terms of ST7 shader the point is not about BOTD but that it might be not possible to use on any custom tree models (i.e. the ones made with Blender Sapling tool, etc.) so seems to be specific to ST7 models only.

1 Like

Hey there,

We are still investigating to see what it would take to support TreeCreator. Meanwhile it’s true that SpeedTree doesn’t perform as well in terms of rendering a massive amount of them. We’ll continue to improve the performance of SpeedTree billboards.

I’m attaching a workaround version of the Soft Occlusion shaders to be rendered in URP.

A little information of the workaround:

  • URP actually still renders passes without lighting. That’s why the TreeCreator imposters were rendering. The workaround turned off lighting by deleting the line ā€œLighting Onā€.
  • When lighting is off, the trees are simply lit from _TerrainTreeLightDirections and _TerrainTreeLightColors, which is filled by the Terrain system internally.
  • The Terrain system only selects directional lights. Therefore the mesh trees will not be affected by point lights or spot lights. But at least it’s consistent with the imposters.
  • I didn’t test much of the result, but noticed the lighting color is a bit off. You probably need to have a better lighting system implemented to replace the builtin one in both the imposter and the mesh shaders tailored to your game’s needs.

6220065–683934–TreeCreator.zip (6.03 KB)

7 Likes

Hi there, thanks for taking a look into that. Very glad to see things started to move here. I will check that zip file what is there.

Just one notice these camera facing billboards are not exactly just for tree creator. When I was trying to make a tree with tree creator it uses these shaders:

ā€œNature/Tree Creator Barkā€
ā€œNature/Tree Creator Leavesā€
ā€œNature/Tree Creator Leaves Fastā€

However, Soft Occlusion shaders are different, I believe they were released for general purpose not just for tree creator but also for using trees modelled by any 3D modelling software, i.e. Blender. These are:

ā€œNature/Tree Soft Occlusion Barkā€
ā€œNature/Tree Soft Occlusion Leavesā€

I also noticed that if I use Tree Creator shaders for Blender modelled trees I am getting this warning:
ā€œThe tree MyTree must use the Nature/Soft Occlusion shader. Otherwise billboarding/lighting will not work correctly.ā€

So in summary Soft Occlusion shaders seems to be for general purpose while Tree Creator shaders just for tree creator modelled trees.

Feel free to use my examples if you are planning in the future to improve SpeedTree performance to be on the similar order like billboards based trees. I have covered most cross-cases for SO, ST7 and ST8 shaders for Build-in and URP in this repo:
https://github.com/chanfort/Tree-billboards-stress-test

1 Like

Yes you are right the billboards are used generally for any tree prefab that doesn’t come with a LODGroup. We’ll take this into account for future improvement. Thank you very much for the info and the example repo you set up. Much appreciated!

2 Likes

Thanks for taking a look into this issue. I just checked these shaders and it looks quite a big improvement already over what it was before. It’s quite nice to see that colors between billboard and mesh modes are consistent. Also nice that trees in mesh mode are swinging in just like they do in built in pipeline. It’s also exciting to see that it does not generate these warnings which are generated when selecting different shaders.

Lighting seems to be working quite well, I just checked it seems like it reacts properly to directional light. I missed a bit fog. But I also see that fog does not apply to terrain when the checkbox is ticked in Lighting Settings. So I assume that it’s alright at this stage. Another small thing I noticed is that nearby trees in mesh mode while using Soft Occlusion URP shaders does not cast shadows. But I don’t see shadows for regular objects as well so I guess it’s alright for trees :slight_smile:

Zeroyao, thanks a ton for these fixed shaders! I’m already multiple months into a URP project and realizing tree billboards don’t work in URP was a shock.
Any indication when these will be brought to URP by default?

4 Likes

Yeah, I am also keen about this, i.e. when cginlude’s and shaders will be included into Unity engine’s / URP package’s code. It’s only 2 days left since it will be one year since the bug was submitted :slight_smile: .