View Full Version : Lighting Flares... how?
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?
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.
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.
02-23-2001, 04: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.
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.
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?
Hello? Anyone out there? Is there a way to get values from the depth buffer?
02-23-2001, 10:53 PM
PHubble, glReadPixels using GL_DEPTH_BUFFER_BIT should work.
Thanks ! I think I'll try it out and see what happens... http://www.opengl.org/discussion_boards/ubb/smile.gif
02-24-2001, 01: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.
02-24-2001, 05: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.
02-24-2001, 06:12 PM
AABB -> Axis Aligned Bounding Box
02-25-2001, 10:26 AM
Alrighty. Makes sense.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.