# How to free up TEXCOORD slots for Unity's Universal Render Pipeline?

I am writing custom a custom shader for Unity's Universal Render Pipeline (Version 7.3.1). The meshes are built using three separate UVMaps for different portions of the mesh. The reason I actually need all three to be separate is because two of them are scaled & offset independently by a C# script, kind of like texture atlas. I need the front and back of a sphere to be independently textured using this.

I followed this tutorial from CyanGameDev to get an understanding of the new syntax for URP as I had previously done this with the Built-In RP. The older version still used the Vertex & Fragment functions to draw it, but it was unlit so I was free to use as many TEXCOORDs as I needed. Now as I followed this tutorial, I found that I needed all 8 available TEXCOORDs immediately just to get it functioning:

struct Varyings // AKA v2f, or OUTPUT from Vertex function to Fragment function
{

float4 positionCS                    : SV_POSITION; // Position in ClipSpace AKA screen space
float4 color                         : COLOR;

float2 uv                               : TEXCOORD0;
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 1); // the 3rd argument is the TEXCOORD index

#ifdef REQUIRES_WORLD_SPACE_POS_INTERPOLATOR
float3 positionWS               : TEXCOORD2;
#endif
float3 normalWS                 : TEXCOORD3; // Normal in WorldSpace as defined in Vert function
#ifdef _NORMALMAP
float4 tangentWS                : TEXCOORD4; // Tangent in WorldSpace as defined in Vert Function
#endif
float3 viewDirWS                : TEXCOORD5;

// Convert to half3 for just vertex lighting, free up a TEXCOORD?
half4 fogFactorAndVertexLight   : TEXCOORD6; // x: fogFactor, yzw: vertex light

#endif
};


Is there anyway I can remove some of these and still get PBR-ish result? For instance, I don't necessarily need the fog on this object. As well, I do not really want to perform this in Shader Graph if I can avoid it.

One thought I am having is to declare the uv as a float4 and just swizzle the texcoord like uv.xy for UV1 and uv.zw for UV2 but my understanding is the texturing and offset is stored within the Z & W vectors which is why you used to define a _MainTex_ST float4.

EDIT:

The specific effect is this:

The background is one texture (not a solid color, or i'd do this differently) And the Foreground is another texture (Alpha channel symbols)

Through the script, you control which background section or foreground symbol you want by changing the tiling of the texture. The idea is that you can have many different combinations of the two textures. The back of the sphere will always have just the background color. The script is such that the amount of tiles on a texture does not have to be square, and the foreground and background textures do not need the same amount of tiles (its calculated at start). At any given time, only one of the tiles is shown on the sphere, mapped to both sides.

The final look is explained in a previous question of mine The final look is explained in a previous question of mine

• You could split the mesh into submeshes, then each can use its own maps without needing to male space for the others. Or you can set your scale/offset values as uniforms and apply multiple shifts to one source UV map in the shader instead of baking each variant into its own channels. But there might be more specific options available if you can show us the particular effect you're creating. – DMGregory Sep 1 at 4:08
• Edited to show the process with images – Rug Sep 1 at 5:07
• And sorry, can you clarify how this is mapped on the sphere? Do we see just colour and one symbol on the sphere at a time? If so, this looks like a job for uniforms, not extra texture coordinate channels. – DMGregory Sep 1 at 11:46
• I use a UV projection of the front hemisphere as one map and scale the other components down/off the map, and a second projection of the back hemisphere with the same layout. Im not sure I understand what you mean by Uniforms in this context, can you elaborate? Finally, yes it is one color, though it is not solid color, and one symbol mapped at any time. – Rug Sep 1 at 13:15
• I'm asking more about the final rendered look. Can you include an image of what the sphere should look like at the end, just to be sure we're understanding you correctly? – DMGregory Sep 1 at 13:16