Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Resolved Tree creator leaves are glowing with spotlight near

Discussion in 'Editor & General Support' started by theMasky, Oct 24, 2020.

  1. theMasky

    theMasky

    Joined:
    May 8, 2015
    Posts:
    124
    So I already asked this on another section, on Unity Answers, on Reddit, Polycount and even on some YouTube videos, and literally no one has answered. This is driving me insane, I'm starting to think that the answer is some kind of government secret...

    I'm gonna paste here the same thing I already explained in many other places:

    I don't think images are necessary, its apparently a well know thing on Unity.
    Hope I'm lucky here.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,724
    Did you try the different shader like they suggested in that thread? In any case it sounds like definitely a shader issue. Are you using the Builtin Renderer or one of the scriptable pipelines? (URP/HDRP)
     
  3. theMasky

    theMasky

    Joined:
    May 8, 2015
    Posts:
    124
    Hi, thanks for taking your time. I already tried using a different shader (I used Standard and Legacy), but none of them worked, which seems weird, since I faced the same issue in another project a long time ago. I checked the old project to see if I did something else that probably I'm missing, but I couldn't find anything useful. Apparently I did the same before (changed the shader) and it just simply worked, however, it's not working this time, and I don't know why.

    I'm using the Built-in renderer, btw.
     
  4. MallNinjaMax

    MallNinjaMax

    Joined:
    Apr 17, 2017
    Posts:
    25
    I've been trying to figure this out, too. After several days of despair, I finally found the solution. You're gonna hate how stupid this is.

    Unity specifically put a single pragma command in the shaders to make the lighting look like ass. It isn't actually unlit. The shader is just reading directional lights only, with others being per-vertex. Which is why all the leaves light up on one side. All you have to do is remove that one command.

    Download the built-in shaders for your version of the engine in Unity's download archives. Instead of clicking on "Hub" next to it, click on your OS dropdown, and you should see the Built-In Shaders option. Navigate to DefaultResourcesExtra>Nature and Import the TreeCreator folder into your project. Find 'TreeCreatorLeavesOptimized.shader' and open it up.

    The command to remove is:
    noforwardadd

    It's on line 31, at the end. Everything else can stay.

    Apparently, it's supposed to be an optimization, according to the docs. I tested a scene with hundreds of trees using both shaders, and I saw no discernable difference in performance. I'll try thousands at some point, but I don't expect any surprises. Just set your terrain optimization options for trees, and watch your light count.

    Like a lot of things in Unity, their ancient tree shaders are yet another blotch of decay in the foundations of their engine that continues to stink up the place. I doubt anyone has touched this shader code in years.
     
    Last edited: Jan 2, 2021
    MUGIK likes this.
  5. theMasky

    theMasky

    Joined:
    May 8, 2015
    Posts:
    124
    I'm not sure if I already tried that...but I think I remember reading that somewhere (?), guess I'm gonna try it and see if that works. Thanks, btw
     
  6. theMasky

    theMasky

    Joined:
    May 8, 2015
    Posts:
    124
    Well yeah, it worked. Thank you very much! I seriously thought that I would never solve that...but then you came in right in time, thanks dude
     
    MallNinjaMax likes this.
  7. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    453
    Thanks mate, you helped a lot!