This has been a very productive week, I fixed the bugs from the last week (and made new ones, which I'll explain later) and also implemented a new features. First, I implemented water rendering. This effect is made by rendering the scene twice (reflection and refraction textures) and then sampling those textures from the water shader (aplied on a plane). The fresnel equation is used to decide how much of each texture should be seen. If I left the water like that, It would look more like a mirror, to make it look more like real water, I displace the reflection/refraction textures, this gives a distortion effect. Normal mapping is also used to give nice looking specular reflections. The shore of the water is faded by testing the current depth of the water (using the depth map), later I would love to add some foam to the shore.
One of the problems that I had with the terrain, is that I had the same amount of triangles in all of the chunks. Many techniques can be used to change this, I used a simple one. I initially create the chunks with low triangles and then, I apply tessellation. The terrain is now more tessellated near the camera. This improves the performance as we are not wasting resources any more. In the comming weeks I will make the chunks an instanced mesh, so I'll be able to draw the terrain in just one draw call (this will allow me to have much more chunks!).
I'm rendering the terrain 3 times each frame (refraction texture,reflection texture and final render) and I'm also rendering all the chunks, that means that chunks that are behind the camera or at the sides are also being rendered, that's why I started working on a frustrum culling system. A frustrum culling system will discard chunks that are outside of the camera view frustrum. Right now this system isn't working at all. Next week I'll be working on it.