Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 5 shaders low quality

Discussion in 'Shaders' started by zenGarden, Mar 25, 2015.

  1. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    @AcidArrow - As I said earlier, I doubt it has to do with inverting. I don't own any substance tools to check it out, but I believe it inverts the channel automatically with the Unity profile. What it doesn't do, is midtone level adjustments, required for Unity and Marmoset Toolbag 2.

    @zenGarden - You can see examples of DDO texturing in my thread, that I linked earlier. I was able to achieve almost exactly the same results in DDO, MarmosetToolbag2 and Unity.
     
    zenGarden likes this.
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,624
    You're right. It turns out, gamma adjusting the middle arrow in levels (to 0.4) makes the results in Unity pretty close to substance.

    cymour.jpg
     
    Nanako, minhdaubu2 and Devil_Inside like this.
  3. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Linear is the best for PBR.
    And i don't see any slider in Unity interface to adjust gamma value, three is only Gamma or Linear option , no values options.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,624
    I meant gamma adjust the alpha channel.

    Here's a little fun game: which is which?

    unitysubstance.jpg
     
    minhdaubu2 likes this.
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,624
    In more seriousness though, it seems that apart from the glossiness/smoothness channel, the albedo/diffuse needs some minor adjustments as well, if we are going for 100% accuracy.

    (actually scratch that, if you switch to gamma in Unity, they are nearly identical. I guess the Substance Painter viewport uses Gamma? Linear is pretty close anyway)
     
    Last edited: Mar 27, 2015
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,624
    So... To reply to the original post (and maybe we should change the title?). Unity PBR shaders are not low quality.

    There is the issue of the Substance Painter calibration for Unity not being correct at this time, but as Wes said, it will probably be taken care of, soon I hope. So the point of this thread should be to encourage Unity and Allegorithmic to work together to have an awesome workflow together.
     
    zenGarden, zyzyx and Devil_Inside like this.
  7. Deleted User

    Deleted User

    Guest

    HI,

    We are investigating this. Talking with other developers, I don't think its only a gamma remap, but also Unity has changed GGX to Normalized Blinn Phong by default in the shader. I don't want to give wrong information, so I will speak with Unity to see if this is the case.

    The workflow I use (manually adjust gamma) can help with the remap issue, but not with GGX difference. Adjusting the gamma of the roughness is a workaround but not a complete solution. So with Painter to Unity or any other application for that matter there could be a 2-fold issue of BRDF and roughness interpretation differences.

    Cheers,

    Wes
     
    Devil_Inside likes this.
  8. Deleted User

    Deleted User

    Guest

    Yes, we definitely want to work with Unity to get a correct match and workflow. We will do this : )

    Cheers,

    Wes
     
  9. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    If this is more than just roughness remap, have you considered developing a custom Unity shader for Substance tools, instead of complex export adjustments?
     
  10. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I think it could be a better solution having some PBR shader compatible with substance tools.
    This way we would be no more dependent from Unity future changes and implementations, and we would always have consistent visuals between Substance and Unity.
    Perhaps some Unity shader coders could help Allegorithmic to make some Unity "substance shader".
     
  11. Deleted User

    Deleted User

    Guest

    Yes, this is one of the workflows we are considering. Actually, it may be a Unity PBR shader for our tools. The main issue seems to be a difference in BRDF. The Unity shader seems to be using Normalized Blinn Phong instead of GGX. I may have this incorrect though. We will discuss this with the Unity devs to make sure we have a correct workflow to support the Unity Standard shader system. I'm not sure when this change took place as when we spoke with the Unity devs, they mentioned it was using GGX. Again, I could be wrong here and don't want to speak out of context until we confirm with Unity. However it looks as though the BRDF has changed.

    So we are looking at the following issues:
    1. Different BRDF between Painter and Unity
    2. a custom remapping of smoothness to match marmoset gloss curve in the unity shaders.

    As a workaround, you can adjust the gamma on the roughness map to get a better result. This is not a fix as the BRDF is different and a gamma change will not fix this. We are working to resolve the issue and provide the best workflow for Unity/Substance users.

    Cheers,

    Wes
     
    minhdaubu2, Zomby138, zyzyx and 2 others like this.
  12. minhdaubu2

    minhdaubu2

    Joined:
    Jun 10, 2014
    Posts:
    76
    Hey, can you explain and instruct me how to got your perfect result in Unity 5 please :D
    Thank you.
     
  13. rebit

    rebit

    Joined:
    Nov 13, 2014
    Posts:
    133
    New version of Alloy Shaders have substance shader in the pipeline for import.
     
  14. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    So again , it's Asset store doing better than Unity could do :D
     
  15. rebit

    rebit

    Joined:
    Nov 13, 2014
    Posts:
    133
    Yes, the success of engine is because many intelligent people are using and creating more and more stuff. The open concept bring this. I like Alloy Shaders i watched it pipeline and is really awesome and powerfull. I think if you work with Unity you need to stay tuned with the best indie tools in the asset store ! This not means the engine is not good.
     
  16. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Go for free and buggy or free and incomplete , make your choice.
     
  17. Deleted User

    Deleted User

    Guest

    Yes, Alloy is very great! I highly recommend it. Their implementation is very good and they really know what they are doing with PBR. We are glad to have substance support with Alloy.

    Cheers,
    wes
     
    Deleted User and xenius like this.
  18. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    If you guys ever have any questions about using Alloy and Substance together, feel free to give me a shout in a PM here :). I'm a Substance Designer obsessee (yay making your own tools hehe), so we spend a lot of time trying to find the absolute best workflows.

    Also, just in case you didn't know, you can set the Alloy custom shader to be your default in substance designer if you'd like it to always be set to that when you create a new graph. While our BRDF implementation is near-identical to SD's default, we do some extra custom shading for specular occlusion, so its always best to use our custom shader in there if you want as close to 1:1 match as possible.
     
    hippocoder likes this.
  19. Deleted User

    Deleted User

    Guest

    Hi,
    We are working a workflow for getting a closer match to the Unity shaders. This is an approximation as the only way to get a 1:1 match as @xenius mentions is to use a customized shader that establishes a specific pipeline. In terms of Unity, there are many aspects to consider such as BRDF differences and that we use multiple importance sampling and unity uses pre-filtered cube maps.

    We are taking into consideration the nature of Substance support across multiple engines and applications similarly to what Unity has done with their implementation and cross platform support. Creating a specific unity shader that locks substances only to unity's implementation of PBS would not be ideal for our substance material workflow and ecosystem.

    PBR is a great workflow, but since there is not a "set in stone" standard, issues such as what we have here with Unity arise. The concepts and data used to make the maps are standard, but the implementations are where the differences appear. I will be sharing more info and a full tutorial on how to best work with Substance and Unity. We are very committed to Unity and will have workflow in place to solve these matching issues.

    In terms of the current workflow, changing the reflection probe resolution in Unity changes the aspect of the minimum smoothness. I think the default resolution is 128, but changing this resolution will affect the smoothness. This becomes and issue because you get a different result at a smoothness of 0 just by changing the resolution of the probe.

    Also, the albedo color has a uniform color set to gray. The albedo is multiplied by this gray, which leads to a darker color. This uniform color value should be set to white.

    Cheers,

    Wes
     
    Dantus likes this.
  20. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Hi Wes,

    Thank you for all this valuable informations. I understand having some Unity specific shader would complicate the workflow, but i hope the exported bitmaps for Unity to match better with Unity requirements without needing us to use some paint program to adjust rought or metallic.
    A good tutorial on how to adjust Unity probes and other features is welcome.
     
    minhdaubu2 likes this.
  21. Deleted User

    Deleted User

    Guest

    Hi,

    We will be able to have a very good match with Unity. Our engineers have been in talks with Unity. I can't say too many specifics at this time as it involves Unity development and I can't openly discuss their plans, but I will say things will be looking good : )

    In the meantime, the resolution for reflection probes is a definite bug. Unity as confirmed what we reported to them. Changing the cube map resolution should not affect the smoothness map. This is something Unity is working to fix although they didn't give us a timeline. This is a major bug in Unity at this time.

    Here is the correct workflow at this time considering Unity's different BRDF and their reflection probe bug.

    Unity Setup:
    1. Use Linear for Color Space
    2. Albedo Color set to White.
    3. Use same environment used in Painter. Import the exr map and set it to cube map in linear. Use True Color and Glossy Reflections.
    4. Use a reflection probe resolution setting of 128 or 256.

    We have prepared a substance material to apply a gamma curve to get a better match as well. Using the above settings in Unity and this Substance material for correction, you can get a decent match.

    To use in Substance Designer, just plug your roughness into the input and the output will go to your final output node.

    To use in Substance Painter, import the substance and apply it to a standard layer as a Filter Effect. For the standard layer, set the the channel mode to roughness and set the layer blending mode to Pass Through.

    Cheers,

    Wes
     

    Attached Files:

    zenGarden likes this.
  22. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,624
    You need to do a bit of a better job at showing off your shaders. Before Unity had any PBR it was obvious, now that Unity has PBR things have become a bit muddier. I understand you have better speculars, better texture packing and proper falloffs, but is that it? I see a list of features on your site, but that's just what it is, a list. I see Specular Occlusion Formulation, I can guess what it does, but I don't KNOW what it does. I also don't know how it performs etc.
     
  23. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    @AcidArrow A very valid criticism. I often let my general distaste for aggressive marketing, and the negative tone that all too easily comes out when folks argue over what's 'best' get in the way of better communicating the merits of our product.

    Further, our energies right up until GDC were spent largely running on the treadmill of Unity5 betas (which was... special). Right now I'm working on documentation and videos, which should hopefully show off the differentiating features better. Until then, I'd be happy to give you a run-through over skype (pm me your sn) if you'd like to be sold on things. :)
     
  24. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I hope Unity will resolve this critical bug, and i 'll be waiting to see what the solution will be ?
    Having substance painter PBR textures looking as good in Unity out of the box will be great :)
     
  25. minhdaubu2

    minhdaubu2

    Joined:
    Jun 10, 2014
    Posts:
    76
    Hey, did you post wrong version of that Unity_curve material? Because object look even smoother than normal.
    With curve:

    Without:

    That actually means it would look even far more wrong in Unity.
     
  26. Deleted User

    Deleted User

    Guest

    Hi,

    That should be the correct version. In Substance Painter, you need to be sure that that the layer you apply the filter has the blending mode set to Pass Thru for the Roughness channel. With that said, it still can produce a slightly more shinny affect, so I will check with the devs. The testing we did seemed to match. We are using a gradient to remap the gloss curve in Unity to basically cancel it.

    Please give it a test and let me know if its not working for you.

    Cheers,

    Wes
     
  27. minhdaubu2

    minhdaubu2

    Joined:
    Jun 10, 2014
    Posts:
    76
    So, actually did like your instruction and this is the result:
    ---In painter:

    ---In unity:




    ---In painter:


    ---In unity:




    ---Painter export setting:


    ---Unity lightning setting:


    -Cubemap Glossy reflection and trilinear checked.
    -The result is so much glossy.
    -Please help. :D
     
  28. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    This is what i see with every UT5 materials or people work too reflective and color is brighter also.
    Unity should improve the default shader, it will be needed when more and more people will go PBR.
     
    minhdaubu2 likes this.
  29. Allegorithmic

    Allegorithmic

    Joined:
    Apr 1, 2015
    Posts:
    11
    Hi,

    Can you please send me your Painter project? I will take a look. Please send to wes.mcdermott@allegorithmic.com and add a reference to this thread.

    Cheers,

    Wes
     
    minhdaubu2 likes this.
  30. Allegorithmic

    Allegorithmic

    Joined:
    Apr 1, 2015
    Posts:
    11
    Hi,

    I checked the files. I think that using the gloss curve correction is no longer valid. I will update the thread on our forums. I have a suspicion that in Unity 5.0.1p2, they could have removed the gloss curve remap. They mentioned they were going to do this. I am trying to validate it with Unity. They are still using Blinn-phong for BRDF.

    In 5.0.1p2, they are now defaulting the secondary albedo color to white, which is correct. So now, you should just export your textures without the roughness correction. However, it looks like its shifted a bit towards not as glossy as Painter. This can also be impacted by the BRDF (not GGX) and the difference of Painter using importance sampling and Unity using a mip-glossed cube map.

    However, the reflection probe still has a major impact on glossiness. By default, its set to 128, which is producing an incorrect gloss on this scene. I set the reflection probe to 1024 and it looks better. Here is what I did for your scene. I also tested this with a metal. It seems to give a better match at the 1024 resolution for the reflection probe. The highlight is still off which is due to the BRDF. Its not perfect, but its getting better.

    1. Add reflection probe, set the resolution to 1024
    2. Turn off Built-in Lighting


    Cheers,

    Wes
     

    Attached Files:

    Nanako and minhdaubu2 like this.
  31. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    If Unity is changing and breaking PBR rendering each release, how could other software provide good eporters ?
    I'm suprised Unity shader engineers not be here on the forum and exchanging about what they are doing or plan for PBR.
    They don't care a lot to have good PBR it seems :rolleyes:
     
  32. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    This is a pretty good breakdown from Unite, and addresses some little gotchas you might be experiencing in Unity.
     
  33. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    I use dDo all the time, and with great results. There is not a 1:1 3Do to Unity translation naturally, but it's pretty close. Also, all of the export calibrations are in jsx files that can be modified or custom ones made. I've made a few custom export calibrations for a few different uses(like putting the opacity map in the albedo alpha channel).
     
  34. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Btw, in the next DDO update they said the 3Do shaders will be identical to Unity5. That's probably because they will update 3DO to use Unity 5 :)
     
    echo4papa likes this.
  35. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Yes. When and if 1.9 is ever released...
     
  36. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I would like to have Substance coming with same stuff :rolleyes:
    But how DDo will do if Unity changes again the shaders ? It will be the users to create the good calibration option it seems.
     
    echo4papa likes this.
  37. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    No, Quixel is using Unity to make the new 3Do. Rather than using Marmoset Toolbag. Or so they have implied.
     
  38. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Actually the current 3DO is also made with Unity, probably 4 with custom shaders. I think they will just update the project to use Unity 5 and the standard PBR shaders that come built-in. Seeing how Unity 5 shaders are similar to Marmoset, they'll kill two birds with one stone.
     
  39. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Really? I could have sworn they worked with Marmoset for 3Do.
     
  40. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    I just browsed to the 3DO folder inside the Suite installation, and it looks just like a regular Unity standalone build, with all the familiar files in there :)
    They might be using Skyshop in their current version though, so that's where Marmoset might come into play.
     
    echo4papa likes this.
  41. G-Mika

    G-Mika

    Joined:
    Jul 17, 2012
    Posts:
    99
  42. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    If we open the exported Albedo and metallicSmoothness maps in Photoshop to do some tweaks - what do we have to keep in mind? Will Photoshop mess with the images (e.g. convert them from linear to gamma on save)?
     
  43. Deleted User

    Deleted User

    Guest

    From someone who's had to muck around inside most of these tools while building his own framework, here's the short list of differences between Unity, Substance Designer/Painter (SD/SP), Disney, Unreal Engine 4 (UE4), Alloy:
    1. Metallic maps
      • Unity applies a gamma curve to their metallic maps for some reason.
      • Alloy/SP/UE4/Disney uses it as a raw linear value.
    2. Smoothness/Roughness
      • Unity's smoothness parameter uses a mapping similar Marmoset Toolbag.
      • Alloy/SP/UE4/Disney uses a modification of Beckmann roughness which is standard among BRDFs.
    3. Diffuse BRDF
      • Alloy/Unity/Disney uses Brent Burley's diffuse BRDF which is affected by roughness.
      • SP/UE4 uses plain old Lambert.
    4. Specular BRDF
      • Unity uses Normalized Blinn Phong, even though they also have the code for GGX but disable it by default.
      • Alloy/SP/UE4/Disney uses GGX, although they each use different visibility functions.
    5. Environment BRDF
      • Unity uses a weird combination of luminance and smoothness to control the rim fresnel.
      • Alloy uses an analytical approximation created by Treyarch and revised by Epic.
      • SP uses importance sampling with GGX.
      • UE4 uses a precalculated lookup texture.
      • Disney uses raytracing with GGX.
    6. Occlusion
      • Unity applies AO to both the diffuse and specular ambient contributions.
      • Alloy applies AO to ambient diffuse, and calculates Specular Occlusion from AO to apply to direct and ambient specular.
      • SP applies AO to ambient diffuse and uses a trick to occlude specular that should be blocked by the geo.
      • UE4 ???
    Probably not a complete list, but it is the most complete one I have seen thus far.
     
    Last edited by a moderator: May 6, 2015
  44. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Really need some vocal input from Unity, or blog posting. A discussion why things are the way they are.
     
    echo4papa likes this.
  45. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I baught Alloy, i don't care anymore about Unity PBR bad shaders . That's sad to say , but it is the reality about Unity 5 shader that has been working from more than one year and is still bad :rolleyes:
     
  46. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    There's nothing bad about Unity's shader. It's just misunderstood. I like it because surface shaders means I can easily bang out a working shader that has physically based lighting without any effort.
     
    echo4papa and Devil_Inside like this.
  47. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    In the principles they are good.
    When you don't need to write shaders and just need good shaders out of the box, Unity 5 just looks bad and Alloy is perfect with substance painter as it provides the same shader for Painter program to have a perfect match workflow.
     
  48. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah I understand they're doing something about that. I use Alloy myself, we have a few licenses scattered about. I think that the key thing to take from this is that there's a tool for each job. I don't use Alloy blindly, just where it is precisely needed.
     
    zenGarden likes this.
  49. Allegorithmic

    Allegorithmic

    Joined:
    Apr 1, 2015
    Posts:
    11
    Great post! Very informative.

    I spoke with our engineers and can provide some additional information specific to Substance as it relates to the points listed above.
    • Alloy/SP/UE4/Disney uses it as a raw linear value.
    Since metallic maps in well behaved materials should be mostly either black or white, this should only cause differences in the small areas where one is transitioning from dielectric to metal.
    • Alloy/SP/UE4/Disney uses a modification of Beckmann roughness which is standard among BRDFs.
    This bullet may be referencing Disney's suggestion to reduce "hotness" by remapping the roughness value. The UE4 paper from Siggraph 2013 (page 3) suggests to do the same. If that's the case, Substance PBR shaders never followed this and from our discussion with the Epic devs, UE4 no longer does this as well as of around august 2014.

    • Alloy/Unity/Disney uses Brent Burley's diffuse BRDF which is affected by roughness.
    • SP/UE4 uses plain old Lambert.
    Unreal communicated to us they chose to keep using Lambert because it does not make a whole lot of difference visually, so changing it was not worth the extra cost.

    • Unity uses Normalized Blinn Phong, even though they also have the code for GGX but disable it by default.
    • Alloy/SP/UE4/Disney uses GGX, although they each use different visibility functions.
    With the exception of the roughness remapping ("hotness") discussed earlier, those differences should not make a lot of difference visually. It all comes down to the fact that game engines tried different approximations to gain a bit of speed here and there, while still having the same results, and we didn't bother because it's not that important for our shaders as they are not running in a game engine.

    • Unity uses a weird combination of luminance and smoothness to control the rim fresnel.
    • Alloy uses an analytical approximation created by Treyarch and revised by Epic.
    • SP uses importance sampling with GGX.
    • UE4 uses a precalculated lookup texture.
    • Disney uses raytracing with GGX.

    The method Disney uses is also some kind of importance sampling, the main difference being the number of rays we cast per pixel (by default 40, at max 256) cannot be as high because we need to get the results in realtime. If we could increase that number of samples indefinitely, it should give the same results. At 256, it should already be very similar at small to mid roughnesses (let's say from "mirror" to "silverspoon" ;) )

    Cheers,

    Wes
     
    Deleted User and Dantus like this.
  50. Deleted User

    Deleted User

    Guest

    @Allegorithmic
    Hey Wes. I hope my list didn't come off as a criticism of the Substance tools. I was merely trying to list why Unity and Substance Painter can't match up by simply remapping values. If anything, I was trying emphasize why every engine needs a custom preview shader for Substance Painter in order to get the best results. Ideally, this shader would be written by the engine-provider since they would be the most knowledgeable about their pipeline.

    I also thought I would clarify some points:
    • Alloy/SP/UE4/Disney uses a modification of Beckmann roughness which is standard among BRDFs.
    Here I was actually referring to Disney's suggestion to use a squared input for Beckmann roughness, since raw Beckmann roughness doesn't produce perceptually linear changes in roughness.
    • Alloy/Unity/Disney uses Brent Burley's diffuse BRDF which is affected by roughness.
    Again, not a criticism of SP or other engines. We chose to use Burley's diffuse BRDF because we found the subtle difference to be pleasing and thus worth the additional cost.