"\n"
"// common definitions between vertex shader and fragment shader:\n"
"\n"
-"varying mediump vec2 TexCoord;\n"
+"varying mediump vec4 TexCoordSurfaceLightmap;\n"
"#ifdef USEVERTEXTEXTUREBLEND\n"
"varying mediump vec2 TexCoord2;\n"
"#endif\n"
-"#ifdef USELIGHTMAP\n"
-"varying mediump vec2 TexCoordLightmap;\n"
-"#endif\n"
"\n"
"#ifdef MODE_LIGHTSOURCE\n"
"varying mediump vec3 CubeVector;\n"
"uniform highp mat4 ModelViewMatrix;\n"
"void main(void)\n"
"{\n"
-" TexCoord = vec2(TexMatrix * Attrib_TexCoord0);\n"
+" TexCoordSurfaceLightmap.xy = vec4((TexMatrix * Attrib_TexCoord0).xy, 0.0, 0.0);\n"
"#ifdef USEVERTEXTEXTUREBLEND\n"
" VertexColor = Attrib_Color;\n"
" TexCoord2 = vec2(BackgroundTexMatrix * Attrib_TexCoord0);\n"
"{\n"
"#ifdef USEOFFSETMAPPING\n"
" // apply offsetmapping\n"
-" vec2 TexCoordOffset = OffsetMapping(TexCoord);\n"
-"#define TexCoord TexCoordOffset\n"
+" vec2 TexCoord = OffsetMapping(TexCoordSurfaceLightmap.xy);\n"
+"#else\n"
+"# define TexCoord (TexCoordSurfaceLightmap.xy)\n"
"#endif\n"
"\n"
"#ifdef USEALPHAKILL\n"
" VertexColor = Attrib_Color;\n"
"#endif\n"
" // copy the surface texcoord\n"
-" TexCoord = vec2(TexMatrix * Attrib_TexCoord0);\n"
+"#ifdef USELIGHTMAP\n"
+" TexCoordSurfaceLightmap = vec4((TexMatrix * Attrib_TexCoord0).xy, Attrib_TexCoord4.xy);\n"
+"#else\n"
+" TexCoordSurfaceLightmap = vec4((TexMatrix * Attrib_TexCoord0).xy, 0.0, 0.0);\n"
+"#endif\n"
"#ifdef USEVERTEXTEXTUREBLEND\n"
" TexCoord2 = vec2(BackgroundTexMatrix * Attrib_TexCoord0);\n"
"#endif\n"
-"#ifdef USELIGHTMAP\n"
-" TexCoordLightmap = vec2(Attrib_TexCoord4);\n"
-"#endif\n"
"\n"
"#ifdef USEBOUNCEGRID\n"
" BounceGridTexCoord = vec3(BounceGridMatrix * Attrib_Position);\n"
"{\n"
"#ifdef USEOFFSETMAPPING\n"
" // apply offsetmapping\n"
-" vec2 TexCoordOffset = OffsetMapping(TexCoord);\n"
-"#define TexCoord TexCoordOffset\n"
+" vec2 TexCoord = OffsetMapping(TexCoordSurfaceLightmap.xy);\n"
+"#else\n"
+"# define TexCoord (TexCoordSurfaceLightmap.xy)\n"
"#endif\n"
"\n"
" // combine the diffuse textures (base, pants, shirt)\n"
"#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
"#define SHADING\n"
" // deluxemap lightmapping using light vectors in modelspace (q3map2 -light -deluxe)\n"
-" myhalf3 lightnormal_modelspace = myhalf3(texture2D(Texture_Deluxemap, TexCoordLightmap)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);\n"
-" myhalf3 lightcolor = myhalf3(texture2D(Texture_Lightmap, TexCoordLightmap));\n"
+" myhalf3 lightnormal_modelspace = myhalf3(texture2D(Texture_Deluxemap, TexCoordSurfaceLightmap.zw)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);\n"
+" myhalf3 lightcolor = myhalf3(texture2D(Texture_Lightmap, TexCoordSurfaceLightmap.zw));\n"
" // convert modelspace light vector to tangentspace\n"
" myhalf3 lightnormal;\n"
" lightnormal.x = dot(lightnormal_modelspace, myhalf3(VectorS));\n"
"#ifdef MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n"
"#define SHADING\n"
" // deluxemap lightmapping using light vectors in tangentspace (hmap2 -light)\n"
-" myhalf3 lightnormal = myhalf3(texture2D(Texture_Deluxemap, TexCoordLightmap)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);\n"
-" myhalf3 lightcolor = myhalf3(texture2D(Texture_Lightmap, TexCoordLightmap));\n"
+" myhalf3 lightnormal = myhalf3(texture2D(Texture_Deluxemap, TexCoordSurfaceLightmap.zw)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);\n"
+" myhalf3 lightcolor = myhalf3(texture2D(Texture_Lightmap, TexCoordSurfaceLightmap.zw));\n"
"#endif\n"
"\n"
"\n"
"\n"
"\n"
"#ifdef MODE_LIGHTMAP\n"
-" color.rgb = diffusetex * (Color_Ambient + myhalf3(texture2D(Texture_Lightmap, TexCoordLightmap)) * Color_Diffuse);\n"
+" color.rgb = diffusetex * (Color_Ambient + myhalf3(texture2D(Texture_Lightmap, TexCoordSurfaceLightmap.zw)) * Color_Diffuse);\n"
"#endif // MODE_LIGHTMAP\n"
"#ifdef MODE_VERTEXCOLOR\n"
" color.rgb = diffusetex * (Color_Ambient + myhalf3(VertexColor.rgb) * Color_Diffuse);\n"