mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +00:00
- some tweaking of shadowmap filter setting to allow changing the PCF filter's number of samplings.
# Conflicts: # src/gl/system/gl_cvars.h # src/gl/system/gl_menu.cpp
This commit is contained in:
parent
62c11cd1a5
commit
24d09fe56a
2 changed files with 10 additions and 8 deletions
|
@ -45,7 +45,10 @@ FRenderState gl_RenderState;
|
|||
|
||||
CVAR(Bool, gl_direct_state_change, true, 0)
|
||||
CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
static VSMatrix identityMatrix(1);
|
||||
|
|
|
@ -194,9 +194,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)
|
||||
|
@ -211,7 +208,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);
|
||||
|
@ -225,11 +222,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