#define MM_FREE free
#endif
+#define DPSOFTRAST_FLT_MIN 0.000000000000000001f
+
typedef enum DPSOFTRAST_ARRAY_e
{
DPSOFTRAST_ARRAY_POSITION,
specularnormal[2] = lightnormal[2] + eyenormal[2];
DPSOFTRAST_Vector3Normalize(specularnormal);
- specular = DPSOFTRAST_Vector3Dot(surfacenormal, specularnormal);if (specular < 0.0f) specular = 0.0f;
+ specular = DPSOFTRAST_Vector3Dot(surfacenormal, specularnormal);if (specular < DPSOFTRAST_FLT_MIN) specular = DPSOFTRAST_FLT_MIN;
}
specular = pow(specular, SpecularPower * glosstex[3]);
specularnormal[2] = lightnormal[2] + eyenormal[2];
DPSOFTRAST_Vector3Normalize(specularnormal);
- specular = DPSOFTRAST_Vector3Dot(surfacenormal, specularnormal);if (specular < 0.0f) specular = 0.0f;
+ specular = DPSOFTRAST_Vector3Dot(surfacenormal, specularnormal);if (specular < DPSOFTRAST_FLT_MIN) specular = DPSOFTRAST_FLT_MIN;
}
specular = pow(specular, SpecularPower * glosstex[3]);
"#define highp\n"
"#endif\n"
"\n"
+"// not REALLY the smallest value (2^-62 would be correct), but short and any compiler failing at parsing this is broken\n"
+"#define FLT_MIN 0.000000000000000001\n"
+"\n"
"#ifdef VERTEX_SHADER\n"
"dp_attribute vec4 Attrib_Position; // vertex\n"
"dp_attribute vec4 Attrib_Color; // color\n"
" // calculate directional shading\n"
" vec3 eyevector = position * -1.0;\n"
"# ifdef USEEXACTSPECULARMATH\n"
-" myhalf specular = pow(cast_myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(eyevector)))*-1.0, 0.0)), SpecularPower * normalmap.a);\n"
+" myhalf specular = pow(cast_myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(eyevector)))*-1.0, FLT_MIN)), SpecularPower * normalmap.a);\n"
"# else\n"
" myhalf3 specularnormal = normalize(lightnormal + cast_myhalf3(normalize(eyevector)));\n"
-" myhalf specular = pow(cast_myhalf(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * normalmap.a);\n"
+" myhalf specular = pow(cast_myhalf(max(float(dot(surfacenormal, specularnormal)), FLT_MIN)), SpecularPower * normalmap.a);\n"
"# endif\n"
"#endif\n"
"\n"
" color.rgb = diffusetex * (Color_Ambient + diffuse * Color_Diffuse);\n"
"#ifdef USESPECULAR\n"
"#ifdef USEEXACTSPECULARMATH\n"
-" myhalf specular = pow(cast_myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVectorFogDepth.xyz)))*-1.0, 0.0)), SpecularPower * glosstex.a);\n"
+" myhalf specular = pow(cast_myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVectorFogDepth.xyz)))*-1.0, FLT_MIN)), SpecularPower * glosstex.a);\n"
"#else\n"
" myhalf3 specularnormal = normalize(lightnormal + cast_myhalf3(normalize(EyeVectorFogDepth.xyz)));\n"
-" myhalf specular = pow(cast_myhalf(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * glosstex.a);\n"
+" myhalf specular = pow(cast_myhalf(max(float(dot(surfacenormal, specularnormal)), FLT_MIN)), SpecularPower * glosstex.a);\n"
"#endif\n"
" color.rgb += glosstex.rgb * (specular * Color_Specular);\n"
"#endif\n"
" myhalf diffuse = cast_myhalf(max(float(dot(surfacenormal, lightnormal)), 0.0));\n"
"# ifdef USESPECULAR\n"
"# ifdef USEEXACTSPECULARMATH\n"
-" myhalf specular = pow(cast_myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVectorFogDepth.xyz)))*-1.0, 0.0)), SpecularPower * glosstex.a);\n"
+" myhalf specular = pow(cast_myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVectorFogDepth.xyz)))*-1.0, FLT_MIN)), SpecularPower * glosstex.a);\n"
"# else\n"
" myhalf3 specularnormal = normalize(lightnormal + cast_myhalf3(normalize(EyeVectorFogDepth.xyz)));\n"
-" myhalf specular = pow(cast_myhalf(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * glosstex.a);\n"
+" myhalf specular = pow(cast_myhalf(max(float(dot(surfacenormal, specularnormal)), FLT_MIN)), SpecularPower * glosstex.a);\n"
"# endif\n"
" color.rgb = diffusetex * Color_Ambient + (diffusetex * Color_Diffuse * diffuse + glosstex.rgb * Color_Specular * specular) * lightcolor;\n"
"# else\n"
"// written by Forest 'LordHavoc' Hale\n"
"// shadowmapping enhancements by Lee 'eihrul' Salzman\n"
"\n"
+"// not REALLY the smallest value (2^-62 would be correct), but short and any compiler failing at parsing this is broken\n"
+"#define FLT_MIN 0.000000000000000001\n"
+"\n"
"// FIXME: we need to get rid of ModelViewProjectionPosition to make room for the texcoord for this\n"
"#if defined(USEREFLECTION)\n"
"#undef USESHADOWMAPORTHO\n"
" // calculate directional shading\n"
" float3 eyevector = position * -1.0;\n"
"# ifdef USEEXACTSPECULARMATH\n"
-" half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(eyevector)))*-1.0, 0.0)), SpecularPower * normalmap.a));\n"
+" half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(eyevector)))*-1.0, FLT_MIN)), SpecularPower * normalmap.a));\n"
"# else\n"
" half3 specularnormal = half3(normalize(lightnormal + half3(normalize(eyevector))));\n"
-" half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * normalmap.a));\n"
+" half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), FLT_MIN)), SpecularPower * normalmap.a));\n"
"# endif\n"
"#endif\n"
"\n"
" color.rgb = diffusetex * (Color_Ambient + diffuse * Color_Diffuse);\n"
"#ifdef USESPECULAR\n"
"#ifdef USEEXACTSPECULARMATH\n"
-" half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVector)))*-1.0, 0.0)), SpecularPower * glosstex.a));\n"
+" half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVector)))*-1.0, FLT_MIN)), SpecularPower * glosstex.a));\n"
"#else\n"
" half3 specularnormal = half3(normalize(lightnormal + half3(normalize(EyeVector))));\n"
-" half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * glosstex.a));\n"
+" half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), FLT_MIN)), SpecularPower * glosstex.a));\n"
"#endif\n"
" color.rgb += glosstex.rgb * (specular * Color_Specular);\n"
"#endif\n"
" half diffuse = half(max(float(dot(surfacenormal, lightnormal)), 0.0));\n"
"# ifdef USESPECULAR\n"
"# ifdef USEEXACTSPECULARMATH\n"
-" half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVector)))*-1.0, 0.0)), SpecularPower * glosstex.a));\n"
+" half specular = half(pow(half(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVector)))*-1.0, FLT_MIN)), SpecularPower * glosstex.a));\n"
"# else\n"
" half3 specularnormal = half3(normalize(lightnormal + half3(normalize(EyeVector))));\n"
-" half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * glosstex.a));\n"
+" half specular = half(pow(half(max(float(dot(surfacenormal, specularnormal)), FLT_MIN)), SpecularPower * glosstex.a));\n"
"# endif\n"
" color.rgb = diffusetex * Color_Ambient + (diffusetex * Color_Diffuse * diffuse + glosstex.rgb * Color_Specular * specular) * lightcolor;\n"
"# else\n"