The vertex shader has no knowledge of “the object” and so each vertex must have enough information to translate it appropriately. So it must have the object coordinate (usually I do this in position) and some value to determine how to offset it (texture coordinates can be used if they are 0,0 - 1,1 or whatever).
To pin to an axis like you have it is a little trickier than having it screen orient, but not too bad.
Also, are your quads going to be the same size or will they be different widths and heights? What kind of size are we talking about?
@pspeed said:
Does your quad have texture coordinates?
The vertex shader has no knowledge of “the object” and so each vertex must have enough information to translate it appropriately. So it must have the object coordinate (usually I do this in position) and some value to determine how to offset it (texture coordinates can be used if they are 0,0 - 1,1 or whatever).
To pin to an axis like you have it is a little trickier than having it screen orient, but not too bad.
Also, are your quads going to be the same size or will they be different widths and heights? What kind of size are we talking about?
The mesh can have different proportions of height/width. The size can be different too… from 1 to 300 units.
Well, the presumption is that you are doing this so that you can batch a bunch of quads together. (If not, just use billboard). So if you wanted to use a matrix to do this then you’d need to store the whole matrix with every vertex. But that’s overkill. Actually, I guess if all objects shared a common up vector and would always then you could use one matrix for the whole batch. This would just be the inverse camera rotation (basically) and you’d multiply it by the world view matrix before applying projection. I’ve never done this approach personally but it sounds simple enough.
Otherwise, somehow, each vertex needs to know the model position (model origin) and the vertex position relative to the model position. Usually I would use the texture coordinates for this but it does get a bit trickier if each quad can be a different size.
I had to do this because normal y-axis-locked billboards look like crap when looking down from above. So for my fire billboards I mix the y-axis-locked position with a more sprite-like position depending on the angle of the viewer.