// currently selected permutation
r_glsl_permutation_t *r_glsl_permutation;
-// temporary variable used by a macro
-int fogtableindex;
-
// vertex coordinates for a quad that covers the screen exactly
const static float r_screenvertex3f[12] =
{
"uniform myhalf SpecularScale;\n"
"uniform myhalf SpecularPower;\n"
"\n"
+"#ifdef USEOFFSETMAPPING\n"
"vec2 OffsetMapping(vec2 TexCoord)\n"
"{\n"
-" vec3 eyedir = vec3(normalize(EyeVector));\n"
-" float depthbias = 1.0 - eyedir.z; // should this be a -?\n"
-" depthbias = 1.0 - depthbias * depthbias;\n"
-"\n"
"#ifdef USEOFFSETMAPPING_RELIEFMAPPING\n"
" // 14 sample relief mapping: linear search and then binary search\n"
-" //vec3 OffsetVector = vec3(EyeVector.xy * (1.0 / EyeVector.z) * depthbias * OffsetMapping_Scale * vec2(-0.1, 0.1), -0.1);\n"
-" //vec3 OffsetVector = vec3(normalize(EyeVector.xy) * OffsetMapping_Scale * vec2(-0.1, 0.1), -0.1);\n"
-" vec3 OffsetVector = vec3(eyedir.xy * OffsetMapping_Scale * vec2(-0.1, 0.1), -0.1);\n"
-" vec3 RT = vec3(TexCoord - OffsetVector.xy * 10.0, 1.0) + OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;OffsetVector *= 0.5;RT -= OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;OffsetVector *= 0.5;RT -= OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;OffsetVector *= 0.5;RT -= OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;OffsetVector *= 0.5;RT -= OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;OffsetVector *= 0.5;RT -= OffsetVector;\n"
-" if (RT.z > texture2D(Texture_Normal, RT.xy).a) RT += OffsetVector;OffsetVector *= 0.5;RT -= OffsetVector;\n"
-" TexCoord = RT.xy;\n"
+" // this basically steps forward a small amount repeatedly until it finds\n"
+" // itself inside solid, then jitters forward and back using decreasing\n"
+" // amounts to find the impact\n"
+" //vec3 OffsetVector = vec3(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_Scale) * vec2(-1, 1), -1);\n"
+" //vec3 OffsetVector = vec3(normalize(EyeVector.xy) * OffsetMapping_Scale * vec2(-1, 1), -1);\n"
+" vec3 OffsetVector = vec3(normalize(EyeVector).xy * OffsetMapping_Scale * vec2(-1, 1), -1);\n"
+" vec3 RT = vec3(TexCoord, 1);\n"
+" OffsetVector *= 0.1;\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"
+" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) - 0.5);\n"
+" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.5 - 0.25);\n"
+" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.25 - 0.125);\n"
+" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.125 - 0.0625);\n"
+" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.0625 - 0.03125);\n"
+" return RT.xy;\n"
"#else\n"
" // 3 sample offset mapping (only 3 samples because of ATI Radeon 9500-9800/X300 limits)\n"
-" //vec2 OffsetVector = vec2(EyeVector.xy * (1.0 / EyeVector.z) * depthbias) * OffsetMapping_Scale * vec2(-0.333, 0.333);\n"
-" //vec2 OffsetVector = vec2(normalize(EyeVector.xy)) * OffsetMapping_Scale * vec2(-0.333, 0.333);\n"
-" vec2 OffsetVector = vec2(eyedir.xy) * OffsetMapping_Scale * vec2(-0.333, 0.333);\n"
-" //TexCoord += OffsetVector * 3.0;\n"
+" // this basically moves forward the full distance, and then backs up based\n"
+" // on height of samples\n"
+" //vec2 OffsetVector = vec2(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_Scale) * vec2(-1, 1));\n"
+" //vec2 OffsetVector = vec2(normalize(EyeVector.xy) * OffsetMapping_Scale * vec2(-1, 1));\n"
+" vec2 OffsetVector = vec2(normalize(EyeVector).xy * OffsetMapping_Scale * vec2(-1, 1));\n"
+" TexCoord += OffsetVector;\n"
+" OffsetVector *= 0.333;\n"
" TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;\n"
" TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;\n"
" TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;\n"
-"#endif\n"
" return TexCoord;\n"
+"#endif\n"
"}\n"
+"#endif\n"
"\n"
"void main(void)\n"
"{\n"
-" // apply offsetmapping\n"
"#ifdef USEOFFSETMAPPING\n"
+" // apply offsetmapping\n"
" vec2 TexCoordOffset = OffsetMapping(TexCoord);\n"
"#define TexCoord TexCoordOffset\n"
"#endif\n"
" myhvec3 diffusenormal = myhvec3(normalize(LightVector));\n"
"\n"
" // calculate directional shading\n"
-" color.rgb = LightColor * myhalf(texture2D(Texture_Attenuation, vec2(length(CubeVector), 0.0))) * color.rgb * (AmbientScale + DiffuseScale * myhalf(max(float(dot(surfacenormal, diffusenormal)), 0.0)));\n"
+" color.rgb = color.rgb * LightColor * (myhalf(texture2D(Texture_Attenuation, vec2(length(CubeVector), 0.0))) * (AmbientScale + DiffuseScale * myhalf(max(float(dot(surfacenormal, diffusenormal)), 0.0))));\n"
"#else\n"
" // calculate directionless shading\n"
" color.rgb = color.rgb * LightColor * myhalf(texture2D(Texture_Attenuation, vec2(length(CubeVector), 0.0)));\n"
"\n"
"#ifdef USEFOG\n"
" // apply fog\n"
-" myhalf fog = myhalf(texture2D(Texture_FogMask, myhvec2(length(EyeVectorModelSpace)*FogRangeRecip, 0.0)).x);\n"
-" color.rgb = color.rgb * fog + FogColor * (1.0 - fog);\n"
+" color.rgb = mix(FogColor, color.rgb, myhalf(texture2D(Texture_FogMask, myhvec2(length(EyeVectorModelSpace)*FogRangeRecip, 0.0))));\n"
"#endif\n"
"\n"
" color.rgb *= SceneBrightness;\n"