Standard Shader Occlusion, what am I missing?

Hi,

I am trying to emulate the Standard Shader’s occlusion behaviour in Shader Forge.

From what I can see, occlusion is applied as such (from UnityStandardInput.cginc):

half Occlusion(float2 uv)
{
#if (SHADER_TARGET < 30)
    // SM20: instruction count limitation
    // SM20: simpler occlusion
    return tex2D(_OcclusionMap, uv).g;
#else
    half occ = tex2D(_OcclusionMap, uv).g;
    return LerpOneTo (occ, _OcclusionStrength);
#endif
}

So I tried the same thing in Shader Forge:

But the end result looks slightly different (from Left to Right: my RMA shader / Standard Shader / my RMA shader with AO Strength set to 1.5)

So you can see Standard Shader occlusion seems to have a multiply effect going on there, but I can’t find it in code. (Left: my RMA Shader using only occlusion, Right: Standard Shader using only occlusion)

(I have also checked my textures are identical. Using Photoshop to view specific layers as well as applying them individually.)

So where does that light gray correction comes from? I have disabled scene Lighting and other details.

1 Like

(Sorry about the broken post a few minutes ago, Unity forum 5 attachment limit was not fun…)

Actually, even without Occlusion, I still see these light grey color from Standard Shader. They don’t appear on the Shader Forge output, hmmm, what exactly ARE they?

Shader Forge and the Standard shader are different shading models. They will not look the same with the same inputs, and there is no solution for that because they are different.

If you use deferred rendering they’ll match a lot closer as it forces most of the lighting to be handled by Unity, but their implementations of ambient lighting are still slightly different.

The way Unity implemented the “no lighting” mode is by acting like there is one single directional light coming from the camera. Different lighting models will handle that slightly differently.

1 Like

Huh, Thx, your “no lighting mode” explanation could explain this.

I am using Deferred Rendering though (Pretty sure there isn’t anything preventing this model from using Deferred).

I guess I shouldn’t be too concerned about copying Standard Shader AO. I was trying make sure I wire the right Shader for RMA texture :slight_smile: