Jump to content
  • Advertisement
Sign in to follow this  
horizon981

OpenGL Making a Light beam

This topic is 4524 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 want help making a Light Beam. If you have seen sunrays coming through dense clouds, you know what I am talking about. You don't only see a finite ground surface lit , but the light rays are also visible ( like a torch in a dark room). This by the way, doesn't happen in normal OpenGL lighting. Where should I start?

Share this post


Link to post
Share on other sites
Advertisement
You might want to look for the techniques used in rendering "caustics". They're the beams of light that are visible underwater. They look similar but are caused by a completely different mechanism. There's two parts to rendering them; one is the texturing of the bottom of the water & the objects in it with the patterns of light. This is probably less useful; although there may be applications in getting the cloud shadows to drift over the landscape.

The other is in rendering the vertical "beams", which is probably more appropriate. The beams you're after are actually a little simpler, since they have a common origin point (the sun) rather than bending in different directions.

I'd guess something like a 1 dimensional texture which gives you your alpha blend across the beam (they're fainter at the edges) and a yellow rectangle, aligned with a vector from the sun, turned so the rectangle faces the camera.

Working out how to place them could be interesting; one option could be to render the world from the sun's viewpoint into a small offscreen buffer and test points to see if a ray projected to that point hits clouds or ground.

Share this post


Link to post
Share on other sites
Most games just use a billboard, or imposters or whatever they call it. A simple texture that always faces the viewpoint.

Here's a shot from Call of Duty2, light beams shinning through bullet holes in a tunnel. They're just simple textures.
http://img.photobucket.com/albums/v89/donuts/cod_lightbeams.jpg

You could use shaders, but it's a bit overkill for a simple task.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!