Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Builtin Standard shader occlusion for my own shader

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

  1. VileGoo


    Apr 29, 2017
    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


    Jul 5, 2013
    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.