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

Issue Tracker

I was wondering if Nature/Soft Occlusion shader is supported in URP? I was recently experimenting with trees in URP and getting issues. If I use Nature/Soft Occlusion shader, trees appear to be rendered properly only in billboard phase. While nearby trees appears pink. Changing material to use Universal Render Pipeline/Nature/SpeedTree8 seems to be working for nearby trees but not for billboard phase. I am also getting warnings in console:

The tree MyTree must use the Nature/Soft Occlusion shader. Otherwise billboarding/lighting will not work correctly.
UnityEngine.TerrainData:RefreshPrototypes()

I also didn’t found in Universal Render Pipeline/Nature category any other soft occlusion shaders. So I was wondering if URP is supporting terrain trees?

4 Likes

Having severe issues with the Speedtree 7 and Speedtree 8 shaders that are part of URP, reporting this test scene soon

3 Likes

Received the following error:

The tree __ must use the Nature/Soft Occlusion shader. Otherwise billboarding/lighting will not work correctly.
UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

Using the said Nature/Tree Soft Occlision Bark turns the trees into everyone’s dreaded color bright pink.
Then one has to switch back to URP/Nature/SpeedTree8.

Please bring a SpeedTree9 with compatibility with URP dear Team Unity.

2 Likes

The thing about using non-SpeedTree shader is that the Tree won’t react to Wind.
Then one will have to use some non-terrain wind function or buy a probably paid asset store shader

1 Like

Using the exact same Speedtree shaders in Built-in renderer produces correct results, seems that there are some issues with Terrain tree lightprobes and the URP-only Speedtree shaders

https://www.youtube.com/watch?v=Qg4MXRSPNLc

I have raised a forum post about this with Speedtree (link below) although I feel this may be something Unity SRP team need to look into?

@wyatttt @XiaoxiLiu
-There is someone working on the Speedtree shader graph who I am trying to inform of this issue, are you able to look into this or notify them?
Reported as a Bug with (Case 1221827) [URP][Terrain][Speedtree]Terrain LightProbes for Speedtree7/8 shaders bake black

Speedtree forum post:
https://forum.speedtree.com/forum/speedtree-modeler/feature-requests-and-bug-reports/8217-unity-universalrp-speedtree-shaders-dark-shading-and-no-light-probe-support-urp#post8218

Unity forum post:
https://discussions.unity.com/t/777668

1 Like

This is only partially true. Non-SpeedTree trees are swinging in wind in model phase and are static in billboard phase. And SpeedTree tree branches are moving while regular trees only swing.

The main problem with SpeedTree trees is that it is possible to use only several hundreds or several thousands of trees while with non-SpeedTree trees we can use hundreds of thousands of them.

So, since SpeedTree is not a replacement for build-in trees, I think both of them should be supported in URP at some time. Especially after hearing that build-in pipeline might be deprecated in the more distant future :slight_smile:

2 Likes

There is an official logged issue for this here, obviously not high enough priority unless it gets some votes. Please vote for it here:

3 Likes

Just voted up :slight_smile: . Will also need to submit build-in tree issues with examples at some point :slight_smile:

1 Like

Upvoted

1 Like

I would like to report a positive change to the silver edges of the tree leaves.

Using :
Tree - SpeedTree sample tree pack from the Asset Store
Shader - URP/Nature/SpeedTree7 or 8
Unity - URP 2019.3.2f1

Located in:
Window/Rendering/Lighting Settings/Environment^EnvironmentReflections^Cubemap

There was an inaccurate cubemap possibly loaded by either Bakery Lightmapper or some plugin which I removed and forgot to clean the project after removal.

Now the SpeedTree has their original “shine” as one can preview in

1 Like

So, recently I spend some time to make demo project with massive forest containing millions of trees. It highlights current advantages and limitations of Soft Occlusion vs SpeedTree in Build-In and URP pipelines. I also converted some Book of the Dead trees to work with Unity 2019.3.0f6 Build-In and URP pipelines.

Demo

Demo projects are available here: GitHub - chanfort/Tree-billboards-stress-test. Demo contains two projects. One is to show the forest in Build-In render pipeline, and another to show alternative in Universal render pipeline. Player can move around the world with WASD keys, rotate camera with mouse right button and zoom with mouse scroll wheel. Naming in projects is combined from these shortcuts: B - Build-In render pipeline, FB - camera facing billboards, CB - cross-plane billboards, SO - soft occlusion shader, ST7 - SpeedTree 7 shader, ST8 - SpeedTree 8 shader.

Build-In pipeline project

This project contains 3 scenes in order to show how forest looks like in Build-In render pipeline.

B_FB_SO Scene

Scene named B_FB_SO contains the first example. The demo generates terrain on entering in play mode. There are nearly 2 million trees placed on the terrain. Trees in this demo contains only single LOD and at larger distances trees appear as billboards. Tree shaders are set as Soft Occlusion Bark and Leaves. This allow trees to appear properly in billboard phase. Here is how the scene looks once entered into play mode:

World is generated within 3-5 seconds and afterwards gameplay runs at impressive 300 FPS on my 16-inch MacBook Pro (in Editor). Number of trees is defined in GenerateTerrain.cs script and can be easily changed. Bringing larger number of trees increases initial time to generate the world. But once generated gameplay performance is decreasing not very significantly with growing number of trees. Player can also see nearby trees swinging in wind. More distant trees are rendered in build-in billboard phase.

B_CB_SO Scene

This scene is identical to the previous B_FB_SO Scene except one change, each tree model is set with LOD Group so that the first LOD would appear as model and the second LOD appears as two cross intersecting planes billboard model. This way the camera facing billboards are not used and instead cross-plane billboards are used. Here is how the scene looks:

As we can see, the scene looks similar to the previous one except the catastrophic drop of performance from 300 FPS down to 0.9 FPS! The scene contains slightly less tree instances, around 1.2 million. So the estimate downgrade in performance would be (300 / 0.9) * (2 / 1.2) ~ 555 times. By comparing statistics tab at the top right corner we can also notice this number in this scene Batches: 578433. In the B_CB_SO Scene this number is Batches: 1476. However, Saved by batching: 0 in B_FB_SO Scene. But as we will see from other examples, where instancing is enabled and more are saved by batching, performance increases only slightly.

B_CB_ST8 Scene

This scene contains similar setup as B_CB_SO Scene except that instead of Soft Occlusion shaders, SpeedTree8 shaders are used. This allows us to see how BOTD trees looks with SpeedTree8 shader in Build-In render pipeline. Here is the scene view:

As we can see here, most of the trees appears black with only small areas illuminated by sunlight. However, this might be caused as BOTD trees were not designed to be used as SpeedTree8 models. And it may need a proper SpeedTree8 conversion or even modelling to fix the issue. The performance in this scene improves slightly from 0.9 to 1.2 FPS. But that is incomparably far from what was in B_FB_SO Scene. B_CB_ST8 tree materials are set to use instancing and we can see that Saved by batching: 577132 in this scene.

Universal render pipeline project

The remo contains the second project which is set in a similar fashion to use URP.

U_FB_SO Scene

This scene is set in a similar way like B_FB_SO Scene in the first project except that the project is converted to use URP. Trees in this scene are still using Soft Occlusion shader from Build-In render pipeline as there are no alternative Soft Occlusion shader in the URP. Here is the result:

As we can see trees which are close to camera are rendered in model phase and appears pink. This is not surprising as Soft Occlusion shader selected from Build-In render pipeline can’t support URP. But the interesting part is that billboards appear to be rendered correctly! That could mean one of two: that billboard phase has been already implemented in URP, or that internal camera facing billboard shader is compatible with new SRPs including URP. Looking from performance perspective, the scene runs at solid 300 FPS in the similar was as it was with B_FB_SO Scene. This is because camera facing billboards are used which are capable to render millions of trees at playable framerates.

U_FB_ST8 Scene

The difference introduced in this scene is that instead of Soft Occlusion shaders, URP compatible SpeedTree8 shader is used. Models are left in the same way without LOD Group components in order to use camera facing billboards. Here is the result:

As we can see, distant trees are rendered in billboards but they are more transparent comparing to Soft Occlusion shader ones. As a result, the forest appears more like it would have dead trees. Performance is still very solid, running at 200 FPS. The drop from 300 FPS might be understandable as SpeedTree8 shader is more advanced than Soft Occlusion and may require more GPU power. When generating terrain, this causes console warning to be printed that Soft Occlusion shader must be used as otherwise billboarding/lighting will not work correctly. This is basically what we see in the picture above. This scene was made as a possible workaround solution in URP in order to be able to render large scale forests. But console warnings and too transparent billboards show that there are issues.

U_CB_ST8 Scene

This scene is set in a similar way like BuildInST Scene in the first project except that URP SpeedTree8 materials are used instead. Due to the usage of cross-plane billboards instead of camera facing billboards, we have again catastrophic performance drop down to 1.8 FPS.

Conclusions

Camera facing tree billboards are currently the only way to render large scale forests in Unity. The technique is capable to handle millions of tree instances. However, it is currently not supported in the new Universal Render Pipeline which is a candidate to replace Build-In render pipeline in more distant future. Several years ago, a different way was introduced to render several hundreds of trees in smaller scenes using two cross intersecting plane billboards. This is currently the default way to use trees in the URP using SpeedTree.

Demos were made to show that cross-place billboards can’t fully replace many years existing camera facing billboards. If scenes are small, containing several hundreds of trees, cross-fading billboards can be a good choice. However, large scale forests containing millions of trees requires the old camera facing billboards.

As a result, it would be nice if camera facing billboards would be ported to URP at some time in the future. This would enable us to continue having large scale forests in our games using URP in the future.

7 Likes

Billboards render correctly in URP as all Unlit shaders work in URP! It would be quite simple to make a replacement Soft Occlusion shader using Shader graph in URP I believe.

It would be worth testing out the SpeedTree7 Shaders in URP also as they could be more performant?

Thanks for looking into this!

This issue is apparently now active, which is promising!

So, just added SpeedTree7 scenes in both projects (Build-In and Universal render pipelines). Also added several other missing scenes. Repo now contains all possible combinations to compare Soft Occlusion, ST7 and ST8 shaders for camera facing and cross-plane billboards. There are 12 scenes in total, 6 for Build-In RP and another 6 for URP. I also made more consistent naming for scenes, prefab and material folders in projects as well as updated the first post describing details. Here are shortcuts I am using: B - Build-In render pipeline, U - Universal render pipeline, FB - camera facing billboards, CB - cross-plane billboards, SO - soft occlusion shader, ST7 - SpeedTree 7 shader, ST8 - SpeedTree 8 shader.

Interestingly ST7 trees appears to be completely black in both Build-In and URP scenes. Here is how it looks for Build-in render pipeline (B_CB_ST7 scene):
5574154--575359--B_CB_ST7.jpg
and for URP (U_CB_ST7 scene):
5574154--575362--U_CB_ST7.jpg
Not sure if trees are black because of shader issues or because I used BOTD trees here. Also noticed that in material inspector colors for bark and leaves looks fine in both Build-In and URP. But interestingly even in inspector for leaves material gaps between leaves does not become transparent for ST7.

That’s great, maybe we will get more fixes for trees soon…

This thing probably looks most interesting. I looked a bit in SO build-in shaders yesterday but didn’t finished yet. Might be keen how complex it would be to upgrade to URP. Camera facing billboards seems to be quite picky (i.e. B_FB_ST8 does not show camera facing billboards at all!), so not sure if Shader Graph would work so well with them, or it would be just simpler to copy shaders from Build-In pipeline and update what’s needed in shader files.

One way or another, it would be nice if Unity would update at least one tree shader for URP which would work for camera facing billboards by default (either SO, ST7 or ST8).

2 Likes

@chanfort they should render just fine in built in and UniversalRP however there are issues specifically in UniversalRP with terrain painted Speedtree7/8 trees using the terrain tree light probes it generates automatically which turns mine black too.

Thanks for looking into this, Book of the dead trees actually may be the problem right - I would advise to use these, they are SpeedTree7 by default and free - Free SpeedTrees Package | 3D SpeedTree | Unity Asset Store

Did they look fine as prefabs?

It’s really worth sending the project in as a bug report if you haven’t already, sounds very tidy and QA will very quickly be able to verify the issue when it’s shown clearly the way you have shown it!

1 Like

Just looked into default SpeedTree models, they work fine. So it’s probably issues with BOTD trees. Here is how the scene looks like:
5577982--575935--ST7_Free_CB.jpg
However, it runs with only 8 FPS. Changing to camera facing billboards, performance increases to 900 FPS (here are 100k models at the moment):
5577982--575938--ST7_Free_FB.jpg
But the issue seems to be that only trunks are visible in billboard phase and no leaves. So camera facing billboards are somehow working in a weird way. It looks like they are not recognizing partially transparent leaves materials. I won’t commit these default SpeedTree cases to GitHub since it’s quite easy to check.

I also submitted a bug report (Case 1227083). So will be looking forward to hear back how it goes…

1 Like

Thanks so much for verifying, BOTD assets are from a separate ‘branch’ of what was LWRP anyway so I’d stick to regular assets anyway!

Did you notice in URP that the dark sides of the speedtrees are a lot darker than normal?

Yes, noticed that speedtrees are darker in URP. I also noticed that terrain is slightly darker as well, i.e. it’s possible to see in earlier post pictures where are build-in scenes shown. Terrain in these scenes pas using Nature/Terrain/Standard shader and now in URP it looks more like Nature/Terrain/Diffuse one. It might be something similar happening with speedtrees as well.

Were BOTD from LWRP at some time? I thought they were always in HDRP…

I believe there are issues with the main directional light shadow cascade that renders even if you have shadows disabled (realtime shadows at least).
There was some kind of fix for it here but I haven’t got round to trying this branch of the SRP repo.
https://github.com/Unity-Technologies/ScriptableRenderPipeline/commit/8f9ef5ada3f3025ea9ac26eb5979c0ee3acac946

Apologies on the BOTD, it was an early version of HDRP, guess it is all SRP anyway :slight_smile: Thanks again for the tests and let me know if you hear anything back!

1 Like

Any update on Case 1227083?