Full screen with random SSAO samples

There we are! The last missing piece was to remove the aliasing that was apparent due to the regularity of the sampling we were doing on every surface fragments. To solve this, a simple method is to rotate the samples around the surface normal of the fragments. That random rotation is calculated (in my case) with shader code applied on the X and Y coordinates of the current fragment (re-using online code snippets).

Finally, to help debug this better (and to show it off now that it is finally working!!!) I added code to switch to a full screen, mouse controlled, camera by pressing enter. Again, this was simple to add, thanks to the quality object oriented design of the project. The feature proved useful since SSAO is subtle. Thus, having a way to zoom in on the models while refreshing the shader code was very valuable:

Full screen rendering of BRDF with 128 SSAO samples

Lots of effort, for a subtle effect... (toggle on/off visible at the 11 and 14 seconds mark)

Time spent for this Time spent so far
5 h 180 h

SSAO support

Finally, I added SSAO (Screen Space Ambient Occlusion) support after 40h of work! It was my first time implementing it, so it took quite a while. I was very close for a long time, but some tricky parts eluded me. I think it was made more complicated for me because of the multi-viewport setup I have. The matrices I used to render to a part of the viewport where incorrect, but it only appeared when I started using them for SSAO. Finding this was quite tricky (especially when you have to come back to this after working all day on something completely different!).

Anyway, here are the results:

If you want some explanation about what is SSAO, you will have to read further!

Time spent for this Time spent so far
40 h 175 h
[Read More]

Render to texture and model cleanup

I did a bit of grunt work as I was getting frustrated with the look of the scene and the usability of the software while working on rendering. This implied a rework of many models making them more colorful, better optimized (removed duplicate vertices and fixed normals) and standardized (they all face the same directions -Z). I could then update my code to work in a more standard way now that models have been oriented properly. I also added a separate debug camera (in the top left corner), and the necessary code to render to texture (which is now displayed on the platform screens).

New models, better debug experience, first steps for deferred renderin

Surface normals visible on the platform screens after pre-calculation

Time spent for this Time spent so far
15 h 135 h
[Read More]

BRDF simulation and mouse movement

This time, I worked on transferring previous work to the project by integrating a shader trying to emulate the BRDF (Bidirectional Reflectance Distribution Function) in real-time. This function represents how much of the incoming light from a specific direction is reflected to an outgoing direction. The idea is: if you calculate it on a specific point of a surface for all incoming directions, for the outgoing direction of your eye, you will get a physically correct simulation of what you would see. While it is currently impossible to achieve in real-time, clever shortcuts and approximations helps get closer to it!

But in short, things look much better now (that is, when models have material set-up, unlike those enemy ships)

BRDF rendering with direct and indirect illumination with single spot light

Computer graphics time-jump... ACTIVATED!

Time spent for this Time spent so far
19 h 120 h
[Read More]

Multiple shader rendering

After further work I was able to get the rendering handler to support more complex configurations. This allowed me to re-enable the old diffuse shader for each camera, while having the background shader only enabled for the main camera. Shaders are not hardcoded directly anymore in the rendering handler, they are created separately before being registered to it. The rendering flow also is now cleaner, with separate sections responsible for the various rendering steps keeping performance in mind (rendering all cameras using a shader, before moving to the next shader, these kind of things…).

Animated gif showing the background rendering behind the old game rendering - Things are working once more!

New rendering with backgroundshader, main view only

Good to be back! (Except that collision bug...)

Time spent for this Time spent so far
25 h 95 h
[Read More]