How to code the UV set picker for the texture map?[Solved]

Hello! I’m trying to write a simple 2-material blending shader based on texture mask (total noob in whole custom shader business BTW). So far I got the working prototype, the only problem that remains is how to tell the masking texture which UV set to use. It won’t be any good without support for second UV set.

Shader "Custom/2matTexBlend" {
    Properties {
        _Color ("Tint of the base texture", Color) = (1,1,1,1)
        _ExtraCol1 ("Tint of the extra texture1", Color) = (1,1,1,1)
        _Glossiness ("Smoothness, multiplied by alpha of normal map", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _Emission ("Emission, multiplied by alpha of texture maps", Range(0,1)) = 0
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _ExtraTex1 ("ExtraTex1 (RGB)", 2D) = "white" {}
        _BumpMap ("Normalmap", 2D) = "bump" {}
        _BumpMap2 ("Normalmap2", 2D) = "bump" {}
        _Mask ("Masking texture (RGB)", 2D) = "grey" {}
        [Enum(UV0,0,UV1,1)]  _UVSec ("UV Set for secondary material", Float) = 0
        [Enum(UV0,0,UV1,1)]  _UVMask ("UV Set for the mask", Float) = 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;
        sampler2D _ExtraTex1;
        sampler2D _BumpMap;
        sampler2D _BumpMap2;
        sampler2D _Mask;
       

        struct Input {
            float2 uv_MainTex;
            float2 uv_ExtraTex1;
            float2 uv_BumpMap;
            float2 uv_BumpMap2;
            float2 uv_Mask;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;
        fixed4 _ExtraCol1;
        half _Emission;
       

        void surf (Input IN, inout SurfaceOutputStandard o) {
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            half4 mask = tex2D (_Mask, IN.uv_Mask);
            fixed4 extra1 = tex2D (_ExtraTex1, IN.uv_ExtraTex1) * _ExtraCol1;
            fixed4 bump = tex2D (_BumpMap, IN.uv_BumpMap);
            fixed4 bump2 = tex2D (_BumpMap2, IN.uv_BumpMap2);
            half MaskBlend = mask.r+mask.g+mask.b/3;
            c.rgb = lerp(c.rgb,extra1.rgb,MaskBlend);
            o.Albedo = c.rgb;
            // Metallic and smoothness come from slider variables
            o.Metallic = _Metallic;
            o.Smoothness = lerp(_Glossiness*bump.a,_Glossiness*bump2.a,MaskBlend);
            o.Alpha = c.a;
            o.Normal = lerp(UnpackNormal(bump),UnpackNormal(bump2),MaskBlend);
            o.Emission = _Emission*c.rgb;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

(I shamelessly ripped the Enum construction from the Standard shader UI, but do not know where to plug the UV indices provided by it :frowning: The rest of the Standard shader code is just too cryptic for my limited understanding.)

Well, I mustered a band-aid solution:

float2 MaskUV1 = IN.uv_Mask*(1-_UVMask);//_UVMask is the enum which returns either 0 or 1
            float2 MaskUV2 = IN.uv2_Mask2*_UVMask;
            float2 _MaskUV = MaskUV1 + MaskUV2;

(multiply one of two UV set variables to zero depending on enum value)
,but I wonder is there less cumbersome way to do it?

why not a simple if?

float2 _MaskUV = IN.uv_Mask;
if(_UVMask==1)_MaskUV = IN.uv_Mask2;

float2 _MaskUV = 1?IN.uv_Mask2:IN.uv_Mask;

So we can use " if " statements in the shaders? I was under the delusion we cannot. Probably confused the Surface with Fragment. Thanks
tsangwailam ,
alienheretic , for clearing this matter!