Jump to content

Detail object can't receive shadow on build of Standalone (URP, Windows64 IL2CPP)


Ken Onion
Go to solution Solved by Peter,

Recommended Posts

Gaia generated some Detail Objects for the terrain during runtime, such as flowers and other plants, to replace the terrain grass of Unity, as shown in the following figure

 In Edit Mode

spacer.png

 

In Playing Mode

spacer.png

 

Detail Objects

spacer.png

 

I think this is an optimization made by Gaia during runtime, and it's completely acceptable. When running it in the editor, everything works nice, and the Detail Object can receive shadow by environmental objects such as trees or other.

However, when I built scene and run it, I found that the Detail Plants cannot receive shadow, as shown in the following figure

 

spacer.png

This is a very frustrating issue, I spent a lot of time testing but didn't get any results. I am using Unity2022.3.4f1 LTS,  URP,  build with WINDOWS64 IL2CPP.

Link to comment
Share on other sites

  • 2 weeks later...

Hi @Ken Onion, please excuse the delay until we were able to get back to you. We tried to reproduce the issue in 2022.3.4f1 URP, however we found that the terrain details still do receive shadows in a build.
Gaia itself does not have any mechanism or optimization that should alter shaders or materials between Editor and Build, so we would need to find out why the shaders behave differently in the build. Some pointers / things you could try:
 

  • Are you currently using a shader variant collection, or the "Alyways Included Shader" List? It might be that the Flora vegetation shaders were recorded in a variant that does not receive shadows, and therefore only this "shadowless" variant ends up in the build. If you do NOT use one, you could try if it fixes it if you use one. Make sure to run the scene so the Flora shaders with shadows on them are part of the variant collection.
  • Do you know if the build uses a low quality preset? It can happen that the build automatically or via script goes to a low quality preset, which then might influence shadows as well.
  • Are there any additional assets in the project? If yes, it might be worth to compare against a neutral project where you only have Gaia installed to make sure it is not a cross asset issue.
  • You could try to remove the Flora terrain tile component from the terrain, so that the terrain details are not swapped out with the Flora rendering during runtime. It would then be interesting to see if those unity terrain details do also not receive shadows as well.
  • Not really a solution, but a workaround could be to use Unity's GPU instanced terrain detail system instead. The whole Flora system we created in Gaia was because there was no good way to render meshes as terrain details on the unity terrains, especially in HDRP. Now since unity has added the GPU instanced terrain details, you could consider using those instead. You would however need a fitting shader for this, e.g. from the Terrain Samples pack from the asset store. Let me know if this could be interesting, then I can elaborate more.
Link to comment
Share on other sites

  • 1 month later...
On 8/26/2023 at 7:21 AM, Peter said:

Hi @Ken Onion, please excuse the delay until we were able to get back to you. We tried to reproduce the issue in 2022.3.4f1 URP, however we found that the terrain details still do receive shadows in a build.
Gaia itself does not have any mechanism or optimization that should alter shaders or materials between Editor and Build, so we would need to find out why the shaders behave differently in the build. Some pointers / things you could try:
 

  • Are you currently using a shader variant collection, or the "Alyways Included Shader" List? It might be that the Flora vegetation shaders were recorded in a variant that does not receive shadows, and therefore only this "shadowless" variant ends up in the build. If you do NOT use one, you could try if it fixes it if you use one. Make sure to run the scene so the Flora shaders with shadows on them are part of the variant collection.
  • Do you know if the build uses a low quality preset? It can happen that the build automatically or via script goes to a low quality preset, which then might influence shadows as well.
  • Are there any additional assets in the project? If yes, it might be worth to compare against a neutral project where you only have Gaia installed to make sure it is not a cross asset issue.
  • You could try to remove the Flora terrain tile component from the terrain, so that the terrain details are not swapped out with the Flora rendering during runtime. It would then be interesting to see if those unity terrain details do also not receive shadows as well.
  • Not really a solution, but a workaround could be to use Unity's GPU instanced terrain detail system instead. The whole Flora system we created in Gaia was because there was no good way to render meshes as terrain details on the unity terrains, especially in HDRP. Now since unity has added the GPU instanced terrain details, you could consider using those instead. You would however need a fitting shader for this, e.g. from the Terrain Samples pack from the asset store. Let me know if this could be interesting, then I can elaborate more.

 

Thanks for your reply! Based on your suggestion. I have created a new project and check it using Gaia Pro 2023, It seems that the terrain detail object still cannot receive shadows on build. Based on my the test results, I think that the problem might be caused by the shader.

In Gaia Pro 2023, the material of the detail object model use this shader as default.

Snipaste_2023-10-08_02-49-46.thumb.png.6de5670bd79065a2a6cb372e447b1ff3.png

I built and ran it. as shown below, The shadow of the capsule was correctly projected onto the ground, but the grass could not receive the shadow.

Snipaste_2023-10-08_03-09-29.png.ec55fb1784ba9e1822e1d4a342193b2e.png

When I try to replace it with another shader  and build it again,

Snipaste_2023-10-08_02-50-27.thumb.png.f2ff0e518b73ab95c65c24c97d502ed7.png

It seems work correctly....

Snipaste_2023-10-08_03-10-30.png.721b5b91d1daacad9c9bf8941fa4e2c2.png

Link to comment
Share on other sites

Hi @Ken Onion, thanks for providing the additional information! I set up another test project and was finally able to reproduce the issue. When comparing the two shaders, there is a major difference between the two as that the Foliage shader that shows the issue implements its own lighting, rather than being marked as a "lit" shader in shadergraph. It looks like one of the mechanisms it uses for the lighting calculations does work differently in a build than it does in the editor.
We will investigate to fix this, you can in the meantime use the other shader for terrain details as a workaround, if they work for your scene.

Link to comment
Share on other sites

  • Solution

Hi @Ken Onion we looked further into it, and found that exposing some shader keywords as public fixes the issue. This has not been a problem in the past, but apparently the non-public keywords were stripped in the build which resulted in the shader lacking proper shadowing. Exposing those keywords fixed the issue in our repro project. Can you please try the attached patch to see if it improves things for you as well?

GaiaURPFoliageShadowPatch.zip

You can install the contained unitypackage file via Assets > Import Package > Custom package in the Editor.

Link to comment
Share on other sites

On 10/10/2023 at 6:58 AM, Peter said:

Hi @Ken Onion we looked further into it, and found that exposing some shader keywords as public fixes the issue. This has not been a problem in the past, but apparently the non-public keywords were stripped in the build which resulted in the shader lacking proper shadowing. Exposing those keywords fixed the issue in our repro project. Can you please try the attached patch to see if it improves things for you as well?

GaiaURPFoliageShadowPatch.zip

You can install the contained unitypackage file via Assets > Import Package > Custom package in the Editor.

Thanks for your help! I patched it, It works nice!

By the way,  This issue will be fixed in next version?

  • Like 1
Link to comment
Share on other sites

5 hours ago, Ken Onion said:

By the way,  This issue will be fixed in next version?

yes, fixes that are created during the support process always go into the next regular update so everyone can benefit from them. So the next update will have the fixed shader in it directly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...