LYGIA Shader Library

shadow (lygia/lighting/shadow)

Sample shadow map using PCF

Dependencies:

Use:

<float> sampleShadowPCF(<SAMPLER_TYPE> depths, <vec2> size, <vec2> uv, <float> compare)
<float> sampleShadowPCF(<vec3> lightcoord)

Check it on Github



#ifndef SHADOWMAP_BIAS
#define SHADOWMAP_BIAS 0.005
#endif

#ifndef SHADOW_SAMPLER_FNC
#define SHADOW_SAMPLER_FNC sampleShadowPCF
#endif

#ifndef FNC_SHADOW
#define FNC_SHADOW

float shadow(SAMPLER_TYPE shadoMap, const in vec2 size, const in vec2 uv, float compare) {
    #ifdef SHADOWMAP_BIAS
    compare -= SHADOWMAP_BIAS;
    #endif

    #if defined(PLATFORM_RPI) 
    return sampleShadow(shadoMap, size, uv, compare);
    #elif defined(TARGET_MOBILE)
    return sampleShadowLerp(shadoMap, size, uv, compare);
    #else 
    return sampleShadowPCF(shadoMap, size, uv, compare);
    #endif
}

#endif 

Dependencies:

Use:

<float> sampleShadowPCF(<SAMPLER_TYPE> depths, <float2> size, <float2> uv, <float> compare)
<float> sampleShadowPCF(<float3> lightcoord)

Check it on Github



#ifndef SHADOWMAP_BIAS
#define SHADOWMAP_BIAS 0.005
#endif

#ifndef SHADOW_SAMPLER_FNC
#define SHADOW_SAMPLER_FNC sampleShadowPCF
#endif

#ifndef FNC_SHADOW
#define FNC_SHADOW

float shadow(SAMPLER_TYPE shadoMap, float2 size, float2 uv, float compare) {
    #ifdef SHADOWMAP_BIAS
    compare -= SHADOWMAP_BIAS;
    #endif
    return sampleShadowPCF(shadoMap, size, uv, compare);
}

#endif 

Licenses

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository