Is there a way to use screenspace vertex positions in a mesh? I’d like to simply set the positions of vertices in a mesh to screenspace values and use a shader that doesn’t do local to view space transforms but uses those values as is. Currently I’m transforming the world space positions in the mesh when the camera moves so that the mesh remains fixed relative to the camera but I’d like to remove this extra cost.
I’m not sure if I understand your question correctly, could you paste your code? It sounds like you’re doing mesh vertex modification on CPU, am I right?
Ideally you would write a CG or GLSL shader which transforms mesh vertices into the screenspace regardless of the camera position. In case of GLSL something like:
gl_Position = gl_ProjectionMatrix * gl_Vertex;
A cheap solution I use for something tracking the camera, and remaining in the same screen space is to just parent it to the Camera. Then the transform matrices do all the work for you.
Yeah, I need to handle zooming as well though. Computing the values on the CPU works currently but I was just wondering how I could do it using the OpenGL fixed function pipeline in Unity.