Unity Standard Material UV Occlusion/AO limitation (632254)

Hello there,

The Unity standard shader is causing me some problems with its lack of ability to set Occlusion to use a secondary UV Map. In this case I would ideally set:

Albedo etc.. to UV0

Occlusion to UV1/Secondary Maps

Currently it is only possible to set Detail Albedo x2 & Normal Map to a Secondary Map. This restriction is very limiting for anybody needing tiled Albedo bitmaps (pretty much a standard requirement) and non overlapping UV’s for use in AO baking/Occlusion. It would appear that Albedo & Occlusion must use the same UV co-ordinates, which is a primitive and restrictive way of working.

As a work around, I have been placing the AO Map in the Detail Albedo x2 inside Secondary Maps (set to UV1). The AO bitmap is set to an Advanced Texture, with Alpha set as Transparency. This provides a nice blended AO on UV1. However, since it is not set to be Occlusion, it of course is effected by the GI more than it should be. Essentially, I have been having to ‘fake’ the AO/Occlusion, rather than use Unity’s Occlusion slot as intended just to set it to UV1.

I was wondering if anybody else is encountering the same limitation? It would be great to hear if anybody has found a fix for this, without re writing the Unity Standard Shader. We have a long term project whereas we need to stick to the Standard Shader, as this project will span over many versions of Unity.

Many thanks,

CM

You can just create a custom surface shader (which extents the standard shader) and fill in your occlusion data as desired. It goes a little something like this:

Shader "Custom/OcclussionOnUv2" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _OcclusionTex("Occlusion", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _OcclusionIntentsity("Occlusion intensity", Range(0,1)) = 1.0
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200
       
        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        sampler2D _MainTex, _OcclusionTex;

        struct Input {
            float2 uv_MainTex;
            float2 uv2_OcclusionTex;
        };

        half _Glossiness, _Metallic, _OcclusionIntentsity;
        fixed4 _Color;

        void surf (Input IN, inout SurfaceOutputStandard o) {
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            // Metallic and smoothness come from slider variables
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = c.a;
            // Occlusion comes from the second uv channel
            o.Occlusion = lerp(1.0, tex2D(_OcclusionTex, IN.uv2_OcclusionTex), _OcclusionIntentsity);
        }
        ENDCG
    }
    FallBack "Diffuse"
}

Many thanks for that! I will give it a shot. It looks like the nicest way of handling it. Thanks again.

Hi, I know it’s an old thread, but did you found out how to change/modify/enhance the standard shader, so we can use another UV channel for the occlusion map? Sadly, I am not a programmer and I am willing to pay 100$ for it. But it seems every Programmer runs away when it comes to replicating or modifying the standard shader. It has become frustrating. My whole project depends on this one “little” change!

  • In Editor shader works fine. But in build Android, a shader is not working
    Is there any way to work on Android devices?

I can’t see a reason why it wouldn’t be supported on Android. Can you test if the shader works in a Windows build, to make sure that the shader is included?

@Thomas-Mountainborn It’s my issue. It’s working on android and iOS well. Now I having an issue regarding lighting dot.
Please check this attached screenshot. Need to be light in the scene. Should remove this white dot due to lighting

5269551--527514--Screenshot 2019-12-11 at 11.16.01 AM.png