What is the function MultiplyUV() in shader?

hello everyone,

Today when I read the source code of a shader in Glow effect by Unity (actually the GlowCompose.shader), I find there is a MultiplyUV() function (see following code segment), and this function’s existence confused me.

v2f vert (appdata_img v)
    v2f o;
    o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    o.uv = MultiplyUV (UNITY_MATRIX_TEXTURE0, v.texcoord.xy);
    return o;

I don’t know why a uv should multiple a matrix since in most of the case, I use uv directly. So, the question is, why the code above transform the uv, and what’s the matrix of UNITY_MATRIX_TEXTURE0 is (I know it’s glstate_matrix_texture[0] or say glstate_matrix_texture0, but don’t know what this matrix is)?

The UV matrix works the same as the regular model-view matrix. It scales, translates and rotates (well, it never does rotates, but it can) the UV coords. It’s a built-in part of the graphics card, but since most wrapped models never want to change UVs, it’s often unused.

I suspect that Unity uses it to apply the offset and scale set in the Material. You might think, “why not just multiply by scale and add offset?” But the matrix is already there, and might run faster.