PCF filtering on OpenGL

1.1k Views Asked by At

I'm reading the docs for ARB_shadow and they hint that OpenGL is free to implement PCF (Percentage Closer Filtering) in the texture samplers but they can't talk about it in the spec.

First they say:

  • How is bilinear or trilinear filtering implemented?

RESOLUTION: We suggest an implementation behaviour but leave the details up to the implementation. Differences here amount to the quality and softness of shadow edges. Specific filtering algorithms could be expressed via layered extensions. We're intentionally vague here to avoid IP and patent issues.

Then later on:

If TEXTURE_MAG_FILTER is not NEAREST or TEXTURE_MIN_FILTER is not NEAREST or NEAREST_MIPMAP_NEAREST then r may be computed by comparing more than one depth texture value to the texture R coordinate. The details of this are implementation-dependent but r should be a value in the range [0, 1] which is proportional to the number of comparison passes or failures.

And ... that's PCF!

Questions

The first question is: Does it work? How many vendors really do PCF when you sample a depth texture with a LINEAR filter?

The second (and most important) question is: How would you detect if hardware PCF filtering via ARB_shadow will work? I want to fall back to a software PCF in the shader if it's not present.

Notes

  • I noticed that ARB_shadow goes hand-in-hand with ARB_fragment_program_shadow (at least on the graphics cards I have access to). ARB_fragment_program_shadow is the low level hardware support for PCF in shaders. Is that a clue to the answer, ie. if both extensions are present then hardware PCF will appear when I say the magic words?

  • Implementing ARB_shadow with a simple binary result would be silly. I'd assume the whole point of implementing ARB_shadow in a driver would be to do PCF, even if the docs aren't allowed to say so. Does the mere presence of ARB_shadow imply hardware PCF?

0

There are 0 best solutions below