mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- some tweaking of shadowmap filter setting to allow changing the PCF filter's number of samplings.
This commit is contained in:
parent
35bb2d3079
commit
797f88a6c8
3 changed files with 10 additions and 9 deletions
|
@ -133,4 +133,6 @@ 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)
|
||||
CUSTOM_CVAR(Int, gl_shadowmap_filter, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self > 8) self = 1;
|
|
@ -70,4 +70,4 @@ EXTERN_CVAR(Bool, gl_billboard_particles)
|
|||
EXTERN_CVAR(Int, gl_enhanced_nv_stealth)
|
||||
EXTERN_CVAR(Int, gl_fuzztype)
|
||||
|
||||
EXTERN_CVAR(Bool, gl_shadowmap_filter)
|
||||
EXTERN_CVAR(Int, gl_shadowmap_filter)
|
|
@ -215,9 +215,6 @@ float sampleShadowmapLinear(vec2 dir, float v)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
#define PCF_FILTER_STEP_COUNT 3
|
||||
#define PCF_COUNT (PCF_FILTER_STEP_COUNT * 2 + 1)
|
||||
|
||||
float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
|
||||
{
|
||||
if (shadowIndex >= 1024.0)
|
||||
|
@ -232,7 +229,7 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
|
|||
|
||||
vec2 dir = ray / length;
|
||||
|
||||
if (uShadowmapFilter == 0)
|
||||
if (uShadowmapFilter <= 0)
|
||||
{
|
||||
ray -= dir * 2.0; // Shadow acne margin
|
||||
return sampleShadowmapLinear(ray, v);
|
||||
|
@ -246,11 +243,13 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
|
|||
vec2 bias = dir * 10.0;
|
||||
|
||||
float sum = 0.0;
|
||||
for (float x = -PCF_FILTER_STEP_COUNT; x <= PCF_FILTER_STEP_COUNT; x++)
|
||||
float step_count = ((uShadowmapFilter - 1) / 2.);
|
||||
|
||||
for (float x = -step_count; x <= step_count; x++)
|
||||
{
|
||||
sum += sampleShadowmap(ray + normal * x - bias * abs(x), v);
|
||||
sum += sampleShadowmap(ray + normal * x /*- bias * abs(x)*/, v);
|
||||
}
|
||||
return sum / PCF_COUNT;
|
||||
return sum / uShadowmapFilter;
|
||||
}
|
||||
#if 0 // nearest shadow filter (not used)
|
||||
ray -= dir * 6.0; // Shadow acne margin
|
||||
|
|
Loading…
Reference in a new issue