How do you get the screen coordinates of a vertex in a spatial shader's vertex() function?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fakedeltatime
:bust_in_silhouette: Reply From: Jason Swearingen

I think you need to multiple by the projection matrix, like this:

:bust_in_silhouette: Reply From: fakedeltatime

Finally figured it out with help on reddit, this makes it so that the output of POSITION will give the same outcome as no vertex manipulation in the shader, making it so that I can manipulate the mesh based on the screen position.

vec4 vert = vec4(VERTEX, 1.0);

vert = MODELVIEW_MATRIX * vert;

vert = PROJECTION_MATRIX * vert;

POSITION = vert;