LYGIA Shader Library

sampler (lygia/sampler)

It defines the default sampler type and function for the shader based on the version of GLSL.

Check it on Github

#ifndef SAMPLER_FNC
#if __VERSION__ >= 300
#define SAMPLER_FNC(TEX, UV) texture(TEX, UV)
#else
#define SAMPLER_FNC(TEX, UV) texture2D(TEX, UV)
#endif
#endif

#ifndef SAMPLER_TYPE
#define SAMPLER_TYPE sampler2D
#endif

Check it on Github


#if defined(__SHADER_TARGET_MAJOR) && __SHADER_TARGET_MAJOR < 4

    #ifndef SAMPLER_FNC
    #define SAMPLER_FNC(TEX, UV) tex2D(TEX, UV)
    #endif

    #ifndef SAMPLER_TYPE
    #define SAMPLER_TYPE sampler2D
    #endif

#else

    // https://docs.unity3d.com/Manual/SL-SamplerStates.html
    #ifndef DEFAULT_SAMPLER_STATE
    #define DEFAULT_SAMPLER_STATE defaultLinearClampSampler
    SamplerState DEFAULT_SAMPLER_STATE
    {
        Filter = MIN_MAG_MIP_LINEAR;
        AddressU = Clamp;
        AddressV = Clamp;
    };
    #endif

    #ifndef SAMPLER_FNC
    #define SAMPLER_FNC(TEX, UV) TEX.Sample(DEFAULT_SAMPLER_STATE, UV)
    #endif

    #ifndef SAMPLER_TYPE
    #define SAMPLER_TYPE Texture2D
    #endif

#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