Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Builtin Standard shader occlusion for my own shader

Discussion in 'Shaders' started by VileGoo, Jul 18, 2019.

  1. VileGoo

    VileGoo

    Joined:
    Apr 29, 2017
    Posts:
    210
    Hello, I'm working on my own shader to get a particular look for my project, everything so far has been rather straight forward but I've now hit a snag. I want to add the Occlusion mapping that the Standard shader provides for my own shader, but I have no idea how to do that. I tried digging into the Shaders source code for Unity 2017.4.28 (the version I'm using) but it's not at all what I expected. It's an extremely complex script that uses multiple includes across many scripts and I have no idea what I need to take from it to add AO to my shader. Can I get some help? Thanks.
     
    Last edited: Jul 18, 2019
  2. Namey5

    Namey5

    Joined:
    Jul 5, 2013
    Posts:
    144
    Ambient occlusion works as the name implies; we take away ambient light in places where it shouldn't be. It's difficult to give you any advice on the subject not knowing your ambient term (light that is constant regardless of physical sources), or even how your shader is composed (surface shader, vert & frag, etc.). Generally speaking though; it works by sampling the occlusion texture (generally a single value) and multiplying the ambient term by said texture sample.