Posts

Showing posts with the label OpenGL

Billboards with geometry shader

Image
Billboards in video games are the 2D planes in 3D scene that are always pointed perpendicularly at the camera. They can be used to draw distance objects that doesn’t require much details, to draw particles or they can be used as a part of the editor interface. Normally the plane is rotated by transforming metrices so it face the camera, but there is another, easier way – by using the goods of geometry shader. In fact, to draw a square billboard we only need the position of it’s center and normalized size of the edge. We pass the position of the center of the billboard from Vertext Shader straight to the Geometry Shader. in vec3 inPosition; out vec4 inoutPosition; void main() { // Just pass the position to the geometry shader. inoutPosition = vec4(inPosition,1); } After that we calculate the screen position of the center of the billboard by using the world position of the center of the billboard and the view-projection matrix. This position can be used to generate a...

GPU Particles

Image
Modern graphic cards are the source of an enormous computing power that can be used not only for rendering. How about updating over million particles with a realtime changing enviroment or emitter position?

Light shafts

Image
Light shafts, light scattering, god rays – many names but they represent the same awesome effect that can be noticed during foggy day or in a dusty room. In games they make levels more moody and atmospheric, but how are they made?