Terrain Tree Lighting

I have a situation where as the player now has a flashlight that lights up the area in front. As the light hits a tree, the entire tree leaves is lit up rather than just the portion of the tree being hit by the light.

Has anyone experienced this and found a solution to it such that, as light hits a tree, only the tree portions being hit by light are illuminated?

1 Like

It could be the rendering path on the camera object. Try changing it to “Deferred”.
image
(Using an older version of Unity so things may look a bit different)

If I remember correctly there’s a performance overhead to deferred lighting, so it might not be best for mobile games. My Unity’s a bit rusty so someone else may have a better solution, or be able to elaborate on why you might want/not want to do this. There’s also more information on the Unity docs.

Hey Myn,

Thank you for the suggestion. I am afraid it did not work.

Note that I am using Cinemachine. I did look at the Virtual Camera and found no similar settings.

My instinct tells me this has something to do with a billboarding effect on the terrain trees and that I may not have a setting correct with my trees prefab or shader. But I do not have enough experience with unity to know how to address it. This obviously could be incorrect.

Thank you for the suggestion.

1 Like

Hi me2001,

Myn’s screenshot shows the normal Camera component, which is not part of the Cinemachine. If you tested a different Rendering Path, I found another solution.

If that didn’t help either, please share more information on what you did and have in Unity. At the moment, we don’t know anything about your project except that you are using trees, the cinemachine and a flashlight.

My apologies for the lack of information.

I am in the following situation:
1) In the Zombie Runner project

2) Added terrain and trees
The trees I am using come from the Low Poly Free Vegetation Kit
I added the trees to LOD groups due to Unity Warnings (Figure 1).
I updated the tree shaders to be Nature/Tree Soft Occlusion due to Unity Warnings (Figure 2).

3) Implemented a flashlight
Using a Spotlight on the player prefab

4) I am using Cinemachine for the camera as that is now a part of Starter Assets
CinemachineBrain - I don’t know that I changed any settings on this (Figure 3)
CinemachineVirtualCamera - I am having to modify the FOV on this in code for the zoom-in/zoom-out (Figure 4)

Screenshots:
Figure 1 - Terrain Tree Settings

Figure 2 - Tree Settings and Shaders

Figure 3 - CinemachineBrain

Figure 4 - CinemeachineVirtualCamera

Thanks. That’s helpful. :slight_smile:

If possible, also provide a screenshot of the problem in the scene to ensure that we are talking about the same. There are so many potential problems in Unity, that it is easy to talk past one another without noticing it.

From what I see, the ‘Rendering Path’ is set to ‘Use Graphics Settings’. What are your Graphics Settings? Did you test what Myn suggested?

Have you tested a different shader to see what happens? It is very likely that you are just experiencing a shader issue.

Also try to decrease the intensity of the spot light. Start with a very low value, so you will hopefully see immediately if something changes in the scene at runtime.

Here is an ancient thread. Maybe somebody suggested something that could help you too.

Here is another thread:
https://forum.unity.com/threads/problem-with-spot-lights-on-terrain.1270490/

Hey Nina,

Thanks for the quick response.
As per your notes:
What are your Graphics Settings?
I will look this up later today. Can you let me know what Graphic Settings this would be referring to? Is this the graphics cards settings? I am afraid that I am unfamiliar with the internals of the camera and I am just using it at this point.

Did you test what Myn suggested?
I did, and unfortunately, this suggestion did not help.

Have you tested a different shader to see what happens?
I have, and what I experience is the trees going completely dark and not being lit up at all.
Changing the shader also presents Unity warnings that the trees will do default billboarding and lighting may not show up well.

I will check out the threads later today.

Thanks for all the info.

Attached are two images demonstrating the problems:
(Figure 1)
Demonstrating the render that shows trees lit up by a flashlight.
The trees on the left are completely dark.
(Figure 2)
Demonstrating the render that shows a tree on the left completely lighting up once it is hit with light.
The lighting just pops in unnaturally.
I am wanting to make the tree light up in parts gradually the way the rest of the scene does.

Figure 1 - Tree on left completely dark

Figure 2 - Tree on left completely lit up

It’s the Graphics Settings in Unity. Simply share a screenshot of what you have there. If I see something ‘suspicious’, I’ll be able to do some specific research to figure out if it might be related to your problem.


Figure 1 looks fine to me but maybe my room is too bright right now to properly see the problem in this very dark screenshot.

Figure 2 looks as if the light might be too intensive. The ‘light’ in Unity is just a calculation and colour mixing. If the result in figure 2 looks closer to what you want to see than figure 1, try to change the settings of your flashlight to see if it affects the current lighting of the tree. Try to make it look worse and then better. Or vice versa. If you are able to do that, you found a potential solution.

Thanks for all the help. I solved it a different way. I switched to a different tree asset from the Unity Asset store. The other one was not working for me with the lighting and I am not skilled enough to work out the issue. But another set of vegetation from the Asset store did work.

Thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

I’m glad you found an alternative solution. :slight_smile:

You are right. The rendering is an advanced topic, especially, when we don’t know if there is a problem with the rendering pipeline or the shader or both. For this reason, we stick with Unity’s built-in render pipeline and specific assets because we know that they work for the majority of students.

When importing a different asset or using a different render pipeline, it’s often a tightrope walk because different shaders and render pipelines could introduce a whole new set of problems that require a lot of experience in Unity to solve them.

For this reason, my advice would be to complete the game and the course first. If you still want to swap the assets after your game is completed and working, you could do that and do some research on the problems. Maybe you’ll ‘just’ have to change the render pipeline in your game to make certain things work but it could be that other things stop working and need a new solution.

1 Like

Privacy & Terms