I’ve been scouring the web trying to find an explanation of what the position of a vertex actually means before and after each projection in the standard MVP chain. After reading and trying some things out, I understand it in a general sense:
- Initially, position is a multiple of the bounds of an object, in local object space
- After M, position is in world coordinates
- After V, position is in camera coordinates
- After P, position is in screen coordinates
What I’m trying to figure out for each of these is what exactly the units mean. Here’s what I understand so far - if anything is incorrect or you can fill in the gaps, I’d appreciate any help
Units are -0.5 to 0.5 along the 3 axes, with -0.5 and 0.5 corresponding to the bounds of the object. No surprises there.
Units are in Unity’s world coordinate system. No surprises there.
Units are in some kind of camera coordinate system. X and Y appear to be square, and a quad with an assigned X and Y range of 1 in MV spaces doesn’t appear to quite fill up the screen from bottom to top. No idea what units Z is in.
X and Y units are in viewport coordinates, with -1 to 1 being the range horizontally and vertically? No idea what units Z is in.
Once you’re in post-P space, it appears you can use _ScreenParams to get the number of pixels and convert from viewport to pixel coordinates in XY.
So in a general sense, I’m looking for information on what the coordinates mean in each space, and what can be done with them.
I’m trying to create some custom billboarding. Here are a couple examples of what I hope to do with this information:
- Create a billboard that appears the same size regardless of distance from the camera.
- Create a billboard whose size is dependent on distance from the camera, but not linearly. E.g. a billboard that appears to be 0 pixels wide at 1000 game units, and 100 pixels wide at 10 game units, increasing along some kind of curve.