Archived

This topic is now archived and is closed to further replies.

Dino

Advanced Lighting Effects

Recommended Posts

Dino    172
Recently there was a post on doing simply lighting effects that didn''t take into account clipping. Various methods were proposed and they were all good. Now I would like to ask the various isometric gurus: How do we implement a more sophisticated lighting effect that takes into account obsticles. I''m thinking that the same algorythms that are used for precise line of sight and be applied to lights... they just run slow. Any opinions? Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Share this post


Link to post
Share on other sites
tployaert    122
I think you can build a D3D surface apart, build walls and ground (need to have some 3d infos about your background),apply some light, transform the result in alpha channel and apply it onto the destination surface via alpha blending operation ...
Fast and simple, I think ...
I have to test this way when I have time.

Thierry

Share this post


Link to post
Share on other sites
Dino    172
Personally, I would like to stay away from using D3D or OpenGL (or any 3D library). I''m would like to see what kind of ideas we can come up with without using any 3D library. Let''s try and stay 2D for now

Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Share this post


Link to post
Share on other sites
GalaxyQuest    122
Hi Dino. You pose an interesting question and i am very glad you wish to keep this topic 2D only. Let me also say i am no lighting guru nor have i had a chance to implement your previous lighting example from the Ultima Online lighting messages.

With that said let me explain an idea i had quickly thought up. Using the example from the UO messages u suggested a map where at certain points colors from light source where added to the background ambient color. End result would be spheres of light sources mapped onto screen.

Example: a torch is placed on a wall. with previous example the player would see light no matter where he was and the light would also not be clipped by the wall.
Your question has 2 parts to be solved. First the player needs to be taken into consideration and secondly, objects need to be considered.
I could go on and on..so let me make this quick: For the player part you would have to include possibly another attribute to areas..like "inside" or "outside" or somehow when you are creating the light sources you consider where the player is and if that light should even be created.

For the objects clipping light..thats hard. What if you created a mask of some type for each object. This way after you create that first mapping of a light source (its spherical shape) you also blit any adjacent tile masks around this light source there by clipping the light.
This second part is really cheesy and probably not a good idea...but maybe you can massage it to come up with something. You defintely have the smarts for it. 8)




aka John M.
Never give up. Never surrender!



Share this post


Link to post
Share on other sites
tployaert    122
Sure I also want to keep 2D for display but if you consider the lighting problem, it is obviously a 3D problem, you can solve it by casting light yourself and not with D3D but it''s much harder ...
If you find any solution, tell us ...

Thierry

Share this post


Link to post
Share on other sites
Dino    172
You make a good point. The more I think about it, the harder it is to get away from doing some basic 3D. If you want really good lighting effects, I think you''ll have to move into the realm of 3D.

I guess I''ll stick to the basic 2D lighting effect like diablo.

Dino M. Gambone
Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Share this post


Link to post
Share on other sites
Davaris    118
Hi Dino,
I was investigating this topic a couple of months ago. The best 2D lighting
effect Ive seen is in Fallout and Fallout 2. They have the shape
of a hexagon as the light surrounding a lit object. This hexagon
only moves when the player enters the next tile. It is a mask
which gives the varying levels that the pixels on the ground
should be brightened by. This is easy to implement. And I have done this. They also light objects to a certain level depending on how close you are to them.

I think they do it this way:

First when night falls, permanently darken all the graphics in your graphic manager.
You can do this by dividing their RGB values by 2 or 3.

When it is day time you just have to multiply all the RGB values by 2 or 3 to return them to their original values.

Do not try to add or subtract values from the RGB values. This will damage the images.

Now the drawing cycle:

Draw everything that is on the on the floor into an offscreen surface. Those things that would be under your feet if you walked on them.

Then brighten the lit areas on the offscreen surface using the hexagon light mask.
It is OK to add or subtract values from the RGB values here as you are just altering RGB values on the offscreen surface.

Then draw the objects and critters onto the offscreen surface
brightening each object as necessary.
It is OK to add or subtract values from the RGB values here as you are just altering RGB values on the offscreen surface.


It gets more difficult from here on. I am too lazy to do this. If you do it could you send me a copy of the code? I'm too lazy to write it.

This large hexagon mask is composed of smaller hexagon masks.
These smaller hexagons are swapped for other small hexagon masks
when the light intersects another light source or a solid object. If you look closely at the game you will see this occuring. The light intersections are quite beautiful in my opinion.

You can see my engine here with its lighting effects. The path finding is messed up and it has been fixed but I've been too lazy to upload the new version.

http://www.geocities.com/david_moffatt_au/

Dave

Edited by - Davaris on November 5, 2000 6:37:58 AM

Share this post


Link to post
Share on other sites