From: divverent Date: Mon, 20 Oct 2008 13:20:06 +0000 (+0000) Subject: q3map2 is too stupid to calculate proper surface normals when q3map_nonplanar is... X-Git-Tag: xonotic-v0.1.0preview~2054 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=56fd91b04f13a1dc31e36113683dda6a72795632;p=xonotic%2Fdarkplaces.git q3map2 is too stupid to calculate proper surface normals when q3map_nonplanar is used (the lightmap and deluxemap coords correspond to virtually random coordinates on that luxel, and NOT to its center, because recursive triangle subdivision is used to map the luxels to coordinates on the draw surfaces), which also causes deluxemaps to be wrong because light contributions from the wrong side of the surface are added up. To prevent divisions by zero or strong exaggerations, a max() nudge is done here at expense of some additional fps. This is ONLY needed for deluxemaps, tangentspace deluxemap avoid this problem by design. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8535 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index d1ee2700..14a1c3f4 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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"