]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
q3map2 is too stupid to calculate proper surface normals when q3map_nonplanar is...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 20 Oct 2008 13:20:06 +0000 (13:20 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 20 Oct 2008 13:20:06 +0000 (13:20 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8535 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index d1ee2700ec908d69961dc85d4749e9c4be1f8b24..14a1c3f47104c1e0b8f534ebc0c8623bee698b05 100644 (file)
@@ -950,7 +950,16 @@ static const char *builtinshaderstring =
 "      diffusenormal.y = dot(diffusenormal_modelspace, myhalf3(VectorT));\n"
 "      diffusenormal.z = dot(diffusenormal_modelspace, myhalf3(VectorR));\n"
 "      // calculate directional shading (and undoing the existing angle attenuation on the lightmap by the division)\n"
-"      myhalf3 tempcolor = color.rgb * (DiffuseScale * myhalf(max(float(dot(surfacenormal, diffusenormal) / diffusenormal.z), 0.0)));\n"
+"      // note that q3map2 is too stupid to calculate proper surface normals when q3map_nonplanar\n"
+"      // is used (the lightmap and deluxemap coords correspond to virtually random coordinates\n"
+"      // on that luxel, and NOT to its center, because recursive triangle subdivision is used\n"
+"      // to map the luxels to coordinates on the draw surfaces), which also causes\n"
+"      // deluxemaps to be wrong because light contributions from the wrong side of the surface\n"
+"      // are added up. To prevent divisions by zero or strong exaggerations, a max()\n"
+"      // nudge is done here at expense of some additional fps. This is ONLY needed for\n"
+"      // deluxemaps, tangentspace deluxemap avoid this problem by design.\n"
+"      myhalf3 tempcolor = color.rgb * (DiffuseScale * myhalf(max(float(dot(surfacenormal, diffusenormal) / max(0.25, diffusenormal.z)), 0.0)));\n"
+"              // 0.25 supports up to 75.5 degrees normal/deluxe angle\n"
 "# ifdef USESPECULAR\n"
 "#  ifdef USEEXACTSPECULARMATH\n"
 "      tempcolor += myhalf3(texture2D(Texture_Gloss, TexCoord)) * SpecularScale * pow(myhalf(max(float(dot(reflect(diffusenormal, surfacenormal), normalize(EyeVector)))*-1.0, 0.0)), SpecularPower);\n"