Search Unity

UBER - Standard Shader Ultra

Discussion in 'Assets and Asset Store' started by tomaszek, Jun 23, 2015.

  1. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    UBER doesn't work exactly the same as standard shader. Two main differences are - heightmap sampling from a channel (instead of G) and detail blending is lerp instead of mulx2. You can make UBER to work exactly the same as standard shader though - then fallback to Unity's shader will be smooth.

    Your suggestion makes sense though. I can set LOD of my shaders to something higher that Unity has and set fallback to standard shader - that makes sense.

    Tom
     
  2. Plutoman

    Plutoman

    Joined:
    May 24, 2013
    Posts:
    257
    Thanks. Now that the documentation is up-to-date, that clears up pretty much everything. I completely missed the tooltips, though, I was going to suggest you add some and then realized that hey, they were there the whole time.

    As far as LOD's go, yeah, for my own specific case, a perfect reproduction is not necessary as it's close enough to grab the scene's ambiance, even if not exact in case of details, so the lerp style isn't a big deal, as my intent with lower settings is to allow playability instead of recreating the perfect scene.

    Using this has also convinced me to snag RTP, I'm going to hijack some of it's features for my own terrain. I've required a pretty custom solution but there's plenty in there that I can utilize to make it look as good as most of my meshes are now looking.
     
  3. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Today's version of pdf docs are even more up-to-date (glitter, translucency in forward and deferred, presets described).

    http://www.stobierski.pl/unity/UBER.pdf

    Missing parts are still:
    - POM types (that's this baking stuff and so on).
    - Triplanar selective
    - 2-Layers variant
    - Refraction
    - Tessellation
    - Custom configuration of shaders (texture channels used, vertex colors, switches and defines per shader and in uber config .cginc file).

    I'm trying to post it quickly but all these screenshots, describing and formatting takes more time than assumed (as usual :) ).

    Tom
     
    DrewMedina likes this.
  4. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    ,,
    Great info, thank you. Im developong for VR and the minimum is GTX970, which sounds perfect... I am using the distance based tesselation, I assume the poly wobling is part of tesselation. I have to push put the low detail pretty far to avoid my rocky ground from coming to life and wobling arpund as i walk... It is stunning being in VR and seeing every detail in full stereo depth, and i can dial it in in realtime....so way beyond a parallax map, which doesnt give real depth.
    ill post screenshots sometime.

    Im not a programmer, but that option to use vertex color sounds really great. Any chance you could include it in the future? Its beyond me to set it up...
    Thanks!
     
  5. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Wobbling is typical behaviour for distance based tessellation amount. There are some techniques to reduce this, but I haven't read much into yet. As you've noticed - you need to select distance far enough to hide it.

    POM effects will not wobble and can provide even better resolution over tessellation, but currently they are broken for integrated VR in Unity. We're still waiting for Unity fix on this (shader need to hae correct camera position available - separately for left and right eye, now it's constant...)

    For tessellation amount based on vertex color look at any of your tessellation shaders doe. Open it in mono and find this:

    Code (csharp):
    1.  //#define VERTEX_COLOR_CHANNEL_TESELLATION_AMOUNT r
    you need to uncomment this line and you can additionaly sepcify which vertex color channel controls tessellation amount. Save shader after tweak and it will work. You don't need any coding expereience on this.

    Tom
     
  6. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Thanks again Tom. Thats great news, please let us know when unity fixes it! I will switch to POM if that's the case. I did notice unity4.6 used to do a good job with parallax mapping in VR, maybe it broke going to 5?
    Cool, i can modify code just about that much hehe... thanks for the help, really appreciated!
     
  7. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    250
    hi Tom!
    I must be doing something wrong...I cannot get it to work with a new clean scene.
    I updated your package, imported the first package, then the example scene.
    1. I started a new clean scene...
    2. added a sphere...
    3. created a fresh new material and assigned Uber core spec shader...
    4. I tweaked on diffuse slider...nothing changes. (although changing the alpha slider did have some effect, but changing the smoothness slider didn't )
    5.Enable snow...tweak some settings..nothing changes...

    6. When I open the examples, I can change all settings but creating something new from scratch doesnt seem to work.
    Looks like I am missing something obvious, but here I am being blind then...

    I am on windows U 5.1.2 btw
     
  8. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    By default specularity is set to white which means - diffuse color doesn't matter (this is like fully metalic object with white metal color). The exception is diffuse scattering with replaced color (diffuse scatter alpha is 1). Set specular color to dark (dielectrics have this set to grey RGB 0.04) and you'll see diffuse. This is the way PBR works.

    For snow - it should work. For sphere object and new material it covers top part of the ball with snow. Look if your shader changed to DynSnow version after you selected Snow in material inspector (it replace shader instead of changing the way shader works).

    Tom
     
  9. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
  10. Tudor

    Tudor

    Joined:
    Sep 27, 2012
    Posts:
    120
    Hey Tom, do you mind shedding some light on how you managed to edit or to build on top of the unity standard shader?

    Your uber shader is a brilliant contribution, but I for instance need to be able to have a custom Standard / Uber shader which has 2 Albedo textures with a slider to blend between them in a certain way at runtime.

    I can't figure out how the heck can I modify this multicompiled built in shader. People keep saying "just download the 900.000.000 lines of code pre-compiled Standard Shader and edit and use that." but that's not a solution for a number of obvious reasons.

    Cheers!

    PS: is there a way I could buy your uber shader + its code (a way to edit it's source)?
     
  11. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Unity Standard Shader is distributed over a lot of .cginc files. It's OK modular solution, but to change anything inside is difficult now, esp. when you're not familiar with shaders.

    Download source code of Unity shaders. You need at least one include file and standard shader. Diffuse/Albedo is sampled in StandardInput.cginc file (Albedo function). Put there another tex2D function with sample to your 2nd texture and lerp the value with additional parameter. You need to declare sampler2D Albedo2; for texture and half someLerpParam; at the top of input include file. Then you need to tweak material inspector GUI (placed in Editor subfolder) to add these 2 parameters (DoAlbedo function).
    After tweaking sucesfully cginc Input file, and editor standard shader should recompile with tweaked include files and work the way you need. Remember to place includes in the same folder as standard.shader.

    Tom
     
    Tudor likes this.
  12. Tudor

    Tudor

    Joined:
    Sep 27, 2012
    Posts:
    120
    Okay now I get it. So you extract that shader source archive, put the directory in your Shaders folder, edit the .cginc files (make sure the paths are correct cause by default they are not), and the local Standard shader in there will compile with the cginc changes.

    So then I see that I will have to manually migrate all my cginc changes to any eventual new versions of those cgincs that unity puts up in the future...

    Thanks a lot for the tips of where to find the albedo sampling and gui changes!
     
  13. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    That's correct, with U5.2 Unity made some critical changes to cginc files. If you've got access to this beta (Pro users) you can compare includes. I'm not sure if StandardInput.cginc is subject for change, but other - for sure as GI reflection probes are not accumulated to color on shader stage, it will be rather set after lighting in screenspace.

    So - I've got the same problem every time Unity changes something in their rendering pipeline... :) (ironically I'm not that happy despite of smilie I put here).

    Tom
     
    Tudor and hopeful like this.
  14. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    483
    Hey Tom had a question for you on the UBER Tessellation shaders. Im working on a cave scene and each cave piece has 2 materials 1 for the celing/walls and the other material for the ground. When I use a tessellation shader on the ground it breaks the mesh slightly apart where the 2 materials meet. So there's seams in spots all over the place for the entire cave network.

    Wondering if you can add some sort of option like "protect borders" so it only affects whats inside the mesh and leaves the outer edge borders alone. 3ds max has a plugin called Pro Optimizer that decimates a high poly model and you can protect borders and UV boundaries and only affects whats inside the mesh leaving edge borders alone.

    I know its not an easy solution was just wondering if at all possible to look into something like that eventually for tessellation shaders. Thanks.

    -Miguel
     
  15. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Sorry, but I don't know the method for shader to determine which edes are borders (when belong to two triangles) and which are internal. It's probably not resolvable on shader level unless we add another switch from vertex color that would store the info (vertex color component = 1 means - border - don't displace it). Would it be practical solution for you ?

    Tom

    P.S. Currently there is similar switch (by default it's not used) which determines the level of tessellation from original mesh vetex color.
     
  16. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,184
    Hiya, picked this great asset up, but wondered how it works with deferred replacement shader - already using alloy for that. Am I right in assuming it's OK to leave the alloy one in place?
     
  17. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Newest Alloy update (not sure if already submitted by Anton or Josh) should have dedicated replacement for Alloy+UBER working together. If not - UBER has replacement already available included as well + txt info included how to quickly make Alloy deferred lighting shader UBER compliant. That's what you probably like to know :).

    Using Alloy original deferred lightng shader - UBER translucency and POM self-shadowing don't work.

    Tom
     
    hippocoder likes this.
  18. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,184
    OK Thanks!
     
  19. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Hi tom,
    There was a post from unity here discussing broken parallax in stereo and unitys new per eye controls. Helpful?

    http://forum.unity3d.com/threads/re...ax-effect-with-native-vr.344239/#post-2235616

    Developers who are working on the Relief Terrain Pack can now edit their Package to include prefab that covers this case. They just need to use the individual eye content in 5.1.2p1 (http://forum.unity3d.com/threads/different-content-in-each-eye.332575/) You could also implement the changes locally with their package's assets. I suggest using 5.1.2p3 when it comes out this week though. Because 5.1.2p1 has a bug with both cameras being placed at the left eye position.
     
  20. weasel47

    weasel47

    Joined:
    Mar 9, 2014
    Posts:
    26
    Version 5.1.2p2 (released a few days ago) restores this functionality, it seems. I'll have to look at your documentation to find out how to set up POM properly, as I've gotten a lot of distortion in my attempts so far.
     
  21. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    584
    Hi,

    this asset looks amazing and it works with Alloy shader! I have vehicles where I want to show a damage texture depends of the damage state. This could be probably possible with transparency settings. But however, I need a second texture, which blends over the first texture. Is this somehow supported in your shader?

    I would need the following textures for my Units:

    PBR shader (albedo + metalic + normal) -> blend dirt (from bottom to top, albedo + normal) -> blend damage texture (albedo + normal) -> blend wetness/snow

    The question is more, is there a way to add some new blending passes to the shader?

    Thanks for the answer in advance!
     
  22. weasel47

    weasel47

    Joined:
    Mar 9, 2014
    Posts:
    26
    I have a few questions after reading the documentation and trying some things.

    If I'm using deferred lighting, do I need the camera component and special shader for transparent translucency or only opaque? Does transparent use forward anyway?

    Translucency seems to be working somewhat, I'm just having a little trouble getting it exactly the way I want. Is it expected to glow from directional light even with a wall in between?

    It seems the texture importer that creates special mip maps for POM height maps won't come in to play with substance materials. Is there any easy way to deal with that? How important is that to making POM look right?

    If a POM material is used for multiple meshes where it has the same scale, is there any need to bake ratios into UV4? In particular, I'm using ProBuilder meshes with tiled materials. Do I just need to translate the scale of the UVs into object space manually and enter the values?
     
  23. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Transparent shaders mean forward only (even if they are shown is they would be rendered in deferred but this is simply misleading info in Unity when swtiching to "rendering path" in Unity scene view window).

    Wall between light source and translucenct object - if the wall casts shadow you will get translucency blocked, but it might be not desirable when translucent object itself get selfshadowing that blocks translucency. I've introduced shadow suppress control in UBER, but for wall vs. object you might get better results using shadow proxy approach described in my pdf. It works fine with convex objects though. That's why translucency in UBER is stated to be approximation one. Works very fast but does not cover some situations.

    POM from substances + baked gloss/height - indeed it doesn't work dynamically with substances, but it shouldn't be of that much problem currently. Spec/gloss maps are baked to equalize specualr power over higher MIP levels used. Additionaly it can take variance from normalmap. Heightmaps take max value from 2x2 pixels from lower MIP instead of average. Currently this is not actually necessary though (I prepared it for future QDM POM implementation, but I doubt I will introduce it in next releases as the technique is probably not worth the effort in most cases).

    If texture distribution ratio to object local space distances are the same in all objects that uses the same material it might be not neccessary to bake ratios into UV4, but it probably won't work in most real cases except for some simple one like cubes, planes, UV mapped the same way (covering in the same UV range in object space).

    Tom
     
  24. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Yes, I'm aware and waiting for "native" solution for "native" VR support. Seems like p2 got it, 5.1.3f1 should have it fixed as well. Without any less or more fancy workarounds. I could even fix this before, but it would be insane to compare MVP matrix multiplication results in pixel shader :).

    BTW - this wobbling tessellation issue I'll try to fix in new update. This will work very simple way - with this reduction of tessellation amount with distance I'll make sure that I don't displace anything untill target tessellation amount has been reached. Like - distance 20, fade distance 5 - from 15 to 20 units I reduce tessellation amount from 100% to 0%, but I'll start reducing displacement sooner with 10 to 15 unit distance. At 10 units we've got full tessellation and full displacement at 15 units we've got full tessellation but no displacement. At 20 we've got no tessellation and no displacement. I will maybe test some overlapping scenarion as well lke displacement reduction a bit farther maybe.
    We've got also 2nd tessellation amount factor - edge length in screen space, but this is reducing factor only (it can only tessellate less than more) so it won't make problem I assume.

    EDIT: edge length limit might introduce wobbling obviously I was wrong, because anything that changes tessellation amount thru camera position/distance will make it. I'm checking if this is real problem or not. Anyway I assume it will improve anyway.

    Tom
     
    Last edited: Aug 5, 2015
    DrewMedina likes this.
  25. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    With dirt alone you could use secondary maps (detail) for this I believe - they have separate PBR (to make dirt or rusty parts less shiny for example), but what you're asking for is next layer in the pipeline (damage). It can't be introduced simple way as they are kind of trietary maps (after primary ones and secondary detail ones). Water+snow is placed over the surface, it's not like "additional blending pass" in shader, it's placed inside one, main shader pass together (additional passes cost additional geomtery rendering which means additional drawcalls BTW).

    For damage maybe it would be possible to add some decals (separate mesh placed over). They would be transparent (so - forward rendered unless you deal with deferred decals thru command buffers like in Unity's examples available), but if you'd use POM for them (w/o z-write) you can even have bullet holes that are really pushed inside, haven't tried, but it might look pretty cool. With UBER shader for decals they might have water+snow mapped globally and should be able to get covered by water and snow uniformly together with underlying surface.

    At some point introducing water&snow in screenspace might be also interesting idea for deferred (before lighting passes), but I don't have real plan to implement it soon.

    Tom
     
  26. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    584
    Thank you for your answer!

    I guess I will use the Alloy shader for my units, they have a good support for different layers but I will definitely find a place for your shaders too, because they are in another way superior too.
     
  27. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    230
    Water effect on objects looks nice but add a light and water droplets will disappear,... all water effect will disappear.
    How to fixs that?
     
  28. Plutoman

    Plutoman

    Joined:
    May 24, 2013
    Posts:
    257
  29. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    @tomaszek @hippocoder
    Sorry about the delays with the official Alloy UBER support. We've trying to get that update out the door, but during testing we ran into some problems in our static directional specular lightmapping code.
     
  30. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,185
    Could you describe how to setup a Glitter Mask more in-depth? The documentation doesn't go into what type of texture it should be. Currently, I have a texture there in the glitter mask, but nothing shows up on my mesh.
     
    DrewMedina likes this.
  31. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Speaking of glitter... Im having an issue with the glitter moving with the camera across a surface... hopefully the info you give Ben Bearfish includes why, unless its the nature of it. The glitter moves, not just the highlight across the glitter that is static.
     
  32. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Is it in forward lighting ? Will need to check when I'm back in the mid if August
     
  33. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    It's red channel of the glitter texture. Extract it with my texture channel mixer to see how it looks like. For masking glitter effect put it into occlusion texture. Look at my carpaint like example. There is a mask applied.
     
  34. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    When the camera moves glitter moves. Offset for glitter tex samoling depends on cam pos and orientation with object pos and orientation. It might however look weird when using too high density. Result might be not enough 'random'
     
  35. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
  36. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Shouldn't only the highlight move across the glitter? When the glitter itself moves it is like a layer of liguid glitter, not specular highlights catching on small bits.
    Thanks
     
  37. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    920
    @tomaszek Hi,

    a couple of questions:

    1) any chance to use it on mobile?

    2) can you add a double sided option?
    (is for support geometry with reversed triangles)

    Thanks,
    Kenshin
     
  38. imtehQ

    imtehQ

    Joined:
    Feb 18, 2013
    Posts:
    230
    Yes, but tryed with other options same effect.
     
  39. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Mobile version is considered. Reduced features though. No fancy POM this would be too slow.

    2 sided is on the roadmap.
     
    Plutoman and Rycons like this.
  40. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    920
    Great, thanks!

    I hope to see 2sided soon.
     
  41. Lasse-Loepfe

    Lasse-Loepfe

    Joined:
    Mar 28, 2014
    Posts:
    25
    Hi,
    I have a (hopefully) small feature request: Add a delay value to the emission pulsate.

    Thanks
    Lasse
     
  42. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
  43. Plutoman

    Plutoman

    Joined:
    May 24, 2013
    Posts:
    257
    Mentioned that just up above. :D

    Maybe the last question - could you note what the -completely approximate- performance impacts would be of each section? ie - wetness, is that just some modification of PBR variables + a texture read, depending on the settings, vs translucency, which involves a lot more.

    Just looking for a ballpark as to how much impact the settings have - with reference to the core shader (not necessarily with reference to FPS, but rather just a rating of 'low' 'medium' 'high' 'very high' impacts on the rendering time of the shader without those features.. obviously can only be a ballpark since rendering is so variable).
     
  44. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    In ordet of heaviness' pom adv. Mapped, pom adv. Basic, pom with z- write is heavy, water with rain, water with flow, snow, glitter, translucency is the least heavy. Then some detail maps. Pom with distance map is cheap (exception)
     
    Plutoman and hopeful like this.
  45. Plutoman

    Plutoman

    Joined:
    May 24, 2013
    Posts:
    257
    Sweet. Thanks! Just wanted a general idea.

    Guess I'm not totally done.. but I'm exploring the translucency right now. Would you have any ideas on how to better represent colors? I love the setup right now, but I'm just exploring the possibilities of better reflecting light colors + diffuse colors.. Especially if I don't use allow, thus allowing an extra GBuffer channel. Like per light translucency instead of per object.. hmm. Or take the color as the blend of light colors at that position. Not particularly sure. Moving it into forward is always a possibility, it's a great implementation there, but also expensive since I rely on lots of dynamic lights.

    Oh, I guess it is, just not as dramatic as I thought. Best to leave the coloring as white it seems like for most objects, I presume, in the general-case?

    Edit: Yeah, this is turning out quite well. I'm not well-studied on translucency, but if there is anything I could add to the extra GBuffer, I'll take it.. but otherwise it's turning out quite well and very inexpensive in the deferred context.
     
    Last edited: Aug 13, 2015
  46. Avonaeon

    Avonaeon

    Joined:
    Apr 17, 2012
    Posts:
    48
    Hey Tom,

    I'm getting an error when trying to use the Dynamic Snow / Metallic shader. I'm using DX9.

    Is it because DX9 doesn't support dynamic snow?
     
  47. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    Translucency color is always light color dependent (that's why white translucency tint works best in most cases except for specal cases like skin that have red tint from underlying blood). I have translucency -per light param which is translucency power per light stored in light color alpha channel, but this is often used by 3rd party stuff (like Alloy to handle area spherical lights) so I disabled this (can be enabled in UBER config cginc file).

    Actually we don't have much room in gbuffer now. Everything available is used or will be used soon (U5.2 diffuse a channel for occlusion).

    Tom
     
  48. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,756
    I can reproduce the issue for DX9, but currently have no idea why it doesn't work. Will report you on this.

    Tom
     
  49. n00body

    n00body

    Joined:
    Dec 17, 2010
    Posts:
    691
    @All
    I'm happy to report that Alloy-UBER integration is finally officially supported with Alloy 3.2.6. It can now be accessed by simply using the new "Alloy Deferred Shading UBER.shader" as your deferred override shader. Going forward we will be coordinating with @tomaszek to ensure that we remain compatible with the current version of UBER.
     
    chelnok and KRGraphics like this.
  50. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    3,979
    This is a match made in HEAVEN!! I use Alloy primarily in my work and stuff like dynamic rain and animated emission will help a lot in my projects. And @tomaszek, my eyeballs melted looking at some of the images of UBER... Now there is something I do want to see with UBER since it will play nice with alloy: Thin Film Interference or Iridescence. :) I plan on creating things like silk and pearls and this is probably the only thing these shaders need...
     
unityunity