Search Unity

Antonov Suit - Physically Based Shader - First Release

Discussion in 'Works In Progress - Archive' started by Charkes, Apr 24, 2013.

  1. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    I moved this to the first page of this thread with latest update.

    Hello,

    Again it's been a while since I posted update but this time I have packages.

    This what I've been working on on my free time, it's not finished but I'm starting to ride in circle so I decided to release a first version.

    This is the Antonov Suit



    It consist of three main component the Dielectric, the Metallic and the Metallic and Dielectric shader.

    Dielectric shader is the non condictor material ( stone, brick, plastic etc ).

    Metallic shader is the conductor material ( any kind of metal ).

    Metallic and Dielectric shader have both properties.

    Depending on what you want to do you'll have to choose one the three.

    If you want to shade a concrete or plastic floor you'll have to choose the Dielectric shader, for a metal object or floor you'll have to choose the Metallic one and if your object has both metal and plastic you'll have to use the Metallic and Dielectric shader.

    Each shader use the following texture :

    BaseColor : basically the colors of the material (Dielectric or Metallic or both). It use the _COLOR suffix.

    RGB :

    R = Metallic (0-1 range black is Dielectric and white is Metallic).
    G = Roughness (0-1 range, black is pure mirror and white is rough).
    B = Ambient Occlusion.
    A = Alpha.

    It use the _RGB or _RGBA suffix.

    Normal Map : Normal texture. It use the _NORM suffix.

    The three shaders use a LUT containing F and G term of the GGX speclar equation.

    And of course Diffuse and Spacular cubemap.

    There's also a skin shader with extra texture :

    A second RGB working as follow :

    R = Cavity.
    G = Curvature or how far the light can penetrate the skin.
    B = Mask for ears and nose ( unused at the moment ).

    It use the _RGB suffix.

    Two micro texture for pores details and Skin LUT.

    Packages :

    Antonov Suit : https://dl.dropboxusercontent.com/u/1812933/AntonovSuit/Antonov Suit_v0.035_20.07.2014.unitypackage

    Antonov Suit Samples : https://dl.dropboxusercontent.com/u/1812933/AntonovSuit/Antonov Suit Samples.unitypackage

    This is some samples textures and materials in a scene to give you an idea on how the shader is working.

    Infinite Head Scan : https://dl.dropboxusercontent.com/u/1812933/AntonovSuit/InfiniteScan.unitypackage

    Infinite head scan from infinite realities allowing you to see how skin shader is working.

    Current Features :
    • Forward only
    • Lightmap (Single and Directionnal)
    • PBR rendering
    • Metallic/Metalness Workflow
    • Pre integrated skin shader ( Eric Penner method ).
    • Probe capture tool
    • RGBM Encoding for cubemap ( Free and Pro )
    • GPU base cubemap convolution using importance sampling.

    Next Features :

    • Lightmap Probe support
    • Box and sphere projection for cubemap.
    • Billboard/Image reflection plane and its tool to capture reflection images.
    • Screen space subsurface scattering
    • Screen space reflection
    • Terrain and foliage shader
    • Wetness/Rain effect
    • Glass shader

    ChangeLog
    :

    v0.035

    Changed exponent calculation for convolution.
    Fixed sharp transition in the cubemap mip map.

    v0.03

    Added GPU based convolution for cubemap using importance sampling.
    Added GGX and Blinn-Phong specular model in the probe tool.

    v0.02

    Added single and directionnal lightmap
    added importance sample amount control to probe tool

    changed RGBM encoding for unity free

    fixed issue with uint
    fixed issue with build : "Assets/Antonov Suit/Scripts/AntonovSuitProbe.cs(151,17): error CS0103: The name `EditorApplication' does not exist in the current context"
    fixed _Illum error while making lightmap with beast

    v0.01

    Initial Version



    Thanks, if you have any questions feel free to send me an MP or mail at antonovsuit@gmail.com.
     
    Last edited: Jul 25, 2014
  2. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
  3. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    why forward only??
     
  4. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Currently it would mean lot of hack to get proper fresnel in deferred pre-passlighing. This is something I'm trying to make it work.
     
  5. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    The shaders are working if you switch to deferred but they are rendered as forward.
     
  6. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ah of course, you might want to check on Lux to implement the hack in deferred :)
     
  7. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    This looks great, especially with all those future features.
    MY i ask why derelicts and metals have seperate shaders?
    Does it clamp the spec value as a derelict, or does is work like a metalness map?

    Also im assuming this is a metalness workflow, not a spec.

    Would you mind if I post some renders with it later as well?
     
  8. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    rea : yeah but this is what I meant I don't want to do hack, I know how to and I did it before but this time I want to find a proper way :) !

    Tiny Man : they are separated because sometimes your objects won't need both properties so you can use one or the other. For a full metal material, the diffuse component isn't needed so it makes the shader a bit cheaper.

    It is a metalness workflow exactly.

    Dielectric part got a predifined specular value and no color as it is not conductor material.

    "Would you mind if I post some renders with it later as well?"

    I really need feedbacks on this so : Go ahead :) !

    Thanks
     
    Last edited: Jul 7, 2014
  9. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    Good to know
     
  10. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    I encourage you to look at the samples I made. I'm doing a proper documentation aswell but it takes time.

    Feel free to ask.
     
  11. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    Generally I use spec pbr workflow, so I got a question.
    Would I use like a grey for composite materials, like steel for example (a mix iron and steel)
     
  12. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Fair point, can't wait to see your implementation in deferred :)

    Edit : Wow....your probe convolution are pretty fast...i'm impressed man :), what do you mean by realtime only in the importance sampling?
     
    Last edited: Jul 7, 2014
  13. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Use the same value you were using for metals, you just need to paint in white in the Red channel of a "MyTexture_RGB" what is metallic and paint your metal colors in the base texture "MyTexture_COLOR".

    With regular PBR workflow for you metal you would have tinted almost black your diffuse and put you metal color in your specular, here the only difference is that the black tint for diffuse is handled in the shader.

    Hope I answered your question :).
     
  14. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Incredible shaders, but i've got some errors like 'Assets/Antonov Suit/Scripts/AntonovSuitProbe.cs(151,17): error CS0103: The name `EditorApplication' does not exist in the current context' when i try to make a build. :(

    About the workflow, have you tried your shaders with Substance Painter? :)
     
    Last edited: Jul 8, 2014
  15. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Thanks :), I didn't but this is something I will look into.

    Error should be fixed now :

    https://dl.dropboxusercontent.com/u/1812933/AntonovSuit/Antonov Suit_v0.02_08.07.2014.unitypackage

    [EDIT]

    I did a quick change on how I was doing my RGBM encoding for unity free. Now it's done almost the same way as pro so as an image effect. I also added importance sample amount control inside the probe tool.
     
    Last edited: Jul 8, 2014
  16. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    The latest version solves the pb. Thanks. :cool:
     
  17. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Great !
     
  18. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    Could you make a spec version for the shader, since I want to try out my model but its not metalness.
    If it's too much don't worry about it.
     
  19. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I'm a noob in physical shaders, just asking what is the difference or benefits compared to Lux framework ?
     
  20. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Hi,

    New version : https://dl.dropboxusercontent.com/u/1812933/AntonovSuit/Antonov Suit_v0.03_19.07.2014.unitypackage

    Now Importance Sampling is no longer a real time process but baked in the cubemap which makes the shader a lot faster.

    The convolution is done with the GPU so it's quit fast even for a 256 or 512 cubemap.

    This presentation inspired me the process : http://framebunker.com/blog/static-sky-unite-presentation

    I use 256 samples but you can use less, more isn't needed I think. Less samples is faster.

    You can choose two specular model, GGX and Blinn.

    I'll add more specular model later and why not some other diffuse model ( Hemisphere ? ).

    I still need to fix some edges and filtering problem but with a smooth edge value of 2 it's qui acceptable.

    I've also added toksvigAA again ( after removed it :) ) but I'm not sure if it's done correclty.

    Next step is Box and Sphere Projection and after that Billlboard/Image Reflection.

    Tiny Man : Yes I'll add it as soon as possible.

    zenGarden : Can't answer to that question, my shaders are just my understanding of PBR so choose what you like or use both :). Anyway I would love to see some asssets rendered with my shaders. .
     
    Last edited: Jul 19, 2014
  21. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    You should definitely update your first post with the latest link, would help it get seen, but yes i just found this and just got round to fixing my problem with aging modelling skills, so i'll try this out on stuff i make along with Lux and furnish both threads with any worthwhile results (If they happen)
     
  22. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Last edited: Jul 20, 2014
    Reanimate_L likes this.
  23. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Nice, i like your decision for moving the importance sampling to precomputed cubemap, better performance is better :D
     
    Charkes likes this.
  24. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I'm getting a bunch of errors from the latest update when the previous worked fine (unity 4.5), getting unexpected token '&&' in two ifdefs in a cginc and variables being reassigned in RGBE.cs i think

    Hope you can fix as the results I got were initally promising
     
  25. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
  26. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    How to upgrade? do i need to remove something?? Somehow i can't convolve the cubemaps.
     
  27. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    I would suggest to remove your Antonov Suit folder and unpack again the package. I've just tested in a clean project with the sample package and it worked but I could have missed something. Let me kow.
     
  28. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Nope, it doesn't work. Still unable to convolve the cubemap. The convolution process are happened but the cubemap result are doesn't convoluted.
    Edit : So after a couple try finally it works, but the cubemap got flipped upside down. Latest patch.
    upload_2014-7-24_3-35-51.png

    Another Edit : Got the cubemaps normal, i have to convolve it twice :/
    upload_2014-7-24_3-45-40.png

    NB : Btw...i can see really amazing performance with precomputed rather realtime convolution
    i get 10000fps with precomputed while only 200fps with realtime convolution. Amazing work :)
     
    Last edited: Jul 23, 2014
  29. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Something I just thought but I think you weren't convovled the correct cubemap.

    When the baking is done the probe does not pick up the cubemap you just baked so you need to put them yourself in the probe then convolve.

    I should fix this.

    Nice result !

    EDIT : I'll try to replicate this flip upside down.
     
  30. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
  31. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I'll have another go but i'm not having very much luck so far - trying to approximate a shader setup that might be analogous to my Lux setup produces very different results - i'm not sure if this is related to Lux altering the Internal_PrePassLighting but i'll look through the documentation properly and make sure everything is in order and see from there - I guess additional fiddlyness comes from the metalness workflow which i am not familiar enough with yet and neglect to factor in when i'm generating maps (I'm using Quixel Suite for convenience and it still requires a good few bug fixes, adding maps after starting a project creates a mess, restarting a project all over again is a headache)

    I do hope to get some good results from this however and would ideally like to offer this as a possible alternative to Lux when on the subject of open source, or freely available PBS solutions for Unity, especially when both this and Lux both offer something a little different from the norm
     
  32. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Well i suppose one problematic start was that the update brought in an enormous number of keywords that took my project over the 64 limit, i could probably prune the project of things i'm not using right now to see if this helps but are there any ways of reducing things at this end too?
     
  33. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    How many shader solution are you using in one project ?

    I'm using 5 keywords with #pragma multi_compile is that really much ( I don't count unity internal like lightmap stuff ) ?

    I could of course not use #pragma multi_compile and instead use some #define for my box and sphere projection stuff.
     
  34. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    My shaders act more like UE4 as it is based on the same papers ( EPIC and Disney ).

    Did you tried the UE4 presets from quixel ?
     
  35. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Hey Charkes, have you tried to create cubemaps while in Dx11 mode? I think that what caused the flipped cubemap, since when i'm using Dx9 mode the cubemaps were fine
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    • UNITY_UV_STARTS_AT_TOP - always defined with value or 1 or 0; value of one is on platforms where texture V coordinate is zero at “top of the texture”. Direct3D-like platforms use value of 1; OpenGL-like platforms use value of 0.
    • http://docs.unity3d.com/Manual/SL-BuiltinMacros.html
     
  37. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Yeah I missed dx 11 and flipped screen uv :)( RGBM is done with post process ).

    I'll fix it !

    EDIT : Thanks lars for the link.
     
    Last edited: Jul 24, 2014
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you are welcome!
     
  39. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Last edited: Jul 26, 2014
  40. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Update : https://dl.dropboxusercontent.com/u/1812933/AntonovSuit/Antonov Suit_v0.042_30.07.2014.unitypackage

    Specular workflow is added, the shader name is Specular ( couldn't find a better name so if you got better idea I take ! )

    Little sample : https://dl.dropboxusercontent.com/u/1812933/AntonovSuit/MetalCeilling_04_SpecularWorkflow_Sample.zip

    added specular workflow
    added toksvig factor parameter in shader

    changed sphere projection code ( Nvidia approach )
    changed material path for specular and mettalic workflow.

    fixed occlusion on direct specular

    removed skin atten shadows from point and spot light in the Pre Integrated Skin, when light is far skin goes red.
     
  41. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Update : https://dl.dropboxusercontent.com/u/1812933/AntonovSuit/Antonov Suit_v0.043_21.08.2014.unitypackage

    Some little changes in this one.


    added exposure control for diffuse and specular cubemap ( request )
    added preview sphere for cubemap
    added edge scale bleeding for smoothedge ( DX9 )
    added three type of convolution for diffuse cubemap
    added view dependent roughness ( see GDC FOX Engine )
    added edge fix for dx9 in shader ( as a test )

    fixed black edge in the lookup texture generator
    fixed G_smith model in the lookup texture generator

    changed samples amount for a quality setting for convolution
    changed cubemap size for a fixed size choice
    changed exponent math for GGX cubemap to match more the importance sampling reference
    changed skybox convolution projection
    changed smooth edge to wokr only on DX9 as DX11 use its own edge fix
    changed fresnel for cubemap with lookup texture ( D_GGX and G_Smith used as default now )

    removed #pragma_multi_compil for convolution type and moved to different shader instead

    improved convolution speed ( a bit )
     
    Last edited: Aug 21, 2014
    Graph and Reanimate_L like this.
  42. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Last edited: Aug 22, 2014
    Luckymouse likes this.
  43. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
  44. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
  46. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    I don't have a mac book here to test :(.

    Will do my best to fix that !
     
  47. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
  48. MegsTan

    MegsTan

    Joined:
    Oct 19, 2013
    Posts:
    55
    Hi Charkes,

    This is really a great PBS system. I'll check this one out later :)
     
    Charkes likes this.
  49. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Thanks !
     
  50. MegsTan

    MegsTan

    Joined:
    Oct 19, 2013
    Posts:
    55
    Hi Charkes,

    I have a dump question though, not sure if I'm doing something wrong. For some reason I'm having trouble convolving the cubemaps. I have tried importing it in a new project and it seems that it's not working. I noticed that when convolving, the cubemapcamera's culling mask is set to nothing. Does that has something to do with it? Sorry for my bad english :(
     
    Last edited: Sep 1, 2014