PDA

View Full Version : Lighting Flares... how?



02-23-2001, 02:52 AM
I would really like to try lighting flares in my program. At the moment, I am plotting a large quad around where a light point is (after rendering everything else, disabling depth testing and enabling blending) and it looks fine, but does not disappear when the point light source goes behind an object.

How do I do this without multiple passes? Is there a way to let opengl think that a quad only exists at a point?

Bob
02-23-2001, 03:07 AM
Well, OpenGL does not help you with this. It's about occlusion culling, something you have to do on your own. You can cast a ray from the viewpoint to the lightsource, and determine if the ray intersects any objects on it's way to the lightsource. If it does, the light is not visible and no flare should be drawn.

02-23-2001, 04:47 AM
Is there a way to do this using OpenGL routines? Surely it would know if anything lies under a specific point on the screen, casting rays from my position to every polygon is bound to be very slow.

DFrey
02-23-2001, 05:00 AM
Huh? You cast one ray from eye to flare. Not from eye to every polygon. And you do the intersection tests with only the polygons that could have a chance of being intersected by the ray.

02-23-2001, 05:42 AM
Hi,

I just came back from a drunky night but maybe you could use the depth buffer.
I don't think it is a good idea but,
-you can put a point at the light source location.
- you can know the z value of your light source.
- you can know where your point light is projected in 2d space
- you can extract value from the depth buffer...
compare the two value if the actual value is greater (or lower i don't really know what is stored in the depth buffer) than yours point light draw your quads.

I have never tested this, i don't know if it could work and consequently i'm very interrested by explains about this.

02-23-2001, 07:14 AM
Sorry, (it must be getting a bit late!), only one ray needed. How can you test whether it intersects a polygon? And, how do I get a value from the depth buffer?

02-23-2001, 06:56 PM
Hello? Anyone out there? Is there a way to get values from the depth buffer?

Tim Stirling
02-23-2001, 11:53 PM
PHubble, glReadPixels using GL_DEPTH_BUFFER_BIT should work.

02-24-2001, 12:22 AM
Thanks ! I think I'll try it out and see what happens... http://www.opengl.org/discussion_boards/ubb/smile.gif

Spark
02-24-2001, 02:10 PM
the way most engines do it is by casting a ray from the camera to the lightsource and check for intersecting polygons. It's not very slow if you don't use a huge number of lights and use some kind of culling algoritm (bounding spheres, AABB). in raytracing you have to do it for "every pixel"*"every polygon" - slow.

Kranomano
02-24-2001, 06:19 PM
About raytracing... could you point me to a tutorial or doc about that? Or just give me an equation I can use to figure out if a specific point is on a triangle. And what's AABB? Thanks.

DFrey
02-24-2001, 07:12 PM
AABB -> Axis Aligned Bounding Box

Kranomano
02-25-2001, 11:26 AM
Alrighty. Makes sense.