OpenGL Shading Language TRANSFORM_TEX

shader, unity-game-engine

Solution

It's just a `Unity3D` specific macro, there's no `Cg` equivalent. You can find this macro definition in the file:

Unity\Editor\Data\CGIncludes\UnityCG.inc

It's defined this way:

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

It scales and offsets texture coordinates. `XY` values controls the texture tiling and `ZW` the offset.

Problem

In unity3d there is a piece of code for a 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 lines below : ``` o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); ``` what is the main task of TRANSFORM_TEX function and what is it's equiavalent in CgFx !

Original source