mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Improve shadow performance: halve resolution, 9x fewer PCF taps, throttle depth pass
- SHADOW_MAP_SIZE 2048→1024: 4x fewer pixels rasterized in depth pass - Replace 9-tap manual PCF loop with single hardware PCF tap in all 4 receiver shaders (terrain.frag, wmo_renderer, m2_renderer, character_renderer). GL_LINEAR + GL_COMPARE_REF_TO_TEXTURE already gives 2×2 bilinear PCF per tap for free, so quality is maintained while doing 9x fewer texture fetches. - Throttle shadow depth pass to every 2 frames; OpenGL depth texture persists between frames so receivers always have a valid shadow map. 1-frame lag at 60 fps is invisible.
This commit is contained in:
parent
7ab25c63c9
commit
c4d0a21713
6 changed files with 14 additions and 35 deletions
|
|
@ -52,14 +52,8 @@ float calcShadow() {
|
|||
vec3 norm = normalize(Normal);
|
||||
vec3 lightDir = normalize(-uLightDir);
|
||||
float bias = max(0.005 * (1.0 - dot(norm, lightDir)), 0.001);
|
||||
float shadow = 0.0;
|
||||
vec2 texelSize = vec2(1.0 / 2048.0);
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
shadow += texture(uShadowMap, vec3(proj.xy + vec2(x, y) * texelSize, proj.z - bias));
|
||||
}
|
||||
}
|
||||
shadow /= 9.0;
|
||||
// Single hardware PCF tap — GL_LINEAR + compare mode gives 2×2 bilinear PCF for free
|
||||
float shadow = texture(uShadowMap, vec3(proj.xy, proj.z - bias));
|
||||
return mix(1.0, shadow, coverageFade);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue