I have a model I exported from Maya that has two UV sets. I’ve written this simple shader that expects to get the two UV sets:
Shader "Karl/BackgroundShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_ShadingTex ("Shading (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Lambert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
sampler2D _ShadingTex;
struct Input {
float2 uv_MainTex : TEXCOORD0;
float2 uv2_shading;
};
fixed4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
fixed4 c2 = tex2D (_ShadingTex, IN.uv2_shading);
o.Albedo = c.rgb * c2.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
The shader appears to work except that UV set2 seems to be being clobbered by unity. Instead of getting the expected UV’s, the uv’s are scrunched up into the upper left corner. I know the UV sets are coming in because if swap UV’s on the FBX import, the expected UV’s of the second set appear to be intact.
Anyone have any experience with this?