i think this is a bit of a non-trivial problem:
i´ve got a scene with several objects that represent light sources, like headlights etc. these are not actually openGL light sources, i just bright cubes or whatever. what i want to do is lay a halo effect on each of these light sources: you see this in various games, like you would have a star-shaped flare emitted by a car´s brake lights, streetlights, etc… can also be seen in the N64 game “Perfect Dark” quite frequently
basically, i only need to draw a semi-transparent bitmap overlaid on each lightsource. the problem is, how do i determine where the sources (and IF) they are actually drawn? i must only draw the halo if a lightsource is visible otherwise it looks wrong.
basically, it´s the same problem as with a lens flare, you want to know when to draw the flare because the light source is visible, and when to omit it.
i´ve got one approach, but am not sure whether this might work:
- set a certain value in the stencil buffer if a lightsource is drawn
- set another value if anything else is drawn
- finally, check where there are “source” values in the stencil buffer and draw the halos there.
this might be very slow since i need to directly access the stencil buffer that way.
has anyone some experience with haloing / lens flares, or knows a good net resource?
regards
eik