Sunbeams in Crysis

How would you go about implementing this kind of effect? I have shadowmapping done, and I am guessing this uses the shadowmap to brighten the screen in a final pass, but I am not sure how:

See the squid in 2:56 here:
Maybe this hints the effect is like radial blur, with black color. It’s a post-processing effect alright. Then again, .pak files are .zip…

Isn’t it a post processing effect called God-rays?
GPU gems 3 has an article about that (chapter 13, Volumetric Light Scattering as a Post-Process).

Yes it is. And like Ilian Dinev said, it’s some kind of radial blurring effect. Nvidia used it in their Nalu demo for GF6 cards.

I experimented GPU Gems 3: Kenny Mitchell’s 2D post effect technique. The result was pretty good, the only drawback is that you lose the god’s ray is the sun is in your back.

I prefer it to the light volume technique described by Jason Mitchell in “Light Shaft Rendering” ShadersX3 . Mostly because it’s easier to implement and it doesn’t make your GPU melt.

I published the source code and a little explanation of the process with openGL:

The Gems 3 technique does require a rather large-ish kernel for good effect (better perf with smaller/downsampled image). Though I think it’s incredibly effective given it’s simplicity (post process only, no preprocessing whatsoever). (Btw, GPU Gems 3 is online now.)

As everyone above me said, Crysis uses a postprocessing shader which performs radial blur on a “masked” framebuffer (masked = all foreground objects in black, with a colorful background/sky).

If you are interested in a more correct approach with less artifacts, you can take a look at nvidia’s Volume Light demo. They are tracing rays from the eye to the first intersection in the scene (depth buffer), and use the shadowmap for checking how many samples are in the shadow and how many are lit. Check the paper for more details.

The problem with this approach is that the final effect looks more like volumetric fog, instead of god rays, for open environments. You can always modify the shader to match Crysis’ god rays if you want, but the paper doesn’t mention that.

Hope that helps.


That is a very nice demo nicolasbol. Thanks for sharing.

amazing sample. thanks alot nicolasbol. unfortunately it crashed my system on Radeon HD 2400 Pro - WinXP. ;(

Same here. It seems not to be working on ATI. The FBO path crashes the driver, the texture-copy path surely does something, but it’s still far from god rays. :slight_smile:

Sorry guys, I don’t have any ATI GPU available to test :frowning: !

Although I believe you, I don’t understand why the FBO is working on NVidia an not ATi. I used only standard ARB methods.

I suspect the issue to be with the shader. If anyone can try to start from the command line, you should be able to see shader compilation errors…

Hopefully someone with an ATI will dive in my code…if Santa brings me a Radeon HD 4870, I promise I will will fix it.

Check out the discussion on this demoscene forum

  • or wait for Nvidia to release chapter 13 of GPU Gems3… or just go buy it :slight_smile: