delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/28/05:08:08

Message-ID: <D1FB30BBA491D1118E6D006097BCAE392DBB06@Probe-nt-2a.Probe.co.uk>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: Real-time lens flares w/ Allegro?
Date: Tue, 28 Apr 1998 10:04:14 +0100
MIME-Version: 1.0

Demandred writes:
> I started out by drawing some sprites - bright in the middle, 
> fading to dark at the edges.  Besides looking canned, they 
> actually darken the background around the edges when blitted 
> draw_trans_rle_sprite()) at a constant alpha. Not pretty.
>
> So I put it to you, O gurus: how can I do real-time lens flares 
> with Allegro?  

Lensflare is an additive effect: a black flare value should leave 
the original color unchanged, while lighter flare colors will 
increase the brightness of the screen color. To do this in Allegro,
you will need to make a custom mapping table (using the
create_color_table() function). In your blender function callback,
just add the two rgb values, clamping to white if the result 
overflows.

If you can't afford the memory for an extra mapping table, you can
get fairly decent effects using normal interpolating translucency,
if you draw the flares using very pale colors and not too solid.
I have to do them this way on the N64 at work (it doesn't support 
additive color), and it doesn't look too far off as long as you
use sensible source images.

In terms of making things look nice, the important thing is not to
overdo it: make the flares quite subtle. Position them at irregular
intervals along your light vector: tweaking these numbers can make
a big difference to how smoothly they move as the light source moves
around the screen. If you can do variable translucency levels (by 
using a truecolor mode, multiple color mapping tables, or different
versions of the flare graphics), try fading out the alpha as the
light source moves towards the edges of the screen.


	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019