From: havoc Date: Fri, 28 Oct 2005 05:44:11 +0000 (+0000) Subject: tweaked GLSL lighting shader to get a bit more performance (at least 7%) on GF6 by... X-Git-Tag: xonotic-v0.1.0preview~4507 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1ccf665076953f8b4693c6dafe41ca183d3d122f;p=xonotic%2Fdarkplaces.git tweaked GLSL lighting shader to get a bit more performance (at least 7%) on GF6 by making all variables half precision except TexCoord, hopefully also helps GFFX git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5777 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/r_shadow.c b/r_shadow.c index 7f39f325..463f6e74 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -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"