Search Unity

Keep specular effect after baked

Discussion in 'Shaders' started by Blastom, Nov 17, 2017.

  1. Blastom

    Blastom

    Joined:
    Aug 13, 2013
    Posts:
    24
    I just found most of the surface and vert + frag shaders will lose the dynamic specular effect after being baked.
    While I found the "Standard Specular" shader can keep the functionality even after being baked.

    How did they do this? By keeping some pass unaffected by the baking or some other magical measurements?
    I'm currently sweeping the cginc codes as well, but quite overloaded as I'm not a senior shader coder.
    Can anyone help me on the theory or providing me a reference to spot in the cginc files.
    Many thanks.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    In what scenario? What kind of surface shaders? What light & lighting settings? What version of Unity?

    If the lights are set to baked, and you're using 5.6 or 2017, I don't believe any shader will do specular from the lights.
    If you're using 5.5 or older there was a directional specular option that was removed that both the standard and surface shaders would have supported properly, but may have required some additional work to support with vertex fragment shaders.

    If you're using 2017 and have your lights set to Mixed, I see no problems with specular highlights showing on the Standard shader or Surface shaders (using the Standard lighting model).
     
  3. Blastom

    Blastom

    Joined:
    Aug 13, 2013
    Posts:
    24
    The unity version was 5.4.1f1.
    I've tried hand made vertex frag and surface as long as the legacy specular bump surface shaders. None of them can provide the same effect as standard specular.
    I've tried both directional and non-directional GI as well. None of them worked.

    I've seen some mobile game has specular effect on ground, which I think should have light baked or it can be costy.

    Well, thanks for your reply.
     
  4. Blastom

    Blastom

    Joined:
    Aug 13, 2013
    Posts:
    24
    I accurately want some principles of lightmapping in Unity. So I can figure out some kind of solution my self.
    Like how the shaders want after lightmapped - are they completely out of function or just a part of them.
    Also, the standard one has a meta pass, I don't know if it's the key of them to keep specular effect.

    I'll try some more experiments, I think.
     
  5. Blastom

    Blastom

    Joined:
    Aug 13, 2013
    Posts:
    24
    I saw the problem - the specular won't accurately work, but the reflection works.
     
  6. Blastom

    Blastom

    Joined:
    Aug 13, 2013
    Posts:
    24
    Solved. The standard one has only reflection after baked. But as it's so "bright", I though it was specular.
    Baked object can have reflection, which is dynamic, but no specular.