LYGIA Shader Library

view2screenPosition (lygia/space/view2screenPosition)

get screen coordinates from view position

Use:

<vec2> view2screenPosition(<vec3> viewPosition )

Check it on Github


#ifndef CAMERA_PROJECTION_MATRIX
#define CAMERA_PROJECTION_MATRIX u_projectionMatrix
#endif

#ifndef FNC_VIEW2SCREENPOSITION
#define FNC_VIEW2SCREENPOSITION
vec2 view2screenPosition(vec3 viewPosition){
    vec4 clip = CAMERA_PROJECTION_MATRIX * vec4(viewPosition, 1.0);
    return (clip.xy / clip.w + 1.0) * 0.5;
}
#endif

Use:

<float2> view2screenPosition(<float3> viewPosition )

Check it on Github


#ifndef CAMERA_PROJECTION_MATRIX
#define CAMERA_PROJECTION_MATRIX u_projectionMatrix
#endif

#ifndef FNC_VIEW2SCREENPOSITION
#define FNC_VIEW2SCREENPOSITION
float2 view2screenPosition(float3 viewPosition){
    float4 clip = mul(CAMERA_PROJECTION_MATRIX, float4(viewPosition, 1.0));
    return (clip.xy / clip.w + 1.0) * 0.5;
}
#endif

Use:

<float2> view2screenPosition(<float3> viewPosition )

Check it on Github


#ifndef CAMERA_PROJECTION_MATRIX
#define CAMERA_PROJECTION_MATRIX u_projectionMatrix
#endif

#ifndef FNC_VIEW2SCREENPOSITION
#define FNC_VIEW2SCREENPOSITION
float2 view2screenPosition(float3 viewPosition){
    float4 clip = CAMERA_PROJECTION_MATRIX * float4(viewPosition, 1.0);
    return (clip.xy / clip.w + 1.0) * 0.5;
}
#endif

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