I am building a 3D engine and have a rendering abstraction that focuses on writing shaders. Most my 3D shaders have
gl_Position output like:
gl_Position = projection * view * model * vec4(position, 1);
I would like to draw some 2D UI on top of all the 3D draw calls. I am having a hard time understanding how to do this.
Let's say I wanted to draw a HUD player life bar that is fixed to the bottom left corner of the screen. I can imagine drawing a quad. and maybe applying a texture to it. I would have 4 vertices for the quad to feed to the shader. How would I change the
gl_Position calculation to handle drawing only to 2D screen space? Would I update the transformation to only apply the
gl_Position = projection * vec4(position, 0, 1);
How to determine the local coordinates of the quad verts? When the screen scales or resolution varies, How to ensure the quad stays positioned to the lower bottom screen? How to ensure the quad dimensions stay the same ratio?