So, how does my render pipeline work?
Let's see how to achieve this:
Warning, this will be a long post!
We start by populated the G-Buffer, which is a framebuffer with 4 buffers attached, used for deferred shading. So it all starts with just the texture colors being drawn to one buffer:
And the normals into another buffer:
The attributes (diffuse and specular infos) into a third:
And the depth into yet another buffer:
Ok. We have the basics. Now we can start the actual rendering, first we draw the skybox:
And then we combine the 4 buffers previously filled, adding a unlimited numbers of pointlights at no cost and calculating the shadows only once per pixel, dependless of the complexity of the scene!
Ok. now, let's add a sun and some post-processing effects:
Now let's draw the godrays. We use the depth-buffer from the the G-Buffer to know where the light comes from:
And the we make it expand directionally from the sun position:
Let's add the godray to the scene:
Nice! Now the water. First, we prepare the reflection on the water by redrawing the scene top-down and cutting down anything above the see level:
Ok, let's add the water to the scene! To do that we again make use of the G-Buffer to include some refraction based on the depth.
Just add the UI and we are done!