GL_EXT_shadow_samplers#

Supported Hardware#

Series6, Series6XE, Series6XT

Valid APIs#

OpenGL ES 2.0

Description#

This extension adds shadow samplers to OpenGL ES 2, which are a type of sampler that has predicated comparisons built-in when texels are sampled. The typical use case for this is to sample a shadow map and determine whether the current pixel is in shadow or not.

Note

This functionality is core to OpenGL ES 3.0, so the extension is no longer needed.

Example#

// Set the texture to perform comparison
glBindTexture(GL_TEXTURE_2D, texture)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_EXT, GL_COMPARE_REF_TO_TEXTURE_EXT);
// Set the texture's comparison predicate function to "Greater Than"
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_EXT, GL_GREATER);
[Example]
#extension GL_EXT_shadow_samplers : require
uniform sampler2Dshadow myShadowMap;
varying vec2 textureCoords;
void main()
{
    ...
    // Sample the shadow texture.
    // The value returned will be either 1.0 or 0.0 with nearest filtering, or a value in that range for linear filtering.
    float shadowAmount = shadow2DEXT(myShadowMap, vec3(textureCoords, referenceValue));
    ...
}