Sunday, November 23, 2008

Motivating Depth of Field using bokeh in games

I've posted before on Higher Fidelity depth of Field effects in games. I believe that current depth of field effects in games fall short of delivering the same cinematic emotion as movies and TV. The reason distills down to the commonplace use of compute-efficient separable Gaussian blur. More expensive methods can reproduce bokeh with crisp circle of confusion shapes.

I've realized in casual conversation, many people can't easily recall how the technique is commonly used in television and movies. And, they often overlook how common it is.

So, in this post I've collected a bunch of examples from movies, and whipped up some mock images from game screen shots.

This is all just motivation. ;) Ideas for fixing the problem in a practical way is for another post.

Cinema Examples

A few simple shots, showcasing bright point lights, and specular highlights:



Similar to the above, but with some edge highlights blurred as well. Look at the horizontal edges blurred in the background on the right of the image:


The Dark Knight made extensive use of the effect for the entire film. The circles of confusion often had an oval shape due to the Panavision anamorphic lens used (compressing the image on film to an aspect ratio different than that of the screen). Also, note the specular highlights from the henchman's head and waist:


These circles are larger than in many of the others, and also show the non-uniform characteristics of the disks:


Finally, a subtle image. The amount of blur is minimal, but still distinctive on the lights in the background. Even though slight, delivering this effect will be yet another one of those required level of polish for AAA games in the future:



Mock Images
I've doctored up some game screen shots to show what is missing. They're quick and dirty, made in Photoshop with "lens blur". In a high dynamic range rendering pipeline, results would be much better, since the distinctive shapes we're looking for are results of very high contrast between highlights and the rest of the background scene.

First, a Mass Effect scene that would have worked well. I quickly added several points of bright light to trigger the effect since the background didn't include small point lights:

Before:


After:


And here marketing screen shot for Unreal Tournament. I only generated a mask and applied the blurs, since the image had good contrast to begin with:

Original:


Lens blur:


Gaussian Blur (common in games today, poorer result):


And, a zoomed section contrasting Gaussian to Lens Blur:


Keep your eyes open as you watch TV, or movies, and you'll notice more and more how common this effect is.

Pay attention in games, and you'll notice that we're currently delivering the concept of "out of focus". That's sufficient to draw attention to near, middle, or background. But, games today are not capturing the artistic & emotional feeling that comes with a strong use of the effect.

I have a few prototyping ideas for delivering a higher quality depth of field, which I hope to have time to try out soon, but may likely take a while. As new hardware brings more FLOPS, it's also possible that the O(n^2 * m^2) naive approach may just be used soon enough (as was already done in Lost Planet on DirectX10).

(Next post, Jeff Russell Depth of Field example comments)

Update: Nice technique writeup in 3DMark11

Sunday, November 2, 2008

Beautiful Pixels Game API; Connexus ships to IGF

Before the blog "Beautiful Pixels", I used the name for a Game/Visualization API.

Beautiful Pixels the API was a concept for a game jam:
  • Everyone decides to write either a game, or a visualizer.
  • Games write out to a low resolution, palletized, frame buffer.
  • Visualizers render the low-rez games in high-rez, in some novel way.
Games are typically Atari 2600 or Intellivision style, or lower rez. Think Tetris clones. Visualizers could render out the games in HDR with bloom, or as colored smiley faces, or a field of flowers, ... The coolness comes from the odd mash-up of games and visualizers, that were not planned to go together.

Well, the last Game Jam we had, we picked another theme, Game Mad Libs. The Beautiful Pixels API only had a few small games we made for it in pre-jam planning days.

Below are screen shots of games using the Beautiful Pixels API:
Game: Platformer, by Adrienne Walker
Visualizer: Mario World, by Mike Daly


Game: Connexus, by Mike Daly
Visualizer: Smiley, by Mike Daly


Game: Box Pusher, by Mike and Jody
Visualizer: Power Blur, by Mike Daly


But, one game did make it well beyond Beautiful Pixels! Connexus (by Mike Daly) just shipped to the Independent Game Festival. Check out the Connexus website for screen shots. To the right is a screen shot of Connexus as it shipped to IGF, re-implemented outside of Beautiful Pixels API.