Friday, April 29, 2016

Substance Painter Shader - Unreal Engine 4

So back in a day I needed a shader for UE4, I gooled it and found nothing. So I wrote it by myself :)
I came up to some nasty surprises left for me by both Epic and Allegorithmic, but I'll write about that another time.

Download Shader

Link to Substance Share


Here is some comparison pictures:
Substance Painter


UnrealEngine 4

Some Synthetic content:

Substance Painter

UnrealEngine 4

There is also one option called Brute Force that can help to get extra quality, but it hits performance greatly:
regular

Brute Force

The equations used to calculate lighting are exactly the same, but still you may notice some difference, that was caused by:
- different methods are used to solve lighting integration(SP uses Monte-Carlo importance sampling, while UE4 uses split sum approximation)
- for some reason HDRI cubemap looks less contrast in UE4(that to be investigated)

23 comments:

  1. well done! I've been waiting for this one!
    could you write one for Unity 5 shader?

    ReplyDelete
    Replies
    1. Yeah , on the next week I think. I hope there will be lesser problems with Unity

      Delete
    2. This comment has been removed by the author.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. no, Substance uses GGX as NDF function, it's the same as UE. This particular shader uses exactly the same equations as UE monte-carlo intergration, you may see it if you look into it.
      Difference is in the source and final output, not in calculations. UE does something with cubemaps and does something with color before tonemapping.

      Delete
  3. I am not referring to specular ndf, Im talking about pmrem.

    ReplyDelete
  4. there is no PMREM in substance. PMREM means you are pre-compute your cubemaps, what substance is not doing. It uses importance sampling to integrate spec in realtime

    ReplyDelete
  5. okay cool, looking forward to your investigation

    ReplyDelete
  6. Hiho, have you managed to whip up something for the Unity version of the shader? Would be extremely appreciated, thanks a lot for your work!

    ReplyDelete
    Replies
    1. Hi. actually yes, but... :D
      Unity has some critical flaws in their shading, which are actually difficult to reproduce using Importance Sampling. I have an idea how to do that, but that will took some time.
      -----
      Fortunately Unity will(during this year I believe) update their whole shading and fix that flaws, so I just tune-up roughness and all will work without rocket science.

      Delete
    2. "Critical flaws", that doesn't bode too well :P
      Well, I'll just try keeping my hopes up, and keep checking your blog, thanks for all the effort! I'm guessing you could make a lot of people very happy ;)

      Delete
  7. Awesome, any chance of Designer version of this shader? :)
    Kind regards,
    Oz

    ReplyDelete
    Replies
    1. yes, there is no blockers for that as far as i remember SD shaders.

      Delete
    2. Hi Damart,

      Are you saying the same shader should work in designer? Could you please help me understand how? I noticed that Designer uses different format for it's shader. I'm probably missing something very obvious :) Any help is much appreciated!

      Delete
    3. no:) it won't
      but the same approach should work, I need to port shader for SD.

      Delete
  8. Hi,
    Thank you a lot for this shader, can't wait to try it on my new project :)
    Just a small (noob-ish) question: Where do I need to place it so I can access it?

    ReplyDelete
    Replies
    1. drag and drop into shaders tab in shelf and choose shader in viewer settings

      Delete
    2. Thanks :)
      I will try it in a few minutes.

      Delete
  9. Does this shader work with opacity channel?

    ReplyDelete
  10. Hey Damart - Thank you for doing this - can you offer some input or advice how to use or set this up in Painter? I have it installed, but is super glossy looking - Any pointers on using it or what to watch out for?

    ReplyDelete
    Replies
    1. Hi Trevor! It should work just as it is. Can you send me your .spp, I can investigate this problem.

      Delete
    2. Hi. Shader dont work in SP 2018.3 :(.

      Delete