" //\n"
" // pow(1-(x*x+y*y+z*z), 4) is far more realistic but needs large lights to\n"
" // provide significant illumination, large = slow = pain.\n"
-" float colorscale = clamp(1.0 - dot(CubeVector, CubeVector), 0.0, 1.0);\n"
+" float colorscale = max(1.0 - dot(CubeVector, CubeVector), 0.0);\n"
"\n"
"#ifdef USEFOG\n"
" // apply fog\n"
"#endif\n"
"\n"
"#ifdef USEOFFSETMAPPING\n"
-" vec2 OffsetVector = normalize(EyeVector).xy * vec2(-1, 1);\n"
+" // this is 3 sample because of ATI Radeon 9500-9800/X300 limits\n"
+" vec2 OffsetVector = normalize(EyeVector).xy * vec2(-0.333, 0.333);\n"
" vec2 TexCoordOffset = TexCoord + OffsetVector * (OffsetMapping_Bias + OffsetMapping_Scale * texture2D(Texture_Normal, TexCoord).w);\n"
" TexCoordOffset += OffsetVector * (OffsetMapping_Bias + OffsetMapping_Scale * texture2D(Texture_Normal, TexCoordOffset).w);\n"
" TexCoordOffset += OffsetVector * (OffsetMapping_Bias + OffsetMapping_Scale * texture2D(Texture_Normal, TexCoordOffset).w);\n"
-" TexCoordOffset += OffsetVector * (OffsetMapping_Bias + OffsetMapping_Scale * texture2D(Texture_Normal, TexCoordOffset).w);\n"
"#define TexCoord TexCoordOffset\n"
"#endif\n"
"\n"
"\n"
" // calculate shading\n"
" vec3 diffusenormal = normalize(LightVector);\n"
-" vec3 color = colortexel * (AmbientScale + DiffuseScale * clamp(dot(surfacenormal, diffusenormal), 0.0, 1.0));\n"
+" vec3 color = colortexel * (AmbientScale + DiffuseScale * max(dot(surfacenormal, diffusenormal), 0.0));\n"
"#ifdef USESPECULAR\n"
-" color += glosstexel * (SpecularScale * pow(clamp(dot(surfacenormal, normalize(diffusenormal + normalize(EyeVector))), 0.0, 1.0), SpecularPower));\n"
+" color += glosstexel * (SpecularScale * pow(max(dot(surfacenormal, normalize(diffusenormal + normalize(EyeVector))), 0.0), SpecularPower));\n"
"#endif\n"
"\n"
"#ifdef USECUBEFILTER\n"
r_shadow_program_light[i] = GL_Backend_CompileProgram(vertstrings_count, vertstrings_list, fragstrings_count, fragstrings_list);
if (!r_shadow_program_light[i])
{
- Con_Printf("permutation %s %s %s %s failed for shader %s, some features may not work properly!\n", i & 1 ? "specular" : "", i & 1 ? "fog" : "", i & 1 ? "cubefilter" : "", i & 1 ? "offsetmapping" : "", "glsl/light");
+ Con_Printf("permutation %s %s %s %s failed for shader %s, some features may not work properly!\n", i & 1 ? "specular" : "", i & 2 ? "fog" : "", i & 4 ? "cubefilter" : "", i & 8 ? "offsetmapping" : "", "glsl/light");
continue;
}
qglUseProgramObjectARB(r_shadow_program_light[i]);
}
if (perm & SHADERPERMUTATION_OFFSETMAPPING)
{
- // these are * 0.25 because the offsetmapping shader does the process 4 times
- qglUniform1fARB(qglGetUniformLocationARB(prog, "OffsetMapping_Scale"), r_shadow_glsl_offsetmapping_scale.value * 0.25);CHECKGLERROR
- qglUniform1fARB(qglGetUniformLocationARB(prog, "OffsetMapping_Bias"), r_shadow_glsl_offsetmapping_bias.value * 0.25);CHECKGLERROR
+ qglUniform1fARB(qglGetUniformLocationARB(prog, "OffsetMapping_Scale"), r_shadow_glsl_offsetmapping_scale.value);CHECKGLERROR
+ qglUniform1fARB(qglGetUniformLocationARB(prog, "OffsetMapping_Bias"), r_shadow_glsl_offsetmapping_bias.value);CHECKGLERROR
}
CHECKGLERROR
GL_LockArrays(0, numverts);
for (i = 0;i < 6;i++)
{
// generate an image name based on the base and and suffix
- snprintf(name, sizeof(name), "%s%s", basename, suffix[j][i].suffix);
+ dpsnprintf(name, sizeof(name), "%s%s", basename, suffix[j][i].suffix);
// load it
if ((image_rgba = loadimagepixels(name, false, cubemapsize, cubemapsize)))
{
light->corona = corona;
if (!cubemapname)
cubemapname = "";
- strlcpy(light->cubemapname, cubemapname, strlen(light->cubemapname));
+ strlcpy(light->cubemapname, cubemapname, sizeof(light->cubemapname));
light->coronasizescale = coronasizescale;
light->ambientscale = ambientscale;
light->diffusescale = diffusescale;