Search Unity

Differed Terrain messed up with 5.2

Discussion in 'Shaders' started by AustinRichards, Sep 6, 2015.

  1. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Bug Report Case 725327

    Hi. I'm using the new 5.2 Unity. I saw in the release notes there were some fixes for terrain in the differed rendering path. It looks like this caused an issue.

    I am using the Legacy Diffuse terrain shader (Because all the other 1s are WAY TOO SHINY even on lowest settings).

    As soon as I updated from 5.1 to 5.2 the shininess showed up on legacy diffuse, but it only exists in deferred. In forward, the terrain looks good and perfect.

    Deferred:


    Foward:
     
    Last edited: Sep 6, 2015
  2. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Hi,

    Prior to 5.2, terrain is always forced to render in forward path, no matter which built-in shader you use or what the rendering path setting is. This is because we used to have difficulties blending terrain normals in deferred rendering.

    In 5.2 we found a proper way to blend normals, so we lifted the restriction and terrain is able to render in standard deferred path again. This means in your first screenshot, despite the Legacy Diffuse shader, the terrain is actually rendered with the standard physically-based lighting model (everything rendered in deferred path is), hence the shininess when viewing from grazing angle.
     
  3. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Well, that's good, except that doesn't fix the issue really. Why is the terrain so shiny even with smoothness set to 0.0, and the alpha channel completely black, and the specular color set to black in the standard/legacy spec terrain shader? It looks good up super close but the farther you zoom from the terrain, the shininess is unnatural.

    No matter what shader used, the terrain is too shiny on the lowest settings possible.
    Legacy Diffuse (the 5.1 version) worked for me, because it wasn't shiny. But now that's not an option. Is there anything I can do? Do I HAVE to force the terrain to render in forward by editing the shader? Am I the only 1 experiencing high shine?
     
  4. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    This is using the standard terrain shader. Metallic set to 0. Alpha channel is 100% black. YET IT'S SO SHINY??.
     
  5. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    So for anyone else who has this issue... and wants to use deferred but wants 0 shine terrain, just add

    exclude_path:prepass exclude_path:deferred

    to the end of your pragma on the specular base, first pass, and addpass shaders (which you'd download) and it'll force the specular terrain shader to render in forward which removes the shine. I still wish I could have my terrain in deferred without these issues...
     
  6. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    We discussed this "not enough roughness" issue back in 5.0 beta period. There is a workaround offered in this post that might be helpful.
     
  7. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Yeah that doesn't fix it. I tested it out. It's as if there's an additional minimum shine that can't be altered. I've tried to remove it before in 5.0-5.1 messing with all the terrain shaders, but it appears to be somewhere in the standard shader. It seems to work fine having the minimum shine on normal objects, but on the terrain it looks INSANE.

    This is the standard terrain shader... 100% black alpha channel in the grey texture (really low for the green), metallic set to 0 in both. Even with the Standard Specular terrain shader you get the same results. Is this really intended?

    Deferred, Linear space:


    Forward, Linear Space:


    Deferred, Gamma space:

    Forward, Gamma space:
     
  8. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Yes the root of this issue lies within the standard lighting model. It doesn't allow enough roughness for terrain. The workaround I was referring to is in ReJ's reply (#28). That is, change the roughness / smoothness curve by turning off UNITY_GLOSS_MATCHES_MARMOSET_TOOLBAG2 in UnityStandardConfig.cginc
     
  9. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    I did do the workaround. I tried it multiple ways, and I definitely changed the value correctly, but it does not fix this at all. I imported it into the project, as well as edited the actual cgic file in the program files. I saw no change. :/. (Thanks for helping out)
     
  10. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    You'll also need to download the built-in shader source that matches your Unity version, and copy Internal-DeferredShading.shader into your project folder. Then go to "Edit->Project Settings->Graphics - Built-in shader settings - Deferred Shader", select "Custom shader", and use the one you just copied (which uses your modified version of UnityStandardConfig.cginc).

    Using these steps, you can fully customize Unity's deferred shader and tailor it to meet your project-specific needs.
     
  11. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Still nothing. I copied the internal-deferredshading.shader into the project, and assigned it in the graphic project settings. I have the standard.cgic file with the changed marmoset value. Restarted unity, etc. Still nothing...
     
  12. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Wait! I deleted the deferredshading shader and then put it back... and it "reset" it.... Now I think it's working! :). The standard shader is still shiny but not as much, and the legacy specular and diffuse are working as before!! Thank you!

    Now I can use the legacy diffuse/specular in deferred without the shine! Thanks. I still don't understand why standard is SO SHINY though... even with this change. Do people honestly use the standard shader on the terrain with success?
     
  13. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    So.... The terrain is very shiny. The terrain engine is sending the standard shader smoothness values based on the alpha texture... but not exactly. My 100% black alpha is giving me a smoothness of ~0.2, which is not what I want. So I took the standard shader and just did some subtraction to the smoothness value and managed to make the standard shader work for me in deferred. Annoying, all this stuff, but it worked. Thanks!
     
  14. King-Hayve

    King-Hayve

    Joined:
    Aug 28, 2015
    Posts:
    7
    I'm having this same problem, but I'm not familiar with editing shaders, from reading this it seems the problem was able to be fixed but it's not clear to me what the solution actually was and how to apply it. Any help please?

    Basically I want to use the Deferred lighting option, but I am forced to use "Legacy Deferred" instead because otherwise my terrain will look shiny, even when I have the alpha of my diffuse texture all blacked out.

    This is what it looks like with Legacy Deferred, the terrain looks good but I don't want to use the legacy settings:


    And this is what it looks like with Deferred option, the terrain looks glossy:
     
    Last edited: Feb 7, 2016
  15. nm8shun

    nm8shun

    Joined:
    Jul 14, 2007
    Posts:
    476
    This really is a problem and makes the Terrain engine kind of useless (especially in dark scenes where the terrain all seems to glow with gloss when using Deferred). Is there any fix for this on the horizon (besides editing the default standard shader)?
     
  16. nm8shun

    nm8shun

    Joined:
    Jul 14, 2007
    Posts:
    476
    Just a note, even when using the "Built In Legacy Diffuse" for the Terrain Material, it's still shiny (doens't do this just with the Standard Material).