PDA

View Full Version : Light Flares



NecroDOME
26-05-2005, 03:22 PM
I there,

When im rendering me scene, i want to add flars on the point where a light is. The flare needs to be visible only when the light point is visible.
I could do a collision check on the geometry beteen the camera point and the light point, but i think it will be slow with a complex scene and a lot of lights...

Mayby I could get a point in the backbuffer end with that information draw the flare ??

Clootie
26-05-2005, 04:24 PM
http://developer.nvidia.com/docs/IO/8230/D3DTutorial0_Intro_And_Features.ppt
This requires Occlusion queries support for your vid card. GF3 and up suport it; Radeon 8500 and up (IIRC).

There is another method (without occlusion queries and back buffer locking) ->

3) An alternative is to render just the Z buffer of the scene around where
the test point is to a small texture, then render your test point as a white
dot (say 2x2). You then stretch that texture and modulate with the flare.
IIRC there's a full paper and/or sample code describing the technique on
either the nVidia or ATI site.


Simon O'Connor
Creative Asylum Limited
www.creative-asylum.com



If your hardware has reasonably flexible render to texture, you can do this kind of effects quite easily, without using any
readbacks.

Render a poly with Z test disabled over the area you are interested in sampling into either destination alpha, or an offscreen
buffer using the screen Z buffer. Set the alpha to 0.

Render the same poly with Z test enabled at the Z of the sun/light. Set the alpha to 255 (or 1.0, according to API :).

You should now have an alpha mask of the visible areas. Using a bilinear filter you can progressively shrink this down to a single
pixel (thus getting an average coverage value), and then use the resulting pixel as a texture to render into the alpha component of
your flare texture. Or you can do as Chris mentions, and blur it outwards to create the illusion of shafts of light, though you'd
probably want to layer up a few sprites tested at different Z's to give it some depth.

Pretty simple effect if your hardware can do it, but extremely effective

Jason G Doig

NecroDOME
26-05-2005, 04:41 PM
Cool.... ill try it tomorrow :)

thnxz