LYGIA Shader Library

aspect (lygia/space/aspect)

Fix the aspect ratio of a space keeping things squared for you.

Use:

<vec2> aspect(<vec2> st, <vec2> st_size)

Check it on Github


#ifndef FNC_ASPECT
#define FNC_ASPECT
vec2 aspect(vec2 st, vec2 s) {
    st.x = st.x * (s.x / s.y);
    return st;
}
#endif

Use:

<float2> aspect(<float2> st, <float2> st_size)

Check it on Github


#ifndef FNC_ASPECT
#define FNC_ASPECT

float2 aspect(float2 st, float2 s) {
    st.x = st.x * (s.x / s.y);
    return st;
}

#endif

Use:

<float2> aspect(<float2> st, <float2> st_size)

Check it on Github


#ifndef FNC_ASPECT
#define FNC_ASPECT
float2 aspect(float2 st, float2 s) {
    st.x = st.x * (s.x / s.y);
    return st;
}
#endif

Examples

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