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. The 2022.2 beta is now available for testing. To find out what's new, have a look at our 2022.2 feature highlights.
    Dismiss Notice
Dismiss Notice
Submit bug reports tagged with #Beta2022Win_Unity when you encounter unknown issues while testing the 2022.2 betas for a chance to win a year of Unity Pro. For more information, have a look at our Beta Sweepstakes Announcement.

SpeedTree shader broken ?

Discussion in '5.4 Beta' started by AdamGoodrich, Apr 22, 2016.

  1. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,346
    Does this mean Lux includes a fixed SpeedTree shader that will work with SpeedTree LOD and billboarding?
     
    uiniti likes this.
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    lux supports real lambert lighting. that's it.
    if a shader pretends to be lambert all specular highlight will be eliminated.
    i does not do anything to the speedtree shaders but kills specular highlights on speedtrees as speedtrees pretend to use lambert lighting.
     
  3. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,346
    I haven't tried Lux since the Unity 4 days. Do you mean it includes a custom shader to put in Graphics -> Deferred to override the default, and that fixes the SpeedTree lighting?
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    yes
     
  5. looki666

    looki666

    Joined:
    Sep 5, 2013
    Posts:
    79
    Yes . It works :)
     
  6. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    That would mean that you are basically switching from Unity PBR deffered lighting to LUX deffered lighting for all objects?
    Thanks
     
  7. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    389
    Lars is a god... the deferred linear speedtree problem has been fixed:

    a quick example:

    The directional light intensity is set to 5, and as you can see you get a beautiful green and some dark spots.



    All you do is download the zip file here: https://github.com/larsbertram69/Lux-2.01

    Unzip it into your Assets folder. Replace the default deferred shader with Lar's shader. And you're good to go.
     
  8. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    727
    AdamGoodrich and uiniti like this.
  9. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    389
    @sjm tech I have to admit both of the photos look absolutely fabulous, I can't even tell what was fixed :D
     
  10. uiniti

    uiniti

    Joined:
    Feb 4, 2015
    Posts:
    74
    Could Unity check how is lux deferred rendering trees correctly and implement it? @dreyhal
     
  11. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    727
    Another comparison.

    Unity Deferred


    LUX Deferred
    Lux4.jpg
     

    Attached Files:

    Last edited: Jun 21, 2016
    Flurgle likes this.
  12. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    389
    Much better... wow you can clearly see that nasty effect on the grass.

    Do you have a video or more screenshots of what you have here? Is it a game? I'd love to know more. It looks awesome
     
  13. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,346
    Thank you lars. But this is still something Unity should fix. I can't switch the core deferred shader at the moment as I'm using UBER and I don't want to redo a million materials.
     
    uiniti likes this.
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    that is correct.
    lux deferred lighting is based on unity 5.4. but adds support for area lights (if enabled) and real lambert lighting.
    it is meant for pc, mac, linux and consoles as it does not come with cheaper approximations of the main brdf.
     
    camel82106 likes this.
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    well, tom should be able to add a similar feature within a few minutes:

    // take specColor.r as indicator for lambert materials (specColor.r == 0 is outside the pbr range)
    half finalSpecMultiplier = (specColor.r == 0) ? 0 : 1;

    then pass finalSpecMultiplier to the BRDF and apply it somewhere to the specular term e.g.:
    half D = GGXTerm (nh, roughness) * finalSpecMultiplier;

    on may add it to the deferred specular reflections as well.
     
  16. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    727
    [Off-topic]
    I'm glad you like it...here more info!
    Best
    Max
     
    uiniti and Flurgle like this.
  17. dreyhal

    dreyhal

    Unity Technologies

    Joined:
    Jan 5, 2016
    Posts:
    15
    Hey. That's a good workaround, it is killing the specular term completely if you have black specular color. I am happy that it works for you guys, thanks @larsbertram1
    I am trying to introduce a systematic solution to this, sorry for not replying recently. Involving lighting team into this a lot. But it also involves me doing a lot of experiments with vegetation assets to make sure that the PBR based solution will look good and won't turn out broken right after release - especially since it will not be Lambert lighting anymore. Thanks for your patience - I appreciate it.
     
    Last edited: Jun 22, 2016
    Dannyoakes, m4d, uiniti and 4 others like this.
  18. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    727
    Patch 5.3.5p5
    Released: 23 June 2016
    • (790798) - Terrain: Fixed backlit SpeedTree leaves not being correct in deferred shading.
    Is this the official fix of the issues mentioned in this thread? (i'm still on 5.3.4)
     
    uiniti likes this.
  19. dreyhal

    dreyhal

    Unity Technologies

    Joined:
    Jan 5, 2016
    Posts:
    15
    Hi @sjm tech. What this entry refers to is the first change I've given to you a page ago. But right now we start QAing a change that fixes the Lambert shading to not have specular in deferred - as it should have been from the start. The result will be identical to what you have with Lux. If it will pass fine, we will push it to 5.3 also, and maybe allow the user to rollback to the previous behavior with a switch.
     
  20. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,499
    Collaborative solutions & forums at their best :). What a turnaround given that right up to Unity Europe it was possible for people like me to moan excessively about official Unity voices in regards to SpeedTree issues being completely absent from the forum.

    Nice work UT and all that helped find solutions and workarounds :)
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    Nice :)
     
    Dannyoakes likes this.
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    today i have come across a broken speedtree – right in front of our office:

    speedtree_01.jpg
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    i totally read this over.
    does it mean unity will implement physically based translucent vegetation lighting? in both forward and deferred?
     
  24. dreyhal

    dreyhal

    Unity Technologies

    Joined:
    Jan 5, 2016
    Posts:
    15
    @larsbertram1
    I meant that basically it is gonna be StandardSpecular instead of Lambert in SpeedTree.shader. Although the old shader will be available under Legacy.
     
  25. Dannyoakes

    Dannyoakes

    Joined:
    Feb 10, 2015
    Posts:
    118
     
    AdamGoodrich and Dreamaster like this.
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    hmm, on sigle sided geometry with perturbed normals? that looks pretty weird i guess. as weird as it does now.
    using vface will break the translucent lighting effect and still give you a "broken" specular due to the perturbed normals.
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    speedtree shader using vface and standard specular: no "translucency", broken specular:
    Bildschirmfoto 2016-06-28 um 16.38.08.png
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    less perturbed normals (using speed tree modeler), vface and lux deferred translucency:
    Bildschirmfoto 2016-06-28 um 16.45.02.png
     
    sjm-tech likes this.
  29. rstorm000

    rstorm000

    Joined:
    Aug 19, 2010
    Posts:
    226
    Still getting this on 5.3.5p5


    edit: on OSX, linear, deferred
     
  30. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    389
    @rstorm000 are you using Lars's deferred shader? Try that
     
  31. rstorm000

    rstorm000

    Joined:
    Aug 19, 2010
    Posts:
    226
    Not yet, I figured it was fixed after reading the patch notes
     
  32. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    727
    The Issue is still present in the last patch (5.3.5p6) release.

    5.2.3 (the reference and still the best visual for now ).


    5.3.4p6


    5.3.5p6
    5.3.5p6.jpg

    @dreyhal
    UnityStandardBRDF now include some of your modifications but there is no effect in scene ...can you check please ?

    Edit:
    LUX still fix this.

    5.3.5p6 + LUX
    5.3.5p6&LUX.jpg
     
    Last edited: Jun 29, 2016
    dnnkeeper and uiniti like this.
  33. rstorm000

    rstorm000

    Joined:
    Aug 19, 2010
    Posts:
    226
    On top of this, is there any way to make the leaves much more translucent green in the first place. It would be nice to have some more intensity (but obviously not that white effect)
     
    sjm-tech likes this.
  34. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    727
    right ... infact i still prefer 5.2.3 look
    VS.jpg
     
    Flurgle likes this.
  35. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,346
    I was thinking about this thread this morning and felt like I should post something. While I do appreciate the feeling of being listened to, I don't think I and the handful of random people in this thread should be determining the future of Unity's standard BRDF shading model. I'm going to be honest and say I mostly don't know what I'm talking about. I know I don't want white edges on tree leaves, but the particular pros and cons about Lambert vs Phong or tweaking normals vs not or zeroing specular in weird cases is a little beyond me. I feel like there must be specific white papers and expert theses out there by people much smarter than I am detailing how to make a good PBR shader, and really those are the ones that Unity should be listening to, rather than randomly inserting code into the shader and asking four people on a thread in a forum if it looks ok. If this was only specifically about the leaves on the trees it would be fine, but we're talking about changing the core PBR shading model, and that should go through more quality control than just me. :p
     
    Devil_Inside and uiniti like this.
  36. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    389
    I agree, but I feel like they should give us much more choice (multiple types of shader styles, or vastly more options). It is still limited to that one style, with few settings.

    Vegetation is the lifeblood of some visuals. Unity could far surpass UE4 if they can get this right.
     
  37. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    No, we're not talking about changing the core shading model. We are talking about getting SpeedTree to work properly with the core shading model. Ergo it's about actually fixing something that's out of place. Right now the workaround is just to kill specularity, that's not "randomly inserting code". Unity is however working on adding proper specular highlights to SpeedTree which should bring it more inline with the rest of the deferred pipeline. And that will go through QA, so I don't see how any one of us are dictating the future of lighting in Unity. Also, a lot of PBR experts work for Unity now. There was a white paper written just recently about some of the graphical features in the Adam demo for instance.
     
    Flurgle likes this.
  38. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,346
    I think you haven't read the actual thread. Changing UnityStandardBRDF.cginc changes the entire core shading model, not just SpeedTree. The current workaround is not killing specularity; that's what Lars's shader replacement does, which, again, replaces the entire core shading model. The first Unity workaround is changing the way normals are tweaked and the second is cutting specular when the normals are at certain angles, again, for the entire shader model, not just for trees.
     
  39. theprotonfactor

    theprotonfactor

    Joined:
    Oct 10, 2014
    Posts:
    140
    Look, I'm not going to argue over semantics. The workarounds cut off or "kill" specularity at some point. Weather at an angle or completely was irrelevant to my point. It's not "randomly inserting code". I'm well aware that this affects the entire deferred renderer which is why I pointed out that Unity are working to make it compatible with standard specular as you know because you've read the thread and apparently I haven't. That means the lighting on your other objects wouldn't be affected. In fact, I've seen no noticeable effect with the workaround on other objects because their backfaces aren't visible. I'm failing to see this big change you go on about. Regardless, I've said my fill. Agree to disagree.
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    i agree that not only a few people discussing speed tree shaders should determine the way unity's standard brdf looks like.
    but we haven't been discussing the brdf. we have only been talking about how to implement "correct" lambert lighting within the deferred lighting shader. these are 2 completely different things.
    it does not. it only makes it "correct".
    and you pretty much know how things evolve if you rely on unity: things may improve in one direction but get worse in another.
    so unity will need our feedback as it does not run its own game development studio. and the fixes provided by unity so far have proven that they are not ground tested.
    as well as my quick shader hack should have proven that speedtrees will not work using standard specular lighting.
    i just remember that neither unity nor speed tree engineers ever seemed to notice that speedtrees got imported using a wrong handiness thus showing up completely corrupted normal map based lighting.
    and unfortunately this is an ongoing story.
     
    Dannyoakes likes this.
  41. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,346
    Well, I trust you to know what correct Lambert lighting looks like, since you've proven you're very knowledgeable about shaders. I was more saying that I don't trust myself to know what correct Lambert lighting looks like, and that me saying "Yeah I guess those leaves look better?" should not be considered a final test pass before releasing a change to the core shader.
     
  42. dnnkeeper

    dnnkeeper

    Joined:
    Jul 7, 2013
    Posts:
    75
    I discovered that changing BRDF model to BRDF2 via #define UNITY_BRDF_PBS BRDF2_Unity_PBS in UnityStandardConfig.cginc fixes this issue and do not affect any visuals besides it (I assume). You should set Custom-DeferredShading shader in Project Settings - Graphics Settings - Build-in shader settings - Deferred field. All it does is defines BRDF2_Unity_PBS method instead of BRDF1_Unity_PBS.

    BRDF1.jpg BRDF2.jpg
     

    Attached Files:

    Last edited: Jul 2, 2016
  43. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    727
    Good catch, thanks!

    Comparison:
    Comparison2.jpg

    @rstorm000: this can be near your request.
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    well, doing so REALLY changes the BRDF as instead of using GGX (> Unity 5.3.x) BRDF2 uses BlinnPhong (like Unity 5.2.x), no Disney diffuse and only an approximated Kelemen visibility and Fresnel term.
    And it will effect all materials...
     
  45. adventurefan

    adventurefan

    Joined:
    Jan 17, 2014
    Posts:
    222
    great stuff for the trees! question about Lux... can it mix and match with any other shaders we already using for other things? at the moment I would just want Lux's proper tree and grass shading support and to use my current shaders for the rest
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,590
    lux works properly with all kind of other shaders – but you can't use it along with Alloy or Uber as all three use their custom deferred lighting shaders.
    according to the latest posts in the Uber thread tom is going to add a similar fix to Uber too.

    lars
     
    Teila and adventurefan like this.
  47. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,346
    Given that RC 1 was just announced, and the SpeedTree changes aren't in, does that mean that the shader fix and instancing support are being pushed back to 5.5?
     
  48. Alex-Lian

    Alex-Lian

    Guest

    Actually, changes landed just shy of RC1. So, they're in RC2.
     
  49. uiniti

    uiniti

    Joined:
    Feb 4, 2015
    Posts:
    74
    What about Unity 5.3.5?
     
  50. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,346
    Which changes? Will instancing work, or is this just the white leaves shader fix? And is it the lambert-diffuse fix, or the no-backwards-normals fix?
     
    uiniti likes this.
unityunity