LYGIA Shader Library

scale4d (lygia/v1.1.6/math/scale4d)

returns a 4x4 scale matrix

Use:

scale4d(<float|vec3|vec4> radians)
scale4d(<float> x, <float> y, <float> z [, <float> w])

Check it on Github


#ifndef FNC_SCALE4D
mat4 scale4d(float s) {
    return mat4(
        s, 0.0, 0.0, 0.0,
        0.0, s, 0.0, 0.0,
        0.0, 0.0, s, 0.0,
        0.0, 0.0, 0.0, 1.0
    );
}

mat4 scale4d(float x, float y, float z) {
    return mat4(
         x, 0.0, 0.0, 0.0,
        0.0,  y, 0.0, 0.0,
        0.0, 0.0,  z, 0.0,
        0.0, 0.0, 0.0, 1.0
    );
}

mat4 scale4d(float x, float y, float z, float w) {
    return mat4(
         x, 0.0, 0.0, 0.0,
        0.0,  y, 0.0, 0.0,
        0.0, 0.0,  z, 0.0,
        0.0, 0.0, 0.0,  w
    );
}

mat4 scale4d(vec3 s) {
    return mat4(
        s.x, 0.0, 0.0, 0.0,
        0.0, s.y, 0.0, 0.0,
        0.0, 0.0, s.z, 0.0,
        0.0, 0.0, 0.0, 1.0
    );
}

mat4 scale4d(vec4 s) {
    return mat4(
        s.x, 0.0, 0.0, 0.0,
        0.0, s.y, 0.0, 0.0,
        0.0, 0.0, s.z, 0.0,
        0.0, 0.0, 0.0, s.w
    );
}
#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