Faster Deferred Shading

In the last two late evenings I have worked on the elimination of the 3D position from the geometry buffer, making some improvements on shader parameter passing and not surprisingly, hunting bugs down. The results are the following:

First of all, there is no such thing as position buffer in the renderer, I calculate the eye-coordinate position directly from the depth buffer using the inverse of the projection matrix. Although this causes some extra cycles in the fragment shaders, but the thinner Gbuffer significantly reduces the overall memory bandwidth of the process. It caused about a 10-20% performance gain, it definitely worths the effort. 🙂

The geometry buffer has the following layout:

Attachment #1: RGBA8, diffuse color and specular exponent.
Attachment #2: RGBA8, normal vector and BRDF index.
Attachment #3: depth, 24 bit

Second, I have introduced several automatic built-in engine variables to the shaders to support these calculations. (I will write about automatic shader parameters later, I promise).

Furthermore, transformation matrices needed by the shaders are calculated on-demand (modelview, normal, etc.).

Now, the renderer can handle many dynamic omnidirectional lights, specular reflections and 255 different BRDFs for shading.

Lights are rendered with bounding spheres, discarding surface pixels not interacting with the light. There is no stencil optimization, I have “deferred” its implementation to a later coding spree.

The final rendering pass combines light accumulation buffer with the GBuffer and renders directional sunlight, ambient light and sky background.

There is a demo video showing a simple scene with the results:

Advertisement

Posted on August 12, 2011, in demo video, rendering and tagged , , . Bookmark the permalink. 3 Comments.

  1. Hey Balázs,

    I noticed you subscribed to my blog, so I decided to check out some of your work. Your engine looks fantastic; I’ve particularly enjoyed reading the posts on deferred rendering and your shader system. I’ve been working on some similar things myself.

    I’m going into software engineering next year and will hopefully be able to find the time to continue working on my own game engine project during school.

    Thanks for taking an interest in my blog, and keep up the good work!

    Taylor

    • Hi Petrick,

      Thank you very much, I’m glad to see you liked that I wrote, especially if I consider that I am not a real journalist, and English is not my native language. 🙂 I have seen that you have done some experiments on OpenGL ES platform, it will be an interesting topic for me because I intend to port the engine to Android. Theoretically, it can be compiled under Linux (actually I started the development in Linux), but that was years ago and I have added a lot of new features since then, so I don’t know if it still compiles… 🙂

      Thanks again, and I hope I will read some more interesting articles from you. 🙂

      Balázs

  1. Pingback: Effects, Passes, Shaders and Parameters « Merlin3d

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: