LYGIA Shader Library

eulerView (lygia/space/eulerView)

Create a view matrix from camera position and camera rotation (euler angles)

Dependencies:

Use:

<mat4> eulerView(in <vec3> position, in <vec3> euler)

Check it on Github



#ifndef FNC_EULERVIEW
#define FNC_EULERVIEW

 mat4 eulerView(vec3 position, vec3 euler) {
    mat3 rotZ = rotate3dZ(euler.z);
    mat3 rotX = rotate3dX(euler.x);
    mat3 rotY = rotate3dY(euler.y);
    mat3 identity = mat3(1.0);
    mat3 rotation = rotY * rotX * rotZ * identity;
    return translate(rotation, position);
}

#endif

Dependencies:

Use:

<float4x4> eulerView(in <float3> position, in <float3> euler)

Check it on Github



#ifndef FNC_EULERVIEW
#define FNC_EULERVIEW

 float4x4 eulerView(float3 position, float3 euler) {
    float3x3 rotZ = rotate3dZ(euler.z);
    float3x3 rotX = rotate3dX(euler.x);
    float3x3 rotY = rotate3dY(euler.y);
    float3x3 identity = float3x3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
    float3x3 rotation = mul(rotY, mul(rotX, mul(rotZ, identity)));
    return translate(rotation, position);
}

#endif

License

MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj

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