Lighting effects in OGL-iso
Hi,
I need some decent light effects to my engine. I know this
type of topics has been gone through here many times before,
but I haven't yet found a solution to implement lights to
iso-engine that would work for me.
I'm looking for a method to do Diablo 2 -type of lights,
meaning: SMOOTH, COLORED, BEAUTIFUL.
Here's part of my simple map structure:
class maparray
{
public:
int tile[4];
int spr[4];
...
int light_intensity;
...
};
My engine uses OGL. My current light implementation is
tile-based lights with vertex coloring. Each tile has its
own light_intensity -value. Light vertices blend together
(reading the neighbor tile light value) so that one can't
see the lighting is tile-based due to the smoothness, BUT
because of the nature of tile-based lights, the light
co-ordinates aren't fixed so if I move the light, it moves
in steps between tiles. Yes it works, but I'm far from
satisfied.
The lights don't interact with each other correctly. I had
to write a terrible hack just to make the lights blend with
each other, not ignoring each other's values.
For that, I have two different light tables:
unsigned int ltable1[width*height],
unsigned int ltable2[width*height].
I use ltable2 as a temporary storage for light values,
where I write a light before I throw the values to the map
array itself.
After the values are written into ltable2, I take the
average values like this:
avg = (int)(ltable1[] + ltable2[]) / 2.
Then I write the ltable2 to ltable1, so that it has the
just written light storaged there. The I copy the avg
value(s) to the map array like this:
for(...) Map[layer][y][x].light_intensity = avg;
---
Man, don't you just hate this? I know I do.
Any ideas how to make GOOD and REAL lighting effects
(that look good)?
I have checked Razorblade's dynamic lighting method, but
I can't implement it to my engine since my engine is
pure 2D (I don't have the vertex data stored in anywhere).
---
class PLight
{
public:
int x, y;
int radius;
void Set(int X, int Y, int rad);
};
---
That looks clean and simple, but ...
I'm a bit lost here. Help?
Thank you for your time.
saeZ
Edited by - saeZ on January 14, 2002 4:59:53 AM
All you need to do is add the values of each channel for your lights! If there are three lights; A, B, and C; and you want to light tile X, then:
X.r = A.r + B.r + C.r
X.g = A.g + B.g + C.g
X.b = A.b + B.b + C.b
Of course, you''ll want to have some sort of check so that you can''t add beyond the maximum value. Remember that for an unsigned char 255+1=0!
X.r = A.r + B.r + C.r
X.g = A.g + B.g + C.g
X.b = A.b + B.b + C.b
Of course, you''ll want to have some sort of check so that you can''t add beyond the maximum value. Remember that for an unsigned char 255+1=0!
D''oh.. shouldn''t of used that "!" icon on my posting. That was stupid of me. Oh well...
Thanks for the reply TerranFury. But what I really want to know is how to do lighting effects in farely advanced yet still easy way. If I have a pointlight class, I would like to add lights where ever I want. I know how to do that, believe me. But what I''m thinking is how to DRAW the actual light. I already have tile-based lighting. I know I was unclear in my post, but what I want to know is how to make nice light effects that are NOT tile-based. Tile-based is okay, BUT I can''t move the light without making it jump in 64x32 (my tile size) -pixel steps.
I guess lightmaps are out of the question because I don''t have vertex data stored in anywhere. All the vertices that show on the screen are ALL the vertices there actually is. My OGLiso-engine works just like 2d iso''s work. There''s nothing special about my engine. No actual 3D used at all.
B''hey, how would I make dynamic lighting? Razorblade''s tutorial was good, but it didn''t explain the actual light drawing thing.
Help?
saeZ
Thanks for the reply TerranFury. But what I really want to know is how to do lighting effects in farely advanced yet still easy way. If I have a pointlight class, I would like to add lights where ever I want. I know how to do that, believe me. But what I''m thinking is how to DRAW the actual light. I already have tile-based lighting. I know I was unclear in my post, but what I want to know is how to make nice light effects that are NOT tile-based. Tile-based is okay, BUT I can''t move the light without making it jump in 64x32 (my tile size) -pixel steps.
I guess lightmaps are out of the question because I don''t have vertex data stored in anywhere. All the vertices that show on the screen are ALL the vertices there actually is. My OGLiso-engine works just like 2d iso''s work. There''s nothing special about my engine. No actual 3D used at all.
B''hey, how would I make dynamic lighting? Razorblade''s tutorial was good, but it didn''t explain the actual light drawing thing.
Help?
saeZ
try lightmaps !
draw the OVER the tiles, I used it, it worx
mail me 4 question cause i''m seldom here...
draw the OVER the tiles, I used it, it worx
mail me 4 question cause i''m seldom here...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement