Why are texcoords (uvs) stored in float4?

Essentially what the title says. When writing CG programs, the Unity docs say to create the texcoords in a structure as a `float4`. What is stored in the `zw` components?

struct v2f {
    float4 texcoord : TEXCOORD0;

when most of the time I just use the xy components.

EDIT: I just looked at the CG documentation page, and it looks like it stores texcoords as a float2 in every example that I looked at.

Graphics cards use float4's to store and manipulate everything. They literally don't have simple variables in their chips or have simple math circuits. You ask one to add 4+7, it gets confused, then prints, "oh, you mean (4,0,0,0) plus (7,0,0,0)!!."

For UV's the 3rd is the 3rd dimension (if you have 64 textures, all 64x64, you can think of the 3rd as picking/blending which textures to use.) The 4th is the scale factor (backwards: 2 is one half size.) They are always (0,1.)

But, the lookup command is generally `tex2D(texture, i.texcoords.xy);` so the last two aren't even used.

I personally use float2s for UVs, but a float2 is really a float4 with the last two slots taped over, and saves 0 time over using a float4. Most likely someone just typed float4 way back and there was never a reason to change it.

After conducting a little more experimentation, Unity will let you create the texcoords as a float2.

//this is also valid:
struct v2f {
    float2 texcoord : TEXCOORD0;

Owenpat does a nice job explaining why the Unity docs recommends creating them as a `float4` instead though.