rendering a ray of light in forest

Started by lobsterman, July 04, 2008, 11:12:13

Previous topic - Next topic

lobsterman

hi folks,

the little family unit and i have started to do some programming for a game with an environmental theme. a cast of insects (a dragon fly, a swarm of bees, mosquitos, praying mantis) interact in a forest scene where we have layers of tree backgrounds drifting past at various speeds.

i would love to add in some occasional rays of light as the sun pierces through canopy. i have tried it with sets of a semi-transparent rays stored as a png, but the results are not that great. is there a way to do this nicer? any help greatly welcome ...

thanks,

princec

That's pretty much the way we'd do it. Maybe you just need to work on the graphic a bit more, blur it a bit, tweak the colour, adjust transparency, etc. What does it look like currently? (Screenie please :))

Cas :)

paco

You can use a polygon to draw the ray and setting the colour at each vertex to make a gradient. That is: draw a polygon with 6 vertex:

a      b       a
        + ---- + ---- +           a = 255, 255, 255, 255
       /             /            b = 255, 255, 255, 170
      /             /
     /             /
  a +             + a
   /             /
  /             /
 /             /
+ ---- + ---- +
a      b      a


Where a and b are colours white fully transparent and white semitransparent.