I am trying to find a way to render certain objects in my 3d scene without the effects of the perspective projection. E.g. I want them to have the same pixel dimension independent of distance to the camera or the dimensions of the viewport.
Here is what I tried in the vertex shader so far
uniform vec2 screen_size;
varying float camera_distance;
void main() {
mat4 mvp = projectionMatrix * modelViewMatrix;
float scaleFactor = 2.0 * 50.0 / screen_size.x;
float w = (mvp * vec4(0.0, 0.0, 0.0, 1.0)).w;
w = w * scaleFactor;
gl_Position = mvp * vec4(position.xyz * w, 1.0);
}
So far no luck.