lygia
/space
/view2screenPosition
)get screen coordinates from view position
Use:
<vec2> view2screenPosition(<vec3> viewPosition )
#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 )
#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 )
#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
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.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository