I've got an old billboard rendering implementing in fixed-function openg. The billboards technically represent locations in 3D space, but I want them to render the same pixel dimensions no matter how far away they are in my 3D (perspective projection) scene.
The way I handled this in the current (ancient) implementation is as follows:
- Render my scene in standard 3D perspective projection without my billboards.
- Switch to orthographic projection, Loop through the billboards client-side, transforming their 3D position into 2D Screen coords
- Render all billboards as 2D objects with a constant size used in pixels.
This is horrible for a number of reasons, first being it uses the oldest of old GL functionality. I'm switching to shaders and using opengl 'instancing' as the basis for the update.
One of my main goals is to eliminate the client-side step of projecting the billboards into 2D screen space, and rendering via a second pass in an orthographic projection.
As far as I can tell, the only way to render the billboards within the perspective projection, while having them all maintain a fixed pixel size on screen, is to re-size each billboard dynamically from within the vertex shader, based on distance from eye .
Is the above assumption correct? Is there any simpler way to go about this that eliminates the client-side transforms/orthographic render stage while maintaining constant pixel dimensions for billboards in a 3D scene?
For what it's worth I'm intending to render the shader-based billboards using OpenGL 'instancing', such that I can store a vertex array with each point representing a unique billoard, and my 'instance' data containing the base corner offsets.