So I just stumbled across by it by chance while researching how shadow maps work.
There are a few occurrences, where PCF5 is handled differently to PCF3 and PCF1 is this by design?
Shoudn’t it be the same as only the sample radius increases?
Different handling:
height: size,
mipmaps: false,
minFilter: filter,
magFilter: filter,
addressU: ADDRESS_CLAMP_TO_EDGE,
addressV: ADDRESS_CLAMP_TO_EDGE,
name: 'ShadowMap2D'
});
let target = null;
if (shadowType === SHADOW_PCF5 || ((shadowType === SHADOW_PCF1 || shadowType === SHADOW_PCF3) && device.supportsDepthShadow)) {
// enable hardware PCF when sampling the depth texture
texture.compareOnRead = true;
texture.compareFunc = FUNC_LESS;
// depthbuffer only
target = new RenderTarget({
depthBuffer: texture
});
} else {
Different handling:
targets[i].destroy();
}
this.renderTargets.length = 0;
}
static getShadowFormat(device, shadowType) {
if (shadowType === SHADOW_VSM32) {
return PIXELFORMAT_RGBA32F;
} else if (shadowType === SHADOW_VSM16) {
return PIXELFORMAT_RGBA16F;
} else if (shadowType === SHADOW_PCF5) {
return PIXELFORMAT_DEPTH;
} else if ((shadowType === SHADOW_PCF1 || shadowType === SHADOW_PCF3) && device.supportsDepthShadow) {
return PIXELFORMAT_DEPTH;
} else if ((shadowType === SHADOW_PCSS) && !device.isWebGL1) {
return PIXELFORMAT_R32F;
}
return PIXELFORMAT_RGBA8;
}
Not present at all (defaulting to FILTER_LINEAR):
return PIXELFORMAT_DEPTH;
} else if ((shadowType === SHADOW_PCF1 || shadowType === SHADOW_PCF3) && device.supportsDepthShadow) {
return PIXELFORMAT_DEPTH;
} else if ((shadowType === SHADOW_PCSS) && !device.isWebGL1) {
return PIXELFORMAT_R32F;
}
return PIXELFORMAT_RGBA8;
}
static getShadowFiltering(device, shadowType) {
if ((shadowType === SHADOW_PCF1 || shadowType === SHADOW_PCF3 || shadowType === SHADOW_PCSS) && !device.supportsDepthShadow) {
return FILTER_NEAREST;
} else if (shadowType === SHADOW_VSM32) {
return device.extTextureFloatLinear ? FILTER_LINEAR : FILTER_NEAREST;
} else if (shadowType === SHADOW_VSM16) {
return device.extTextureHalfFloatLinear ? FILTER_LINEAR : FILTER_NEAREST;
}
return FILTER_LINEAR;
}
One difference under the hood is is that SHADOW_PCF5 is not supported on WebGL1, and we fall back to PCF3.
Also, all of them on WebGL1 use RGBA8 encoded depth, as depth buffer sampling is not available.
And there are further differences like that I’m sure.
1 Like