How do I get lightmap uvs in a surface shader?

I’m working on a blend shader which will be used to mix snow and regular ground. I bumped into a few issues though.

I’m currently mixing snow and regular texture with the following code. It adds snow on surfaces where the worldnormal is pointing up and it looks pretty cool.
However, I want to be able to control snow distribution using an additional blend texture (forcing/removing snow)
(This could also be used for grass, and such…)

I’m aware of that I can’t use a third uv channel, but I would like to access the raw lightmap uv’s and use these also for the mask.
How do I get the lightmap uv’s in a surface shader?

Do I have to revert to creating vertex/pixel shaders from scratch?

struct Input 
		{
			float2 uv_MainTex;
			float2 uv_BumpMap;
			
			float3 viewDir;
                        INTERNAL_DATA
		};
		
		void surf (Input IN, inout SurfaceOutput o) 
		{
			half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w;
			float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir);
			IN.uv_MainTex += offset;
			IN.uv_BumpMap += offset;
			
			fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
			fixed3 snow = tex2D(_Tex2, IN.uv_MainTex).rgb;
			
			o.Albedo = c.rgb;
			o.Alpha = c.a;
			o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
			
			float snowFactor = saturate(dot(WorldNormalVector(IN, o.Normal)-_Adjust, _Direction.xyz));
                        snowFactor = pow (snowFactor, _FPower);
            
     	   	        o.Albedo.rgb = lerp(o.Albedo.rgb, snow.rgb, snowFactor);
     	   	
     
		}
1 Like

You can just write uv2_:

float2 uv2_SnowMask;

Well that seems to be working! :slight_smile: Thanks a bunch! :slight_smile: