Additive Blending / Light Maps

Hello,

I was wondering if there was a really quick way to do Additive blending w/
or w/o light maps. Im not sure if im using the correct terminology so by
additive blending i mean if i have a pixel on a surface that is (50,25,150)
and i want to additive blend that with (30,30,30) i want to replace the
pixel on the surface with (80,55,180).

Right now i have a function that has a double for loop for x and y. Inside
it gets the source pixel (either from the light map or using a constant) and
then gets the dest pixel, blends and writes the dest pixel back.

I know i could do some optomizations like check and see if the source pixel
from the lightmap is completely black not to do the blending, and also
instead of having a double for loop where it re-finds the pixel at x,y i
could get a pointer to the begining of the row on the outer loop and just
use the pointer in the inner loop, but apart from that, is there any real
good techniques to do this?

Thanks a bunch!
Atrix

Behalf Of Atrix Wolfe

I was wondering if there was a really quick way to do
Additive blending w/ or w/o light maps. Im not sure if im
using the correct terminology so by additive blending i mean
if i have a pixel on a surface that is (50,25,150) and i want
to additive blend that with (30,30,30) i want to replace the
pixel on the surface with (80,55,180).

Right now i have a function that has a double for loop for x
and y. Inside it gets the source pixel (either from the
light map or using a constant) and then gets the dest pixel,
blends and writes the dest pixel back.

I know i could do some optomizations like check and see if
the source pixel from the lightmap is completely black not to
do the blending, and also instead of having a double for loop
where it re-finds the pixel at x,y i could get a pointer to
the begining of the row on the outer loop and just use the
pointer in the inner loop, but apart from that, is there any
real good techniques to do this?

If you want to replace on a pixel by pixel basis, I recommend
accesing that information using a pointer… But, if you want
to Blend a square or rectangular area (say, the whole screen),
can’t you just overimpose another surface, but with the ALPHA
channel set to the lumminosity that you want… I haven’t tried
this yet, but it may work… (Event with non-square images, if you
use Color Key with Alpha blending all toghether).
I would be like laying a “transparent color plastic” over your scene.
(Color or white coloured).

Maybe this helps.
Good Luck

Juan Ignacio Carniglia - Programmer - Buenos Aires, Argentina.> -----Original Message-----

From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On
Subject: [SDL] Additive Blending / Light Maps

Hey Juan,

the only problem with that is that alpha blending is different than additive
blending. i know in OpenGL you can change blending modes…i dont know if
you can in SDL but it would be really cool!> ----- Original Message -----

From: juancarniglia@fibertel.com.ar (Juan Ignacio Carniglia)
To:
Sent: Wednesday, August 20, 2003 11:49 AM
Subject: RE: [SDL] Additive Blending / Light Maps

-----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On
Behalf Of Atrix Wolfe
Subject: [SDL] Additive Blending / Light Maps

I was wondering if there was a really quick way to do
Additive blending w/ or w/o light maps. Im not sure if im
using the correct terminology so by additive blending i mean
if i have a pixel on a surface that is (50,25,150) and i want
to additive blend that with (30,30,30) i want to replace the
pixel on the surface with (80,55,180).

Right now i have a function that has a double for loop for x
and y. Inside it gets the source pixel (either from the
light map or using a constant) and then gets the dest pixel,
blends and writes the dest pixel back.

I know i could do some optomizations like check and see if
the source pixel from the lightmap is completely black not to
do the blending, and also instead of having a double for loop
where it re-finds the pixel at x,y i could get a pointer to
the begining of the row on the outer loop and just use the
pointer in the inner loop, but apart from that, is there any
real good techniques to do this?

If you want to replace on a pixel by pixel basis, I recommend
accesing that information using a pointer… But, if you want
to Blend a square or rectangular area (say, the whole screen),
can’t you just overimpose another surface, but with the ALPHA
channel set to the lumminosity that you want… I haven’t tried
this yet, but it may work… (Event with non-square images, if you
use Color Key with Alpha blending all toghether).
I would be like laying a “transparent color plastic” over your scene.
(Color or white coloured).

Maybe this helps.
Good Luck

Juan Ignacio Carniglia - Programmer - Buenos Aires, Argentina.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Atrix Wolfe wrote:

Hey Juan,

the only problem with that is that alpha blending is different than
additive blending. i know in OpenGL you can change blending
modes…i dont know if you can in SDL but it would be really cool!

You can’t, and I agree that it would be cool. Lack of additive blending is
one of the big weaknesses of SDL IMO.–
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com