Jump to content
  • Advertisement
Sign in to follow this  
maya18222

dynamic light shafts

This topic is 2838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've noticed a lot of games using the following kind of lighting scattering effects within light shafts, both outside like below

crysis_2_demo_for_pc_coming_very_soon_1.jpg192451-header.jpg
and inside like this
VolumeLight.jpg

The second image looks like its achived by a bloom filter, but with a directional blur. But Im wondering how the third image would be acheived?

Share this post


Link to post
Share on other sites
Advertisement
Crytek's technique is a post process. You can implement something similar using this as a guide. However it's really only good for the sun or the moon, since it only works for one light source thats' at infinite distance from the camera. If you want real volumetric lighting effects it's possible to do so by marching through a shadow map, but that can be rather expensive in comparison.

Share this post


Link to post
Share on other sites
I'm also fairly interested in this.
I used to experiment a bit with something relatively similar to what MJP suggested - the volume marching was implemented using standard projection and additive blends (it happened quite some time ago). It used to be quite slow for an the amount of slices required to give convincing results (especially when the blends were not additive).
I think the ray-casting operation MJP suggests is going to be fairly more efficient nowadays compared to real blend (compute instead of read/mod/store bandwidth)... I don't expect this to be fast enough to be used in action but perhaps adjusting the "step" sizing could do the trick.

I'd like to read other experiences.

Share this post


Link to post
Share on other sites
It's quite literally a radial blur of 1- scene depth. The trick, however, is that the center of the blur is the light position in screen space-- lightPos * VP. While you probably can't reproduce the third shot exactly, the effect still looks pretty decent in practice. Disregard the infinfite light thing-- as far as I'm aware, Unreal 3 uses the projected light position without issue.

Share this post


Link to post
Share on other sites
We did the marching through the shadow map technique, gave some really nice results. We needed quite a few samples for best visual look though, so we do it in low res and then blur the result as we composite it on screen. Added some luminance adaptation and it looked pretty good. However doing additive fake light passes like this on screen can occasionally play hell with HDR, so worth keeping in mind.

Share this post


Link to post
Share on other sites
Doing shafts as a post effect only works when you can see the lightsource, because you'll have to render the source as a bright dot/sprite/sphere(or whatever), then create blur-streaks. For outside scenario's it works good & fast. Eventually you can use it for (mutiple) indoor lights as well. Like I did here:



http://3.bp.blogspot...0/HookBeast.jpg
A bright sprite is behind the monster. You can't see the sprite, but it will be rendered in a special pass required for the blurring. Here another one. Notice that you won't get perfect shafts between all that detailed fence wires, unless the you are nearby enough to render the fence sufficient in the (smaller) pass that renders black objects and source spots into a texture:
http://2.bp.blogspot...ShaftMethod.jpg



However, if you can't see the source (for example, in a long corridor where the sun comes in via windows on the left in such a way you can't see the sun), you won't get any shafts. So I switched over to a technique that shoots rays between the pixels in front of you(scene depthMap) and the camera. For each step (you need a lot), you test if it intersects shadowMap(s). It gives pretty accurate results, although it costs quite a lot more of course. You can gain speed with tricks like ATEFred suggested.
http://2.bp.blogspot...Light_Shot4.JPG

As for the cool color effects & dust within the ray like you see on shot 3. You could store a depth or 3D position for the shaft pixels (in the raymarch pass). Then later when upscaling to full-screen, you can use that info to sample from a 2D or 3D texture with animated dust. The blue colorizing... no idea how they did that. Probably some cool formula based on camera angle, traveled shaft distance, and some magic :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!