MotoGP: the sun

The MotoGP sun effect started out similar to this XNA Framework lensflare sample:

  • Use a GPU occlusion query to detect when the sun is visible
  • Draw a big and very soft glow sprite
  • Draw a series of smaller lensflare sprites

But we weren't satisfied. If you look straight into the sun, that should be blindingly glowy. Our version was just too tame.

Today, everyone and his dog is partying away with high dynamic range, tone mapping, and bloom filters. But this was 2001. Even if the hardware had been up to the job (which it wasn't), we had never heard of such techniques.

If I remember right it was Damyan (hi there if you ever happen to read this!) who came up with a solution. He noticed that when you look straight at the sun, everything else seems much darker in comparison (which is the principle behind HDR tonemapping). So, what if we detected when you were looking at the sun, and just manually darkened down all our other graphics in response?

Of course, darkening everything down is easier said than done. No way could we afford to add a special "darken if looking at sun" computation to every shader in the entire game!

But wait...

All our shaders already supported fog. That's basically just a global tint, right? Plus a computation that makes it only apply to distant objects.

Fog is controlled by two values: the start and end distances. Anything closer than the start distance is not fogged at all. Anything further than the end distance is 100% fogged. In between, the fog amount changes gradually. The artists usually tweaked the fog to start somewhere around 70% of the draw distance.

But what if you make the fog start distance negative? Then even objects close to the camera will appear partially fogged.

Cheapo not-really-HDR-but-still-looks-kinda-cool hack:

  • Detect when you are looking at the sun
  • If so, change fog color to black, and fog start to a negative value
  • Draw glowy 2D flare sprites over the top



Comments (0)

Skip to main content