- enabled the linear shadowmap filter.

Although this doesn't look as good as the PCF version it is a lot less calculation intensive and therefore more suitable for weaker hardware.
It also tends to bleed through walls a lot less.
This commit is contained in:
Christoph Oelckers 2018-09-29 13:23:40 +02:00
parent 86c7e87767
commit c8852b8fea
6 changed files with 26 additions and 18 deletions

View file

@ -68,6 +68,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
int uViewHeight; // Software fuzz scaling
float uClipHeight;
float uClipHeightDirection;
int uShadowmapFilter;
};
)";

View file

@ -280,5 +280,6 @@ void HWViewpointUniforms::SetDefaults()
mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f;
mPalLightLevels = static_cast<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8);
mClipLine.X = -10000000.0f;
mShadowmapFilter = gl_shadowmap_filter;
}

View file

@ -16,6 +16,7 @@ struct HWViewpointUniforms
int mViewHeight = 0;
float mClipHeight = 0.f;
float mClipHeightDirection = 0.f;
int mShadowmapFilter = 1;
void CalcDependencies()
{

View file

@ -132,3 +132,5 @@ CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE)
{
if (self < 0 || self > 8) self = 0;
}
CVAR(Bool, gl_shadowmap_filter, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)

View file

@ -69,3 +69,5 @@ EXTERN_CVAR(Bool, gl_billboard_faces_camera)
EXTERN_CVAR(Bool, gl_billboard_particles)
EXTERN_CVAR(Int, gl_enhanced_nv_stealth)
EXTERN_CVAR(Int, gl_fuzztype)
EXTERN_CVAR(Bool, gl_shadowmap_filter)

View file

@ -218,9 +218,6 @@ float sampleShadowmapLinear(vec2 dir, float v)
#define PCF_FILTER_STEP_COUNT 3
#define PCF_COUNT (PCF_FILTER_STEP_COUNT * 2 + 1)
// #define USE_LINEAR_SHADOW_FILTER
#define USE_PCF_SHADOW_FILTER 1
float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
{
if (shadowIndex >= 1024.0)
@ -235,10 +232,13 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
vec2 dir = ray / length;
#if defined(USE_LINEAR_SHADOW_FILTER)
ray -= dir * 6.0; // Shadow acne margin
if (uShadowmapFilter == 0)
{
ray -= dir * 2.0; // Shadow acne margin
return sampleShadowmapLinear(ray, v);
#elif defined(USE_PCF_SHADOW_FILTER)
}
else
{
ray -= dir * 2.0; // Shadow acne margin
dir = dir * min(length / 50.0, 1.0); // avoid sampling behind light
@ -251,7 +251,8 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
sum += sampleShadowmap(ray + normal * x - bias * abs(x), v);
}
return sum / PCF_COUNT;
#else // nearest shadow filter
}
#if 0 // nearest shadow filter (not used)
ray -= dir * 6.0; // Shadow acne margin
return sampleShadowmap(ray, v);
#endif