S2ENGINE toward realism
As anticpated in the previous post during the last two weeks I have worked in order to speed-up engine fill rate optimizing shaders and reducing texture bandwidth requirements. One big problem was the G-buffer dimension. Until now I used 4 x 64bit buffers + depth: this is too much if I want the engine run well at high resolutions.
The first think was to reduce the buffers from 4 to 3. How to make this if my deferred rendering system needs all information contained into the 4 buffers? Simple I need to change the rendering equation choosing one requiring less data. My choice fell on a physically correct bidirectional reflectance distribution function (BRDF), based on Blinn-Phong equation.
The previous reflectance function required 4 parameter: specular pow, specular multiplier, fresnel pow and fresnel multiplier, i.e. an entire buffer (4 16bit channels).
Well in the new equation only one parameter is required: surface roughness (i.e. surface glossisness). With only this parameter the new equation can control the specular power, the glossisness and the fresnel reflection of the surface with a physically correct behaviour.
Thanks to this fact I have been able to re-arrange the parameters into the buffers and reduce them from 4 to 3, also obtaining more realism and quality in rendering. With the new equation the previous specular-opacity map (stored inside the normalmap alpha channel) become a real glossisness map. In other words the alpha channel of the normal map can control not only the specular intensity of the surface but also its specular power opening new possibilities to the artists that can control shininess of the surface on a per-pixel basis.
See the images below: the tires of the jeep have less gloss than rims, but they are rendered with the same material and textures.
The next pass has been reducing the bit depth of the buffers: from 64 to 32bit (8 bit per channel). So in the last version our G-buffer has a depth of 32×3=96 bits instead of 64×4=256 bits!!! The effects of this reduction, together with some minor improvements of bloom and lens post-processing effects, are clearly visible: about 20-22 FPS at 1600×900 resolution on an NVIDIA GTS 250 card with all post-processing effects enabled!!
Working on the G-buffer re-arranging I have found space to left the parameter for scattering (just like previous version) and I have also left 2 (TWO!!!) channels free for future use. The scattering equation has been changed too. The new one is more attractive and convincing. I have used it on trees and plants but also on clouds and smoke particles.
To complete the rendering equation I’ve made some improvements also on the ambient lighting. In this new version all surfaces have ambient diffuse and specular reflections, the blurriness of ambient specular reflections of a surface can be controlled with the same parameter used for glossisness, changing this parameter you can see the surface become more/less metallic. The same equation have been applied also to alpha-blended and refractive surfaces.
Other improvements: A global shadowmap for the terrain that gives it a more convincing look , a new smoke/clouds shader and, most important, the new filmic tone mapping operator, also used into Battlefield 3 and uncharted games, which gives to the final image a movie-like feeling.
More improvements can be made but for now it’s just unbelievable.
This week will be the last before the build releasing, I’m now working on the new occlusion culling system (which will complete, together the frustrum culling discussed in the previous post, the overall new visibility culling system), and I’ll end up with some minor improvements I’ve collected from the comunity feedbacks.
Today S2ENGINE is closer to reality…stay tuned!