]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
tweaked GLSL lighting shader to get a bit more performance (at least 7%) on GF6 by...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 28 Oct 2005 05:44:11 +0000 (05:44 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 28 Oct 2005 05:44:11 +0000 (05:44 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5777 d7cf8633-e32d-0410-b094-e92efae38249

r_shadow.c

index 7f39f3253bb93af21a0a21b1a680fa0f647bcf95..463f6e74e8b23580da13333c6ae44624b4c5476c 100644 (file)
@@ -280,15 +280,28 @@ const char *builtinshader_light_vert =
 "// ambient+diffuse+specular+normalmap+attenuation+cubemap+fog shader\n"
 "// written by Forest 'LordHavoc' Hale\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"
 "uniform vec3 LightPosition;\n"
 "\n"
 "varying vec2 TexCoord;\n"
-"varying vec3 CubeVector;\n"
-"varying vec3 LightVector;\n"
+"varying myhvec3 CubeVector;\n"
+"varying myhvec3 LightVector;\n"
 "\n"
 "#if defined(USESPECULAR) || defined(USEFOG) || defined(USEOFFSETMAPPING)\n"
 "uniform vec3 EyePosition;\n"
-"varying vec3 EyeVector;\n"
+"varying myhvec3 EyeVector;\n"
 "#endif\n"
 "\n"
 "// TODO: get rid of tangentt (texcoord2) and use a crossproduct to regenerate it from tangents (texcoord1) and normal (texcoord3)\n"
@@ -371,10 +384,10 @@ const char *builtinshader_light_frag =
 "#endif\n"
 "\n"
 "varying vec2 TexCoord;\n"
-"varying vec3 CubeVector;\n"
-"varying vec3 LightVector;\n"
+"varying myhvec3 CubeVector;\n"
+"varying myhvec3 LightVector;\n"
 "#if defined(USESPECULAR) || defined(USEFOG) || defined(USEOFFSETMAPPING)\n"
-"varying vec3 EyeVector;\n"
+"varying myhvec3 EyeVector;\n"
 "#endif\n"
 "\n"
 "void main(void)\n"
@@ -415,7 +428,7 @@ const char *builtinshader_light_frag =
 "      myhvec3 color = myhvec3(texture2D(Texture_Color, TexCoord)) * (AmbientScale + DiffuseScale * max(dot(surfacenormal, diffusenormal), 0.0));\n"
 "#ifdef USESPECULAR\n"
 "      myhvec3 specularnormal = myhvec3(normalize(diffusenormal + myhvec3(normalize(EyeVector))));\n"
-"      color += myhvec3(texture2D(Texture_Gloss, TexCoord)) * (SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower));\n"
+"      color += myhvec3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(max(dot(surfacenormal, specularnormal), 0.0), SpecularPower);\n"
 "#endif\n"
 "\n"
 "#ifdef USECUBEFILTER\n"