]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
some cleanup of the GLSL shader, no longer uses #ifdef variable declarations because...
[xonotic/darkplaces.git] / gl_rmain.c
index 7af8009a7a92ed0ca88da60dcf767b79d5873ef8..d5c180eeebe9bc423b647d72b2037dd2f29884ba 100644 (file)
@@ -102,8 +102,6 @@ cvar_t r_glsl = {0, "r_glsl", "1", "enables use of OpenGL 2.0 pixel shaders for
 cvar_t r_glsl_offsetmapping = {0, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"};
 cvar_t r_glsl_offsetmapping_reliefmapping = {0, "r_glsl_offsetmapping_reliefmapping", "0", "relief mapping effect (higher quality)"};
 cvar_t r_glsl_offsetmapping_scale = {0, "r_glsl_offsetmapping_scale", "0.04", "how deep the offset mapping effect is"};
-cvar_t r_glsl_usehalffloat = {0, "r_glsl_usehalffloat", "0", "use half and hvec variables in GLSL shader for a speed gain (NVIDIA only)"};
-cvar_t r_glsl_surfacenormalize = {0, "r_glsl_surfacenormalize", "1", "normalize bumpmap texels in GLSL shader, produces a more rounded look on small bumps and dents"};
 cvar_t r_glsl_deluxemapping = {0, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"};
 
 cvar_t r_lerpsprites = {CVAR_SAVE, "r_lerpsprites", "1", "enables animation smoothing on sprites (requires r_lerpmodels 1)"};
@@ -415,41 +413,16 @@ static const char *builtinshaderstring =
 "\n"
 "// common definitions between vertex shader and fragment shader:\n"
 "\n"
-"// use half floats if available for math performance\n"
-"#ifdef GEFORCEFX\n"
-"#define myhalf half\n"
-"#define myhvec2 hvec2\n"
-"#define myhvec3 hvec3\n"
-"#define myhvec4 hvec4\n"
-"#else\n"
-"#define myhalf float\n"
-"#define myhvec2 vec2\n"
-"#define myhvec3 vec3\n"
-"#define myhvec4 vec4\n"
-"#endif\n"
-"\n"
 "varying vec2 TexCoord;\n"
-"#if !defined(MODE_LIGHTSOURCE) && !defined(MODE_LIGHTDIRECTION)\n"
 "varying vec2 TexCoordLightmap;\n"
-"#endif\n"
 "\n"
-"#ifdef MODE_LIGHTSOURCE\n"
-"varying myhvec3 CubeVector;\n"
-"#endif\n"
-"\n"
-"#if defined(MODE_LIGHTSOURCE) || defined(MODE_LIGHTDIRECTION)\n"
+"varying vec3 CubeVector;\n"
 "varying vec3 LightVector;\n"
-"#endif\n"
-"\n"
-"#if defined(USESPECULAR) || defined(USEFOG) || defined(USEOFFSETMAPPING)\n"
 "varying vec3 EyeVector;\n"
-"#endif\n"
 "\n"
-"#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
-"varying myhvec3 VectorS; // direction of S texcoord (sometimes crudely called tangent)\n"
-"varying myhvec3 VectorT; // direction of T texcoord (sometimes crudely called binormal)\n"
-"varying myhvec3 VectorR; // direction of R texcoord (surface normal)\n"
-"#endif\n"
+"varying vec3 VectorS; // direction of S texcoord (sometimes crudely called tangent)\n"
+"varying vec3 VectorT; // direction of T texcoord (sometimes crudely called binormal)\n"
+"varying vec3 VectorR; // direction of R texcoord (surface normal)\n"
 "\n"
 "\n"
 "\n"
@@ -457,28 +430,20 @@ static const char *builtinshaderstring =
 "// vertex shader specific:\n"
 "#ifdef VERTEX_SHADER\n"
 "\n"
-"#ifdef MODE_LIGHTSOURCE\n"
 "uniform vec3 LightPosition;\n"
-"#endif\n"
-"\n"
-"#if defined(USESPECULAR) || defined(USEFOG) || defined(USEOFFSETMAPPING)\n"
 "uniform vec3 EyePosition;\n"
-"#endif\n"
-"\n"
-"#ifdef MODE_LIGHTDIRECTION\n"
-"uniform myhvec3 LightDir;\n"
-"#endif\n"
+"uniform vec3 LightDir;\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"
+"      gl_FrontColor = gl_Color;\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 MODE_LIGHTSOURCE\n"
 "      // transform vertex position into light attenuation/cubemap space\n"
@@ -500,13 +465,11 @@ static const char *builtinshaderstring =
 "      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"
 "      EyeVector.x = dot(eyeminusvertex, gl_MultiTexCoord1.xyz);\n"
 "      EyeVector.y = dot(eyeminusvertex, gl_MultiTexCoord2.xyz);\n"
 "      EyeVector.z = dot(eyeminusvertex, gl_MultiTexCoord3.xyz);\n"
-"#endif\n"
 "\n"
 "#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
 "      VectorS = gl_MultiTexCoord1.xyz;\n"
@@ -519,7 +482,7 @@ static const char *builtinshaderstring =
 "      gl_Position = ftransform();\n"
 "}\n"
 "\n"
-"#endif\n"
+"#endif // VERTEX_SHADER\n"
 "\n"
 "\n"
 "\n"
@@ -527,97 +490,48 @@ static const char *builtinshaderstring =
 "// fragment shader specific:\n"
 "#ifdef FRAGMENT_SHADER\n"
 "\n"
-"uniform myhvec3 LightColor;\n"
-"#ifdef USEOFFSETMAPPING\n"
-"uniform myhalf OffsetMapping_Scale;\n"
-"uniform myhalf OffsetMapping_Bias;\n"
-"#endif\n"
-"\n"
-"#if defined(MODE_LIGHTSOURCE) || defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE) || 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"
-"#if defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE)\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"
-"uniform myhvec3 Color_Pants;\n"
-"uniform myhvec3 Color_Shirt;\n"
-"#endif\n"
-"\n"
-"uniform myhalf AmbientScale;\n"
-"uniform myhalf DiffuseScale;\n"
-"#ifdef USESPECULAR\n"
-"uniform myhalf SpecularScale;\n"
-"uniform myhalf SpecularPower;\n"
 "uniform sampler2D Texture_Gloss;\n"
-"#endif\n"
-"\n"
-"#ifdef USECUBEFILTER\n"
 "uniform samplerCube Texture_Cube;\n"
-"#endif\n"
-"\n"
-"#ifdef USEFOG\n"
-"uniform myhvec3 FogColor;\n"
-"uniform myhalf FogRangeRecip;\n"
 "uniform sampler2D Texture_FogMask;\n"
-"#endif\n"
+"uniform sampler2D Texture_Pants;\n"
+"uniform sampler2D Texture_Shirt;\n"
+"uniform sampler2D Texture_Lightmap;\n"
+"uniform sampler2D Texture_Deluxemap;\n"
+"uniform sampler2D Texture_Glow;\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"
+"uniform vec3 LightColor;\n"
+"uniform vec3 AmbientColor;\n"
+"uniform vec3 DiffuseColor;\n"
+"uniform vec3 SpecularColor;\n"
+"uniform vec3 Color_Pants;\n"
+"uniform vec3 Color_Shirt;\n"
+"uniform vec3 FogColor;\n"
 "\n"
+"uniform float OffsetMapping_Scale;\n"
+"uniform float OffsetMapping_Bias;\n"
+"uniform float FogRangeRecip;\n"
 "\n"
+"uniform float AmbientScale;\n"
+"uniform float DiffuseScale;\n"
+"uniform float SpecularScale;\n"
+"uniform float SpecularPower;\n"
 "\n"
 "void main(void)\n"
 "{\n"
 "      // apply offsetmapping\n"
 "#ifdef USEOFFSETMAPPING\n"
-"      myhvec2 TexCoordOffset = TexCoord;\n"
+"      vec2 TexCoordOffset = TexCoord;\n"
 "#define TexCoord TexCoordOffset\n"
 "\n"
-"      myhvec3 eyedir = myhvec3(normalize(EyeVector));\n"
-"      myhalf depthbias = 1.0 - eyedir.z; // should this be a -?\n"
+"      vec3 eyedir = vec3(normalize(EyeVector));\n"
+"      float depthbias = 1.0 - eyedir.z; // should this be a -?\n"
 "      depthbias = 1.0 - depthbias * depthbias;\n"
 "\n"
 "#ifdef USEOFFSETMAPPING_RELIEFMAPPING\n"
 "      // 14 sample relief mapping: linear search and then binary search\n"
-"      myhvec3 OffsetVector = myhvec3(EyeVector.xy * (1.0 / EyeVector.z) * depthbias * OffsetMapping_Scale * myhvec2(-0.1, 0.1), -0.1);\n"
+"      vec3 OffsetVector = vec3(EyeVector.xy * (1.0 / EyeVector.z) * depthbias * OffsetMapping_Scale * vec2(-0.1, 0.1), -0.1);\n"
 "      vec3 RT = vec3(TexCoord - OffsetVector.xy * 10.0, 1.0) + OffsetVector;\n"
 "      if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
 "      if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
@@ -636,7 +550,8 @@ static const char *builtinshaderstring =
 "      TexCoord = RT.xy;\n"
 "#else\n"
 "      // 3 sample offset mapping (only 3 samples because of ATI Radeon 9500-9800/X300 limits)\n"
-"      myhvec2 OffsetVector = myhvec2((EyeVector.xy * (1.0 / EyeVector.z) * depthbias) * OffsetMapping_Scale * myhvec2(-0.333, 0.333));\n"
+"      vec2 OffsetVector = vec2((EyeVector.xy * (1.0 / EyeVector.z) * depthbias) * OffsetMapping_Scale * vec2(-0.333, 0.333));\n"
+"      //TexCoord += OffsetVector * 3.0;\n"
 "      TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;\n"
 "      TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;\n"
 "      TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;\n"
@@ -644,9 +559,9 @@ static const char *builtinshaderstring =
 "#endif\n"
 "\n"
 "      // combine the diffuse textures (base, pants, shirt)\n"
-"      myhvec4 color = myhvec4(texture2D(Texture_Color, TexCoord));\n"
+"      vec4 color = vec4(texture2D(Texture_Color, TexCoord));\n"
 "#ifdef USECOLORMAPPING\n"
-"      color.rgb += myhvec3(texture2D(Texture_Pants, TexCoord)) * Color_Pants + myhvec3(texture2D(Texture_Shirt, TexCoord)) * Color_Shirt;\n"
+"      color.rgb += vec3(texture2D(Texture_Pants, TexCoord)) * Color_Pants + vec3(texture2D(Texture_Shirt, TexCoord)) * Color_Shirt;\n"
 "#endif\n"
 "\n"
 "\n"
@@ -656,27 +571,24 @@ static const char *builtinshaderstring =
 "      // light source\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"
-"      myhvec3 surfacenormal = -1.0 + 2.0 * myhvec3(texture2D(Texture_Normal, TexCoord));\n"
-"#endif\n"
-"      myhvec3 diffusenormal = myhvec3(normalize(LightVector));\n"
+"      vec3 surfacenormal = normalize(vec3(texture2D(Texture_Normal, TexCoord)) - 0.5);\n"
+"      vec3 diffusenormal = vec3(normalize(LightVector));\n"
 "\n"
 "      // calculate directional shading\n"
 "      color.rgb *= (AmbientScale + 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"
+"      vec3 specularnormal = vec3(normalize(diffusenormal + vec3(normalize(EyeVector))));\n"
+"      color.rgb += vec3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
 "#endif\n"
 "\n"
 "#ifdef USECUBEFILTER\n"
 "      // apply light cubemap filter\n"
-"      color.rgb *= myhvec3(textureCube(Texture_Cube, CubeVector));\n"
+"      //color.rgb *= normalize(CubeVector) * 0.5 + 0.5;//vec3(textureCube(Texture_Cube, CubeVector));\n"
+"      color.rgb *= vec3(textureCube(Texture_Cube, CubeVector));\n"
 "#endif\n"
 "\n"
 "      // apply light color\n"
-"      color.rgb = color.rgb * LightColor;\n"
+"      color.rgb *= LightColor;\n"
 "\n"
 "      // apply attenuation\n"
 "      //\n"
@@ -695,19 +607,14 @@ static const char *builtinshaderstring =
 "      // 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"
-"      myhvec3 surfacenormal = -1.0 + 2.0 * myhvec3(texture2D(Texture_Normal, TexCoord));\n"
-"#endif\n"
-"      myhvec3 diffusenormal = myhvec3(normalize(LightVector));\n"
-"\n"
+"      vec3 surfacenormal = normalize(vec3(texture2D(Texture_Normal, TexCoord)) - 0.5);\n"
+"      vec3 diffusenormal = vec3(normalize(LightVector));\n"
 "\n"
 "      // calculate directional shading\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"
+"      vec3 specularnormal = vec3(normalize(diffusenormal + vec3(normalize(EyeVector))));\n"
+"      color.rgb += vec3(texture2D(Texture_Gloss, TexCoord)) * SpecularColor * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
 "#endif\n"
 "\n"
 "\n"
@@ -717,23 +624,19 @@ static const char *builtinshaderstring =
 "      // deluxemap lightmapping using light vectors in modelspace (evil q3map2)\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"
-"      myhvec3 surfacenormal = -1.0 + 2.0 * myhvec3(texture2D(Texture_Normal, TexCoord));\n"
-"#endif\n"
-"      myhvec3 diffusenormal_modelspace = myhvec3(texture2D(Texture_Deluxemap, TexCoordLightmap)) - 0.5;\n"
-"      myhvec3 diffusenormal = normalize(myhvec3(dot(diffusenormal_modelspace, VectorS), dot(diffusenormal_modelspace, VectorT), dot(diffusenormal_modelspace, VectorR)));\n"
+"      vec3 surfacenormal = normalize(vec3(texture2D(Texture_Normal, TexCoord)) - 0.5);\n"
+"      vec3 diffusenormal_modelspace = vec3(texture2D(Texture_Deluxemap, TexCoordLightmap)) - 0.5;\n"
+"      vec3 diffusenormal = normalize(vec3(dot(diffusenormal_modelspace, VectorS), dot(diffusenormal_modelspace, VectorT), dot(diffusenormal_modelspace, VectorR)));\n"
 "\n"
 "      // calculate directional shading\n"
-"      myhvec3 tempcolor = color.rgb * (DiffuseScale * max(dot(surfacenormal, diffusenormal), 0.0));\n"
+"      vec3 tempcolor = color.rgb * (DiffuseScale * max(dot(surfacenormal, diffusenormal), 0.0));\n"
 "#ifdef USESPECULAR\n"
-"      myhvec3 specularnormal = myhvec3(normalize(diffusenormal + myhvec3(normalize(EyeVector))));\n"
-"      tempcolor += myhvec3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
+"      vec3 specularnormal = vec3(normalize(diffusenormal + vec3(normalize(EyeVector))));\n"
+"      tempcolor += vec3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
 "#endif\n"
 "\n"
 "      // apply lightmap color\n"
-"      color.rgb = tempcolor * myhvec3(texture2D(Texture_Lightmap, TexCoordLightmap)) + color.rgb * myhvec3(AmbientScale);\n"
+"      color.rgb = tempcolor * vec3(texture2D(Texture_Lightmap, TexCoordLightmap)) + color.rgb * vec3(AmbientScale);\n"
 "\n"
 "\n"
 "\n"
@@ -742,47 +645,41 @@ static const char *builtinshaderstring =
 "      // deluxemap lightmapping using light vectors in tangentspace\n"
 "\n"
 "      // get the surface normal and light normal\n"
-"#ifdef SURFACENORMALIZE\n"
-"      myhvec3 surfacenormal = normalize(myhvec3(texture2D(Texture_Normal, TexCoord)) - 0.5);\n"
-"      myhvec3 diffusenormal = normalize(myhvec3(texture2D(Texture_Deluxemap, TexCoordLightmap)) - 0.5);\n"
-"#else\n"
-"      myhvec3 surfacenormal = -1.0 + 2.0 * myhvec3(texture2D(Texture_Normal, TexCoord));\n"
-"      myhvec3 diffusenormal = -1.0 + 2.0 * myhvec3(texture2D(Texture_Deluxemap, TexCoordLightmap));\n"
-"#endif\n"
+"      vec3 surfacenormal = normalize(vec3(texture2D(Texture_Normal, TexCoord)) - 0.5);\n"
+"      vec3 diffusenormal = normalize(vec3(texture2D(Texture_Deluxemap, TexCoordLightmap)) - 0.5);\n"
 "\n"
 "      // calculate directional shading\n"
-"      myhvec3 tempcolor = color.rgb * (DiffuseScale * max(dot(surfacenormal, diffusenormal), 0.0));\n"
+"      vec3 tempcolor = color.rgb * (DiffuseScale * max(dot(surfacenormal, diffusenormal), 0.0));\n"
 "#ifdef USESPECULAR\n"
-"      myhvec3 specularnormal = myhvec3(normalize(diffusenormal + myhvec3(normalize(EyeVector))));\n"
-"      tempcolor += myhvec3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
+"      vec3 specularnormal = vec3(normalize(diffusenormal + vec3(normalize(EyeVector))));\n"
+"      tempcolor += vec3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
 "#endif\n"
 "\n"
 "      // apply lightmap color\n"
-"      color.rgb = tempcolor * myhvec3(texture2D(Texture_Lightmap, TexCoordLightmap)) + color.rgb * myhvec3(AmbientScale);\n"
+"      color.rgb = tempcolor * vec3(texture2D(Texture_Lightmap, TexCoordLightmap)) + color.rgb * vec3(AmbientScale);\n"
 "\n"
 "\n"
 "\n"
 "\n"
 "#else // MODE none (lightmap)\n"
 "      // apply lightmap color\n"
-"      color.rgb *= myhvec3(texture2D(Texture_Lightmap, TexCoordLightmap)) * DiffuseScale + myhvec3(AmbientScale);\n"
+"      color.rgb *= vec3(texture2D(Texture_Lightmap, TexCoordLightmap)) * DiffuseScale + vec3(AmbientScale);\n"
 "#endif // MODE\n"
 "\n"
 "#ifdef USEGLOW\n"
-"      color.rgb += myhvec3(texture2D(Texture_Glow, TexCoord));\n"
+"      color.rgb += vec3(texture2D(Texture_Glow, TexCoord));\n"
 "#endif\n"
 "\n"
 "#ifdef USEFOG\n"
 "      // apply fog\n"
-"      myhalf fog = texture2D(Texture_FogMask, myhvec2(length(EyeVector)*FogRangeRecip, 0.0)).x;\n"
+"      float fog = texture2D(Texture_FogMask, vec2(length(EyeVector)*FogRangeRecip, 0.0)).x;\n"
 "      color.rgb = color.rgb * fog + FogColor * (1.0 - fog);\n"
 "#endif\n"
 "\n"
 "      gl_FragColor = color * gl_Color;\n"
 "}\n"
-"#endif // !USEEASTEREGG\n"
 "\n"
-"#endif\n"
+"#endif // FRAGMENT_SHADER\n"
 ;
 
 void R_GLSL_CompilePermutation(int permutation)
@@ -868,18 +765,6 @@ void R_GLSL_CompilePermutation(int permutation)
                fragstrings_list[fragstrings_count++] = "#define USEOFFSETMAPPING_RELIEFMAPPING\n";
                strlcat(permutationname, " OFFSETMAPPING_RELIEFMAPPING", sizeof(permutationname));
        }
-       if (permutation & SHADERPERMUTATION_SURFACENORMALIZE)
-       {
-               vertstrings_list[vertstrings_count++] = "#define SURFACENORMALIZE\n";
-               fragstrings_list[fragstrings_count++] = "#define SURFACENORMALIZE\n";
-               strlcat(permutationname, " surfacenormalize", sizeof(permutationname));
-       }
-       if (permutation & SHADERPERMUTATION_GEFORCEFX)
-       {
-               vertstrings_list[vertstrings_count++] = "#define GEFORCEFX\n";
-               fragstrings_list[fragstrings_count++] = "#define GEFORCEFX\n";
-               strlcat(permutationname, " halffloat", sizeof(permutationname));
-       }
        shaderstring = (char *)FS_LoadFile("glsl/default.glsl", r_main_mempool, false, NULL);
        if (shaderstring)
        {
@@ -995,10 +880,6 @@ void R_SetupSurfaceShader(const entity_render_t *ent, const texture_t *texture,
                if (r_glsl_offsetmapping_reliefmapping.integer)
                        permutation |= SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING;
        }
-       if (r_glsl_surfacenormalize.integer)
-               permutation |= SHADERPERMUTATION_SURFACENORMALIZE;
-       if (r_glsl_usehalffloat.integer)
-               permutation |= SHADERPERMUTATION_GEFORCEFX;
        if (!r_glsl_permutations[permutation].program)
        {
                if (!r_glsl_permutations[permutation].compiled)
@@ -1105,9 +986,6 @@ void R_SetupSurfaceShader(const entity_render_t *ent, const texture_t *texture,
 
 void gl_main_start(void)
 {
-       // use half float math where available (speed gain on NVIDIA GFFX and GF6)
-       if (gl_support_half_float)
-               Cvar_SetValue("r_glsl_usehalffloat", 1);
        r_main_texturepool = R_AllocTexturePool();
        r_bloom_texture_screen = NULL;
        r_bloom_texture_bloom = NULL;
@@ -1189,8 +1067,6 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable(&r_glsl_offsetmapping);
        Cvar_RegisterVariable(&r_glsl_offsetmapping_reliefmapping);
        Cvar_RegisterVariable(&r_glsl_offsetmapping_scale);
-       Cvar_RegisterVariable(&r_glsl_usehalffloat);
-       Cvar_RegisterVariable(&r_glsl_surfacenormalize);
        Cvar_RegisterVariable(&r_glsl_deluxemapping);
        Cvar_RegisterVariable(&r_lerpsprites);
        Cvar_RegisterVariable(&r_lerpmodels);