how to force base texture to use 2nd uv channel.

hi guys, i am using legacy lightmap shader, i believe uv channel 1 is used for texture and 2nd for lightmaps, is it possible to force base texture to use uv channel 2 as well? so both lightmap and uv channel will use uv channel 2.

anyone?

Yes, you can do that. But you will need to change the shader.
You can dowload built-in shaders here.

p.s.
Sorry, but what is the point of using second set of UV coordinates for both textures?

thanks a lot IJM, it solved my problem.
let me explain why i need second uv for base texture. suppose i have a model of a room in 3ds max and it has a certain wallpaper texture that uses uv channel 1 and i build a lightmap (in my case vrayrawtotallightmap) which uses uv channel 2. but suppose i want to use vraycompletemap rendered out of 3ds max for better looking result. this vraycompletemap has to be used in base texture but it requires mapping of uv channel 2 since uv channel 1 is just a tiled wallpaper texture.

Oh I see. I wrote a small shader for you:

Shader "UV2/Diffuse"
{
	Properties 
	{
		_MainTex ("Base (RGB)", 2D) = "white" {}
	}
	SubShader 
	{
		Tags { "RenderType"="Opaque" }
		LOD 200
		
		CGPROGRAM
		#pragma surface surf Lambert

		sampler2D _MainTex;

		struct Input 
		{
			float2 uv2_MainTex;
		};

		void surf (Input IN, inout SurfaceOutput o) 
		{
			half4 c = tex2D (_MainTex, IN.uv2_MainTex);
			o.Albedo = c.rgb;
			o.Alpha = c.a;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

thanks alot IJM :slight_smile:

Just a thought, but unless your example is actually nothing to do with what you are trying to do, it may not be the best approach to dealing with quality issues.

The point of lightmapping in a second channel is that the lightmap can be of a lower resolution than your base textures. By exporting complete maps, you’ll obviously need to use much higher resolutions and will end up with far greater use of vram since there is no re-use of base textures anymore. As to whether this might be a problem depends upon your project and target, e.g. will work great if you are just lightmapping a single small environment or are targeting 1GB gpu’s, but not if you are trying to make a large level.

Its been a while since I used Max, but shouldn’t you be able to export your models with the lightmap/unwrapped uv’s going straight into uv1? You can of course achieve the same thing in a shader, although I wonder if that means the mesh then needs two sets of u’vs in Unity, thus increasing memory usage further, but with a whole uv channel of data that you are ignoring?

Its just a ‘unusual’ direction to take, though certainly viable for specific cases and situations, I guess I’m wonder if this is one of those situations or not?

hi Noisecrime,yes it is possible in max to export everything in uv1 but i want to have the flexibility to use just lightmap and lightmap with completemap, that answers you 1st question, i want to compare the results of just lightmap and lightmap with completemap, and possibly use these two solution for different purposes, like i can use completemap solution for standalone and just lightmap for webplayer.
another advantage of completemap is that lightmap doesnt bake light hotspots, like the one you get with spot lights etc, and my scene is not big, it is an archviz scene so it is rather small so far, ill try to upload a preview sample later this evening, a few lightmaps are still rendering.

Cool, just checking, though I don’t quite follow the lightmap not baking hotspots/spotlights issue?

check the difference between lightmap(vrayrawtotallightmap) and completemap(vraycompletemap) of the same area. the completemap has a nice light hotspot pattern.

728413--26470--$lightmap.jpg
728413--26471--$completemap.jpg

I’m guessing that the “vrayrawtotallightmap” is just ambient occlusion or something like it. You should be able to get a real light map that takes local lighting into account, without baking in the base texture.