Light Beams

Started by
3 comments, last by HurlyBurly 21 years, 5 months ago
I am currently working on a scene that requires a lightbeam effect, like when the sun light gets through the clouds... I was simply wondering what the simplest way to accomplish this was. Particles maybe? Maybe not... Please help
Built to Last
Advertisement
There is the radial blur effect in one of the last lessons...but something like that usually isnt practical. You could use quads with a reduced alpha value and draw a whole bunch of them with some sort of texture on it. That would be fast and if you knew where the coulds opened up would be effective. I think, however the only realistic way to get this to work is to use ray tracing...but its probably not going to be fast.
Raytracing would be good, but definately NOT realtime. Though, maybe for your application it is enough to compute some raytracing "offline" and use it in realtime then (in a static model) assuming that the sun and the clouds never move.
You have basically two possibilities: render the real thing (volume rendering) or fake them.

Rendering real lightbeams involves either raytracing (very nice but slow, although it can be done in realtime on smaller resolutions) or image space volume rendering with shadow projections (realtime, there was a thread about that on the graphics forum not long ago). Both methods produce ecxellent results, even if the camera is near or inside the rays, but are pretty complex, and certainly don't classify as 'simplest ways'.

The other alternative is to fake them. Which looks horrible, when the camera is near the beam (or even inside), but which can look pretty good, if the camera is always far away. In the case of sunrays through clouds, the camera will always be reasonably far away, so a fake beam effect can look very nice.

Here again, you have several possibilities. A common one is to render the lightshafts as normal geometry, using additive blend. Most of the time, this will create problems with the zbuffer and drawing order, and will look rather fake. But it's very easy, if the light shafts are simple (eg. lightbeam shining through a rectangular window).

Another approach is using a simple 2D layer. Position a quad, shaped like a trapezoid, over the screen. It should be aligned to the approximate height where the sunrays start, just beneath the clouds. And it should reach down to the ground. Now either draw the lightrays directly onto a 2D texture (or use some kind of automatic algorithm for that) or better, use a 1D texture stretched all over the quad. The 1D texture contains the opacity values of your clouds, a 1D slice through your clouds at the approximate position of the light ray exit point.

You can add some gouraud colour and alpha on the trapezoid, and modulate with the ray texture, so that you can fade them out as they move towards the ground. Or perhaps change their colour.

/ Yann

[edited by - Yann L on November 4, 2002 5:36:29 PM]
yeah. a week or so ago I posted a thread on a method for light rays I had whipped up the night before...

the thread

<-- smile :-)

Project-X

This topic is closed to new replies.

Advertisement