LYGIA Shader Library

lookAtView (lygia/space/lookAtView)

Create a look-at view matrix

Dependencies:

Use:

<mat4> lookAtView(in <vec3> position, in <vec3> target, in <vec3> up)

Check it on Github



#ifndef FNC_LOOKATVIEW
#define FNC_LOOKATVIEW

mat4 lookAtView( in vec3 position, in vec3 target, in vec3 up ) {
    mat3 m = lookAt(position, target, up);
    return translate(m, position);
}

mat4 lookAtView( in vec3 position, in vec3 target, in float roll ) {
    mat3 m = lookAt(position, target, roll);
    return translate(m, position);
}

mat4 lookAtView( in vec3 position, in vec3 lookAt ) {
    return lookAtView(position, lookAt, vec3(0.0, 1.0, 0.0));
}

#endif

Dependencies:

Use:

<float4x4> lookAtView(in <float3> position, in <float3> target, in <float3> up)

Check it on Github



#ifndef FNC_LOOKATVIEW
#define FNC_LOOKATVIEW

float4x4 lookAtView( in float3 position, in float3 target, in float3 up ) {
    float3x3 m = lookAt(position, target, up);
    return translate(m, position);
}

float4x4 lookAtView( in float3 position, in float3 target, in float roll ) {
    float3x3 m = lookAt(position, target, roll);
    return translate(m, position);
}

float4x4 lookAtView( in float3 position, in float3 lookAt ) {
    return lookAtView(position, lookAt, float3(0.0, 1.0, 0.0));
}

#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