I’m trying to get free PCF working on my shadows, something that I have heard and read about, but I can’t find any solid info on the specifics.
It seems that most solid info on it is hidden behind broken links (or I REALLY suck at googling)
I’m writing the shaders in CG, not directly in HLSL
First what I’ve read so far:
Some forum(post)s state that simply changing filtering of the depth texture is enough, this doesn’t seem to be true
I have read that the texture format should be DEPTH_STENCIL, some others have stated that it should be DEPTH_COMPONENT or some Nvidia specific format
Combined with above, i could not get any results, and I couldn’t find any reference to a Nvidia specific format.
Some have said Texture2D should be used, some others have said Shadow2D should be used.
Some say a different kind of sampler-type should be used (can’t remember the name by heart atm)
I couldn’t get any code to compile by using above keywords in my shaders, I probably need their CG-coutnerparts, if they exist.
I’m also unclear of how the extra “compare value” should be passed to the sampling instruction (texture2D/shadow2D). Should it be the extra third component of the sampling coord?
I have almost nog OpenGL background, but I do have worked some years with DirectX. On some hardware, Using Tex2D() with a third component (and corret sampler settings) was enough to trigger PCF under DX.
I have tried to use the ARB_Shadow Texure comparison state, (COMPARE_TEXTURE_TO_R) but I couldn’t really get it to work correctly.
I couldn’t make heads or tails of the ARB_Shadow OpenGL Spec for explenation of how the comparison works
(it seems to be doing compare between the (2D?3D?) V coord and the scalar (?) depth value, but I don’t see how that would work)
It seems that the COMPARE_TEXTURE_TO_R stuff seems to be ARB_shadow specific, while Shadow2D is part of a later OpenGL spec?
Are some extra extensions needed?
Hmm, haven’t done this with CG, but given that others correctly pointed out that with GLSL you need a sampler2DShadow (and possibly the correct texture access function), have you tried CG’s tex2Dcmpbias?
Can’t get it to work, It seems that the CG compiler isn’t outputting the correct GLSL to get the compare-feature activated properly.
I’ll take a closer look later on when I have the tools and the time to go through the GLSL output.