I have added a new post-processing effect that approximates light scattering on the sunlight according to this GPU Gems 3 article. It required a minor coding on the engine, I have introduced two new built-in shader parameters: sun screen-space position to use in the calculation, and a term that gradually scales down the ray effect when the camera is not turned towards the sun. The process itself has been implemented in the postprocessing shader of the deferred chain, that made implementing it easy because all required data is available at this point of the rendering.
Here are some pictures about the result.
I have made dynamic sunlight and shadow support wired to the UI, so the sun position can be controlled interactively. The engine calculates the sun position by using azimuth and elevation as parameters. Sun and fog color is adjusted according to the elevation by using a color gradient generated with GIMP. The result can be seen here:
I have added normal mapping support recently. It is not perfect, but works well with some new models I have obtained from ShareCG (thank you, Nobiax). The model loader still lacks of tangent and binormal processing support (still relying on lowly OBJ files), so I am using partial derivatives to reconstruct T and B from GBuffer and shader parameters.
I have extended the deferred light combiner shader to handle multiple BRDFs with many parameters (diffuse, specular, environment reflection, etc.). The BRDF parameters are organized in a table that is indexed by a field in the GBuffer. Different objects can have different BRDFs, the particular index is an effect parameter. Deferred light combiner shader handles backside lighting (e.g. the sunlight shines through the leaves), controlled by a diffuse parameter in the BRDF table.
Here are some images produced by the current state of the renderer.
Just finished the cascaded shadow map support. It uses the technique described in NVidia’s CSM paper. The original method gives somewhat flickering shadow edges so I have added some reduction technique described in a talk about Frostbite. To make it more smooth, I have added 3×3 PCF filtering. There is a short video with the results:
After some struggling with frustum and light projection matrix calculation, CSM is finally working in the engine. There are four splits, parallel light projection and dynamic bounding frustum calculation. The technique is basically the same as described in the NVidia’s article.
There is still some annoying bug with frustum culling in the shadow map render code, thus, the shadows are leaking sometimes. But performs quite good after all.
Here are some pictures of the results.
I have switched from PhysX to Bullet (but not irreversibly) due to the long waiting for my developer account from NVidia. To test the physics, I have implemented some basic FPS character movement functionality. First I have tried to use the Bullet’s character class, but after a while I have realized that it would be too painful to use it. Now it works with a simple capsule collision shape locked in vertical orientation. Here is a short video about the new features.
I have played with the shaders in the renderer. Now it supports glow maps and specular maps. The specular map is used in two ways. On the one part, it is used as a specular term in the light equation in the lighting pass. On the other part, it is used to add some environment reflections on objects in the final pass.
The terrain shader blends between multiple textures depending on the terrain slope and height. The shading is done in runtime so the changes in the terrain geometry caused by the erosion simulation are properly appearing in the rendering.
Here are some images about the results.
To emphasize the effects of environment reflections (and to make calculations simpler), I have replaced the procedural skybox to a static HDR environment cube map.
Update 10/01/12: I have found a bug in the shaders. I have fixed it, and I have done some modelling to see the results. I have obtained some (cars and dumpster) from TurboSquid too, and I have put some new images to the slideshow to show the results.
Finally, I have a brand new hardware. The config is: Intel i7 2600K 3.4GHz, 8GB RAM, NVidia GeForce 560 Ti. It is like to get into a Rolls-Royce after a trolley. One of the first things that I did was to give my engine a try. Of course… 🙂 The difference is amazing. The overall speed-up factor of the rendering is somewhere between 10 and 40… quite good, I think… The occlusion culling gives much more boost than on the old GPU.
Read the rest of this entry
…and there are spotlights. And we see the lights, and this is good.
And I am very happy with it, because it took some time to get it work correctly due to some small and annoying bugs. But the results are fine. We can add spotlights into the scene, we can put projected textures on them and they can cast dynamic shadows. They are integrated into the deferred renderer, of course. Spotlights are rendered with a closed pyramid, but is possible to use a cone instead. Bounding boxes are adjusted according to the current transform of the light frusta to keep visibility culling efficient.
Read the rest of this entry
This post is the second part of another I posted earlier.
The detection of uninitialized class members is one of of my recurring problems with C++. The language standard does not guarantee anything about member variables so I should initialize them myself. Unfortunately, VC++ compiler does not warn me if I forget to initialize a class member variable, even if I set the highest warning level. GCC detects this kind of sloppiness and reports them to me keenly, making great improvements in code quality. Furthermore, GCC goes one step beyond and warns me if the initialization order differs from the declaration order (see Effective C++ about this).
Read the rest of this entry