Is GLSL sampler2DShadow deprecated with past version 120? What to use?

I am trying to implement filtering with a closer filter for my shadow display, as described here by the Nvidia GPU Gems

When I try to fetch my shadow map using a single sampler2Shadow and shadow2D or shadow2DProj file, GLSL compilation fails and gives me an error

shadow2D deprecated after version 120 

How can I implement an equivalent solution in GLSL 330+? Right now I'm just using a binary texture sample along with a Poisson fetch, but aliasing the stairs is pretty bad.

+4
opengl glsl
source share
2 answers

Your name is out of base. sampler2DShadow not supported not . The only thing that changed in GLSL 1.30 was that the clutter of functions like texture1D , texture2D , textureCube , shadow2D , etc., was replaced by texture (...) overloads.


Note that this texture (...) overload is equivalent to shadow2D (...) :

 float texture(sampler2DShadow sampler, vec3 P, [float bias]); 

The coordinates of the texture used to search using this overload are: P.st and the reference value used to compare the depth Pr . This overload only works when texture comparison is enabled ( GL_TEXTURE_COMPARE_MODE == GL_COMPARE_REF_TO_TEXTURE​ for a texture / sampler object tied to a shadow sampler texture image block; otherwise the results are undefined.


Starting with GLSL 1.30, the only time you need to use another texture search function, you do something fundamentally different (for example, texture projection => textureProj , asking for the exact LOD => textureLod , texel selection by its integer coordinates / pattern index = > texelFetch , etc.). A texture search with comparison (shadow sampler) is not considered fundamentally different to require its own specialized texture search function.

All this is described in detail on the OpenGL Viking website .

+14
source share

You need to use textureProj , which returns a float , not vec4 . Here is an overview of shadow artifacts and solutions (including a Poisson sample) here .

+1
source share

All Articles