Since I spent most of the previous week bedridden, I have fallen behind a week and will have to rethink my planning. Yesterday I did pretty decently however, and now my billboards are in place. Cleaning code has gotten pushed back, and now focus will instead be on functionality. I’ll make it less messy when I feel I have the time.
This is the shader program for my first billboarded particles:
- [VS] Pass unprojected points directly down to the Geometry Shader
- [GS] GL_POINTS as input, output GL_TRIANGLE_STRIP
- [GS] Get the non-projected point. (modelView, no projection)
- [GS] Add/Subtract extents from the points for each corner of the billboard, then multiply with the projection matrix.
projection * vec4(pos.x – extent.x, pos.y – extent.y, pos.z, pos.w), //Lower Left
projection * vec4(pos.x+extent.x, pos.y – extent.y, pos.z, pos.w), //Lower Right
- [GS] Emit vertices accompanied by an outparameter for UV coords,
- [FS] Texture the billboard from a sampled texture!
This is mostly done, I just need to put up a texture on the billboard now. One interesting detail to note for someone new to geometry shaders (like me!), remember to generate points following a point only altered by the modelview matrix, otherwise the billboard will be skewed depending on the screen width and height!
Hopefully things will work pretty alright and I won’t have to overthink. I am slightly curious about the difference in consumption between these Geometry Shader billboards and normal billboarded particles. Maybe I’ll have to measure when I have time.