"#endif\n"
"\n"
"varying vec2 TexCoord;\n"
+"#if !defined(MODE_LIGHTSOURCE) && !defined(MODE_LIGHTDIRECTION)\n"
+"varying vec2 TexCoordLightmap;\n"
+"#endif\n"
"\n"
-"#ifdef USELIGHTSOURCE\n"
+"#ifdef MODE_LIGHTSOURCE\n"
"varying myhvec3 CubeVector;\n"
+"#endif\n"
+"\n"
+"#if defined(MODE_LIGHTSOURCE) || defined(MODE_LIGHTDIRECTION)\n"
"varying vec3 LightVector;\n"
"#endif\n"
"\n"
"// vertex shader specific:\n"
"#ifdef VERTEX_SHADER\n"
"\n"
-"#ifdef USELIGHTSOURCE\n"
+"#ifdef MODE_LIGHTSOURCE\n"
"uniform vec3 LightPosition;\n"
"#endif\n"
"\n"
"uniform vec3 EyePosition;\n"
"#endif\n"
"\n"
+"#ifdef MODE_LIGHTDIRECTION\n"
+"uniform myhvec3 LightDir;\n"
+"#endif\n"
+"\n"
"// TODO: get rid of tangentt (texcoord2) and use a crossproduct to regenerate it from tangents (texcoord1) and normal (texcoord3)\n"
"\n"
"void main(void)\n"
"{\n"
" // copy the surface texcoord\n"
" TexCoord = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);\n"
+"#if !defined(MODE_LIGHTSOURCE) && !defined(MODE_LIGHTDIRECTION)\n"
+" TexCoordLightmap = vec2(gl_MultiTexCoord4);\n"
+"#endif\n"
+" gl_FrontColor = gl_Color;\n"
"\n"
-"#ifdef USELIGHTSOURCE\n"
+"#ifdef MODE_LIGHTSOURCE\n"
" // transform vertex position into light attenuation/cubemap space\n"
" // (-1 to +1 across the light box)\n"
" CubeVector = vec3(gl_TextureMatrix[3] * gl_Vertex);\n"
" LightVector.z = dot(lightminusvertex, gl_MultiTexCoord3.xyz);\n"
"#endif\n"
"\n"
+"#ifdef MODE_LIGHTDIRECTION\n"
+" LightVector.x = dot(LightDir, gl_MultiTexCoord1.xyz);\n"
+" LightVector.y = dot(LightDir, gl_MultiTexCoord2.xyz);\n"
+" LightVector.z = dot(LightDir, gl_MultiTexCoord3.xyz);\n"
+"#endif\n"
+"\n"
"#if defined(USESPECULAR) || defined(USEFOG) || defined(USEOFFSETMAPPING)\n"
" // transform unnormalized eye direction into tangent space\n"
" vec3 eyeminusvertex = EyePosition - gl_Vertex.xyz;\n"
"uniform myhalf OffsetMapping_Bias;\n"
"#endif\n"
"\n"
-"#if defined(USELIGHTSOURCE) || defined(USEDELUXEMAPPING)\n"
+"#if defined(MODE_LIGHTSOURCE) || defined(MODE_LIGHTDIRECTIONMAP) || defined(MODE_LIGHTDIRECTION) || defined(USEOFFSETMAPPING)\n"
"uniform sampler2D Texture_Normal;\n"
"#endif\n"
"\n"
+"#ifdef MODE_LIGHTDIRECTION\n"
+"uniform myhvec3 AmbientColor;\n"
+"uniform myhvec3 DiffuseColor;\n"
+"uniform myhvec3 SpecularColor;\n"
+"#endif\n"
+"\n"
"uniform sampler2D Texture_Color;\n"
"\n"
+"#if !defined(MODE_LIGHTSOURCE) && !defined(MODE_LIGHTDIRECTION)\n"
+"uniform sampler2D Texture_Lightmap;\n"
+"#endif\n"
+"#ifdef MODE_LIGHTDIRECTIONMAP\n"
+"uniform sampler2D Texture_Deluxemap;\n"
+"#endif\n"
+"\n"
+"#ifdef USEGLOW\n"
+"uniform sampler2D Texture_Glow;\n"
+"#endif\n"
+"\n"
"#ifdef USECOLORMAPPING\n"
"uniform sampler2D Texture_Pants;\n"
"uniform sampler2D Texture_Shirt;\n"
"#endif\n"
"\n"
"#ifdef USEFOG\n"
+"uniform myhvec3 FogColor;\n"
"uniform myhalf FogRangeRecip;\n"
"uniform sampler2D Texture_FogMask;\n"
"#endif\n"
"\n"
+"#ifdef USEEASTEREGG\n"
+"void main(void)\n"
+"{\n"
+" gl_FragColor = myhvec4(0, 0, 0, 1);;\n"
+" int i;\n"
+" float o;\n"
+" vec2 p = vec2(CubeVector.x * 16.0, CubeVector.y * 16.0);\n"
+" vec2 c = vec2(CubeVector.x * 16.0, CubeVector.y * 16.0);\n"
+" for (i = 0;i < 1000 && dot(p,p) < 4.0;i = i + 1)\n"
+" {\n"
+" o = p.x * p.x - p.y * p.y;\n"
+" p.y = 2.0 * p.x * p.y;\n"
+" p.x = o;\n"
+" p += c;\n"
+" }\n"
+" o = float(i) * 0.314;\n"
+" if (i < 1000)\n"
+" gl_FragColor = vec4(cos(o), sin(o), sin(o * 0.2), 1);\n"
+"}\n"
+"#else // USEEASTEREGG\n"
+"\n"
+"\n"
+"\n"
"void main(void)\n"
"{\n"
" // apply offsetmapping\n"
"\n"
"\n"
"\n"
-"#ifdef USELIGHTSOURCE\n"
+"#ifdef MODE_LIGHTSOURCE\n"
" // light source\n"
"\n"
" // get the surface normal and light normal\n"
"\n"
"\n"
"\n"
+"#elif defined(MODE_LIGHTDIRECTION)\n"
+" // directional model lighting\n"
+"\n"
+" // get the surface normal and light normal\n"
+"#ifdef SURFACENORMALIZE\n"
+" myhvec3 surfacenormal = normalize(myhvec3(texture2D(Texture_Normal, TexCoord)) - 0.5);\n"
"#else\n"
-"#ifdef USEDELUXEMAPPING\n"
+" myhvec3 surfacenormal = -1.0 + 2.0 * myhvec3(texture2D(Texture_Normal, TexCoord));\n"
+"#endif\n"
+" myhvec3 diffusenormal = myhvec3(normalize(LightVector));\n"
+"\n"
+"\n"
+" // calculate directional shading\n"
+" color.rgb *= AmbientColor + DiffuseColor * max(dot(surfacenormal, diffusenormal), 0.0);\n"
+" //color.rgb *= AmbientColor + DiffuseColor * max(dot(surfacenormal, diffusenormal), 0.0);\n"
+"#ifdef USESPECULAR\n"
+" myhvec3 specularnormal = myhvec3(normalize(diffusenormal + myhvec3(normalize(EyeVector))));\n"
+" color.rgb += myhvec3(texture2D(Texture_Gloss, TexCoord)) * SpecularColor * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
+"#endif\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"#elif defined(MODE_LIGHTDIRECTIONMAP)\n"
" // deluxemap lightmapping\n"
"\n"
" // get the surface normal and light normal\n"
"#endif\n"
"\n"
" // calculate directional shading\n"
-" color.rgb *= (AmbientScale + DiffuseScale * max(dot(surfacenormal, diffusenormal), 0.0));\n"
+" myhvec3 tempcolor = color.rgb * (DiffuseScale * max(dot(surfacenormal, diffusenormal), 0.0)));\n"
"#ifdef USESPECULAR\n"
" myhvec3 specularnormal = myhvec3(normalize(diffusenormal + myhvec3(normalize(EyeVector))));\n"
-" color.rgb += myhvec3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
+" tempcolor += myhvec3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
"#endif\n"
"\n"
" // apply lightmap color\n"
-" color.rgb *= myhvec3(texture2D(Texture_Lightmap, TexCoordLightmap));\n"
+" color.rgb = tempcolor * myhvec3(texture2D(Texture_Lightmap, TexCoordLightmap)) + color.rgb * myhvec3(AmbientScale);\n"
"\n"
"\n"
"\n"
"\n"
-"#else\n"
+"#else // MODE none (lightmap)\n"
" // apply lightmap color\n"
-" color.rgb *= myhvec3(texture2D(Texture_Lightmap, TexCoordLightmap)) * DiffuseScale;\n"
-"#endif\n"
-"#endif\n"
-"\n"
-"\n"
+" color.rgb *= myhvec3(texture2D(Texture_Lightmap, TexCoordLightmap)) * DiffuseScale + myhvec3(AmbientScale);\n"
+"#endif // MODE\n"
"\n"
+"#ifdef USEGLOW\n"
+" color.rgb += myhvec3(texture2D(Texture_Glow, TexCoord));\n"
+"#endif\n"
"\n"
"#ifdef USEFOG\n"
" // apply fog\n"
-" myhalf fog = texture2D(Texture_FogMask, myhvec2(length(EyeVector)*FogRangeRecip, 0)).x;\n"
-" color.rgb = color.rgb * (1 - fog) + FogColor * fog;\n"
+" myhalf fog = texture2D(Texture_FogMask, myhvec2(length(EyeVector)*FogRangeRecip, 0.0)).x;\n"
+" color.rgb = color.rgb * fog + FogColor * (1.0 - fog);\n"
"#endif\n"
"\n"
-" gl_FragColor = color;\n"
+" gl_FragColor = color * gl_Color;\n"
"}\n"
+"#endif // !USEEASTEREGG\n"
"\n"
"#endif\n"
;