LYGIA Shader Library

zero (lygia/v1.1.6/sample/zero)

turns alpha to zero if it's outside the texture normalize coordinates

Dependencies:

Use:

<vec4> sampleZero(<SAMPLER_TYPE> tex, <vec2> st);

Check it on Github



#ifndef FNC_SAMPLEZERO
#define FNC_SAMPLEZERO
vec4 sampleZero(SAMPLER_TYPE tex, vec2 st) { 
    return SAMPLER_FNC( tex, st ) * vec4(1.0,1.0,1.0, (st.x <= 0.0 || st.x >= 1.0 || st.y <= 0.0 || st.y >= 1.0)? 0.0 : 1.0); 
}

vec4 sampleZero(SAMPLER_TYPE tex, vec2 st, float pad) { 
    return SAMPLER_FNC( tex, st ) * vec4(1.0,1.0,1.0, (st.x <= pad || st.x >= 1.0-pad || st.y <= pad || st.y >= 1.0 - pad)? 0.0 : 1.0); 
}

vec4 sampleZero(SAMPLER_TYPE tex, vec2 st, vec2 pad) { 
    return SAMPLER_FNC( tex, st ) * vec4(1.0,1.0,1.0, (st.x <= pad.x || st.x >= 1.0-pad.x || st.y <= pad.y || st.y >= 1.0 - pad.y)? 0.0 : 1.0); 
}

vec4 sampleZero(SAMPLER_TYPE tex, vec2 st, vec4 pad) { 
    return SAMPLER_FNC( tex, st ) * vec4(1.0,1.0,1.0, (st.x <= pad.x || st.x >= pad.z || st.y <= pad.y || st.y >= pad.w)? 0.0 : 1.0); 
}

#ifdef STR_AABB
vec4 sampleZero(SAMPLER_TYPE tex, vec2 st, AABB pad) { 
    return SAMPLER_FNC( tex, st ) * vec4(1.0,1.0,1.0, (st.x <= pad.min.x || st.x >= pad.max.x || st.y <= pad.min.y || st.y >= pad.max.y)? 0.0 : 1.0); 
}
#endif

#endif

Dependencies:

Use:

<float4> sampleZero(<SAMPLER_TYPE> tex, <float2> st);

Check it on Github



#ifndef FNC_SAMPLEZERO
#define FNC_SAMPLEZERO
float4 sampleZero(SAMPLER_TYPE tex, float2 st) { 
    return SAMPLER_FNC( tex, st ) * float4(1.0,1.0,1.0, (st.x <= 0.0 || st.x >= 1.0 || st.y <= 0.0 || st.y >= 1.0)? 0.0 : 1.0); 
}
#endif

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