+ if(thread->shader_mode == SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE)
+ {
+ // myhalf3 lightnormal_modelspace = myhalf3(dp_texture2D(Texture_Deluxemap, TexCoordSurfaceLightmap.zw)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);\n";
+ lightnormal_modelspace[0] = buffer_texture_deluxemapbgra8[x*4+2] * (1.0f / 128.0f) - 1.0f;
+ lightnormal_modelspace[1] = buffer_texture_deluxemapbgra8[x*4+1] * (1.0f / 128.0f) - 1.0f;
+ lightnormal_modelspace[2] = buffer_texture_deluxemapbgra8[x*4+0] * (1.0f / 128.0f) - 1.0f;
+
+ // lightnormal.x = dot(lightnormal_modelspace, myhalf3(VectorS));\n"
+ lightnormal[0] = lightnormal_modelspace[0] * (VectorSdata[0] + VectorSslope[0] * x)
+ + lightnormal_modelspace[1] * (VectorSdata[1] + VectorSslope[1] * x)
+ + lightnormal_modelspace[2] * (VectorSdata[2] + VectorSslope[2] * x);
+
+ // lightnormal.y = dot(lightnormal_modelspace, myhalf3(VectorT));\n"
+ lightnormal[1] = lightnormal_modelspace[0] * (VectorTdata[0] + VectorTslope[0] * x)
+ + lightnormal_modelspace[1] * (VectorTdata[1] + VectorTslope[1] * x)
+ + lightnormal_modelspace[2] * (VectorTdata[2] + VectorTslope[2] * x);
+
+ // lightnormal.z = dot(lightnormal_modelspace, myhalf3(VectorR));\n"
+ lightnormal[2] = lightnormal_modelspace[0] * (VectorRdata[0] + VectorRslope[0] * x)
+ + lightnormal_modelspace[1] * (VectorRdata[1] + VectorRslope[1] * x)
+ + lightnormal_modelspace[2] * (VectorRdata[2] + VectorRslope[2] * x);
+
+ // lightnormal = normalize(lightnormal); // VectorS/T/R are not always perfectly normalized, and EXACTSPECULARMATH is very picky about this\n"
+ DPSOFTRAST_Vector3Normalize(lightnormal);
+
+ // myhalf3 lightcolor = myhalf3(dp_texture2D(Texture_Lightmap, TexCoordSurfaceLightmap.zw));\n";
+ {
+ float f = 1.0f / (256.0f * max(0.25f, lightnormal[2]));
+ LightColor[0] = buffer_texture_lightmapbgra8[x*4+0] * f;
+ LightColor[1] = buffer_texture_lightmapbgra8[x*4+1] * f;
+ LightColor[2] = buffer_texture_lightmapbgra8[x*4+2] * f;
+ }
+ }
+ else
+ {
+ lightnormal[0] = (LightVectordata[0] + LightVectorslope[0]*x) * z;
+ lightnormal[1] = (LightVectordata[1] + LightVectorslope[1]*x) * z;
+ lightnormal[2] = (LightVectordata[2] + LightVectorslope[2]*x) * z;
+ DPSOFTRAST_Vector3Normalize(lightnormal);
+ }