Sign in to follow this  
ade-the-heat

shaders to do light glare

Recommended Posts

Hi I'm not looking for the precise specifics but how would you do a glare from a spotlight. What I mean is that if you look at the spotlight (sp.) directly not only is it a bit blinding but you can't see anything around the spotlight egdes. eg |------------------| | _ _ _ _ | | | | | | |sp. | | | - - --- | | glare around sp. | |------------------| [tried edditing the above but can't align the edges- meant to be a square for the spot light and a rectangle around the spot to represent the glare.] So how would I do that ? Obviously doing a shader for the sp. I could do a bright glare if the camera was looking straight on - but what about around the edge ? Also, could you do this without a shader ?

Share this post


Link to post
Share on other sites
I haven't tried this, but you could use a texture as in a lightmap that resembles the glare around the spotlight and billboard it at the spotlights location. And then you could use alpha testing with blending to get the desired amount of blocked viewing around the spotlight. If you wanted to if you aren't using shaders, you could try using emissive lighting on that area to do a cheap effect, or if you want really bright you will probably need HDR...

Share this post


Link to post
Share on other sites
If I understand you well,

I would suggest the following ( it works in fixed function, too ) :

Draw a high-definition sprite representing the light source (a bright light) in your favorite image editor. This image should use alpha channel to softly specify the transparency, as MARS_999 rightly suggested.

In OGL, draw the texture (generated from the image saved) as if it was a sprite (billboard).

The tricky part is : draw it bigger as it reaches the center of the screen. Indeed the more it gets to the center, the more you look at the spotlight.

This could do the blind-effect, and should react quite good.

One more thing : you have to take the vector of the spotlight direction in account to determine the size of the sprite.

So basically you have :

- choose a minimum size and maximum size for your sprite.

and, for each frame :
- Determine the size of the sprite according to the distance between the spotlight center and the center of the screen (post-projection screen coordinates).
- multiply this distance with the dot product (normalized vectors) of the eye vector and light vector (spot light vector, not vector from light to eye!)

JF

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this