OpenGL Shader Language TRANSFORM_TEX

Unit3d has a code snippet for the vertex shader:

v2f vert(appdata_full v) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); o.vertexColor = v.color * _TintColor; return o; } 

In the lines below:

 o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 

What is the main task of the TRANSFORM_TEX function and that it is equivalent in CgFx!

+7
source share
1 answer

This is just a Unity3D specific macro , there is no Cg equivalent. You can find this macro definition in the file:

Unity \ Editor \ Data \ CGIncludes \ UnityCG.inc

It is defined as follows:

 // Transforms 2D UV by scale/bias property #define TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw) 

It scales and shifts texture coordinates. XY values ​​control texturing and ZW offset .

+8
source

All Articles