View previous topic - View next topic |
Author |
Message |
Mandrake elementry school minded asshole
Joined: 28 May 2002 Posts: 1341 Location: GNARR!
|
Posted: Mon Jun 09, 2003 9:56 pm Post subject: fun with lighting |
[quote] |
|
heh, so anyways, I was playing Silent Hill 2, and thought about working on a sort of kick ass horror game engine (2d of course). The main plan will be that there will be a main isometric map for the background, and that map has a light map. Ok, here's the basic rundown of how a lightmap would work:
It works like a regular 2d matrix array (like you would a normal tilemap) but isntead of tile positions, it will store light levels. 255 being completely lit, 0 being compeletely dark. Now, a map will have what's known as a default light level based on where the map is at (indoors/outdoors) and time of day (dawn, early morning, noon, day, evening, dusk, night), which all map positions will autimitically be alloted to.
Then, the game will have lightsource objects (liek for example, a sprite could be a lightsource(lamp, main player, lightning bug, etc), and that has a level of brightness. If it's above the default light level, it will then change the tiles around it to reflect the new light level...getting dimmer farther away from the light source it gets. Also, sprites will have shadows, and the direction of the light source will cast the shadows in diffrent directions.
So, for example, you have a lamp in a corner of the room (to the left), it will cast shadows to the right of all sprites on the map.
Also, all sprites will be lit according to the light level of the tile they are standing on according to the light level map.
I haven't coded any of this yet...but it seems pretty damn feasible....and pretty cool.
I also plan on turning this tile-lib loose on the world for other's to use and also suppkying a game maker so people can either make Parasite Eve style games (with turn based combat, being on the same map, not moving to a diffrent map like how the FF games do it), or a Resident Evil Silent Hill style real-time combat game.
Yup.
|
|
Back to top |
|
|
ThousandKnives Wandering Minstrel
Joined: 17 May 2003 Posts: 147 Location: Boston
|
Posted: Mon Jun 09, 2003 10:26 pm Post subject: |
[quote] |
|
I thought somewhat about something like that, but my major issue is, it can cast shadows OF objects but I cant see how it can properly light the objects themselves.
Darker and lighter pixels, yes, but... I dunno. I'm just not sure that simply changing the brightness level in a sphere around the light source is going to really provide a convincing effect, and I don't think you can get it to do anything more.
I mean, probably the most important element for defining 3-dimensional shapes in 2 dimensions is shadow and highlight, and it takes a good eye to do it right. I dunno if you could write a method for intelligably and aesthetically shifting the shadows around on objects.
At the very least you would have to design the graphics such that they dont use much shading/highlight of their own.
Anyway thats my concern. I'd still like to see someone try, maybe I'm exaggerating the problems, hehe. Good luck.
Wait... actually, you could create an aspect mask for each graphic object, using a different color based on the average direction that most of the stuff represented by that pixel is facing. (N,NE,E,SE,S,SW,W,NW). The engine could draw some vertices between the object and the light sources and use the aspect value to create the shadow/highlight for that point. It would be difficult, but having that data could make intelligent, adaptive shading possible. Aspect models, combined with slope, are how cartographers create hillshades for maps. A similiar technique could be possible in 2D graphics hehe.
So like, you would create a simple character graphic with a flat value for each color, and let the engine shade it for you using the aspect mask.
Sounds like a lot of work though...
|
|
Back to top |
|
|
Mandrake elementry school minded asshole
Joined: 28 May 2002 Posts: 1341 Location: GNARR!
|
Posted: Tue Jun 10, 2003 12:23 am Post subject: |
[quote] |
|
I don't know- i think it can be done realisticlly, but not completely 100% accurately in 2d. I mean, the only major "unrealism" problem I can see is from the veiw point of casting shadows (or light) onto a wall. The fact of creating "spheres of light" around an oject being unconvincing, I'd have to say I disagree with that. After playing a few PSX games that used 2d lighting, it can be very convincing. I can't name a few off the top of my head, but it can work if done correctly.
I don't know about the wall shadows/lighting quite yet...I'm still working on that. And of course you can't get rippled textured lighting (for like, let's say the way lighting runs on clothes, or bumps on a wall...), but the effect would work well enough without it. Enough to create a creepy atmosphere. And the lighting would do more than that, some enemies can avoid light, (like the cockroaches in Alone in the Dark 4), thus making it safer to be in the light....I also want it to cast diffrent light streams for diffrent light sources. For example a torch would cast diffrent light than a flashlight/electric torch, and a lamp would cast diffrent light than that.
I think A good example of the way the light casting would work would be the Sims....(the sims shadow-casting on the other hand, isn't really existant...this game engine would cast better shadows depending on light degree, as well as direction of light. Stronger light will cast longer shadows...etc).
Again, I don't plan on overcomplicating this and getting to the level, of let's say, using vector transformations in order to create a realistic 3d light mapping system in a 2d plane. I plan on keeping it simple (a problem I used to have, and many programmers I know still do have is by overcomplicating things beyond necassity, and then making their projects become vaporware by feature creeping it to death). _________________ "Well, last time I flicked on a lighter, I'm pretty sure I didn't create a black hole."-
Xmark
http://pauljessup.com
|
|
Back to top |
|
|
Rainer Deyke Demon Hunter
Joined: 05 Jun 2002 Posts: 672
|
Posted: Tue Jun 10, 2003 12:46 am Post subject: |
[quote] |
|
Kind of like the lighting in Ultima 6. Completely unrealistic, but nice nevertheless. One issue with the shadows: in reality, as the light source changes, not only the size/direction but also the shape of shadows change. I don't see any way to emulate that in 2D.
|
|
Back to top |
|
|
BigManJones Scholar
Joined: 22 Mar 2003 Posts: 196
|
Posted: Tue Jun 10, 2003 12:52 am Post subject: |
[quote] |
|
I used to think about alot too. An additional feature I want in an iso game is the ability to rotate the view smoothly 360 degrees so 3d locked in iso is the only way to go for that.
I agree with ThousandKnives that it would be difficult to do lighting an the sprites, but what is more important is calculating which tiles are lit at what level at run time. I think on a 1 ghz + computer this probably wouldn't be a problem nowadays, but I read somewhere were one person used precalculated lite maps in a iso game like your talking about; thats the only way he could get it fast enough.
Avernum 3 has some nice lighting in it. Your light doesn't go around corners and there are nice smooth transitions between lit/unlit areas. Much better than the previous Avernums.
|
|
Back to top |
|
|
Jihgfed Pumpkinhead Stephen Hawking
Joined: 21 Jan 2003 Posts: 259 Location: Toronto, Canada
|
Posted: Tue Jun 10, 2003 4:32 am Post subject: Roach Men and Globs of Darkness and Such |
[quote] |
|
I don't know about the general feasibility of the graphics, but from what you've said I think it should be fairly easy to have elements which reduce the light level instead of raising it, and I think this would be really, really cool. Consider your cockroach example: the cockroaches stay in the dark, so keeping to the light keeps the player safe. But then there's the Roach Man who exudes darkness (you can find a better way of putting this, I'm sure), allowing the cockroaches to congregate around him and so attack you (sounds lame in text, but in-game I think it would make a great effect). Kill the Roach Man, the bugs are deprived of their darkness, and they go scurrying for the shadows once again. Then there's the enemy who can fire globs of blackness at you. And so on.
It would add a lot of gameplay depth if you were to implement it, I think. Wouldn't work if the game doesn't have supernatural elements, though.
Will it be real-time? Games tend to be scarier that way, I think, usually, though I guess it could work either way.
|
|
Back to top |
|
|
mandrake*rpgdx Guest
|
Posted: Tue Jun 10, 2003 5:20 am Post subject: |
[quote] |
|
Quote: |
Kind of like the lighting in Ultima 6. Completely unrealistic, but nice nevertheless.
|
NO. as I said before, more like the sims. Not completely unrealistic (like U6- ugh- that was obv unreal), but more like the Sims with smooth transitions and etc...
Quote: |
I used to think about alot too. An additional feature I want in an iso game is the ability to rotate the view smoothly 360 degrees so 3d locked in iso is the only way to go for that.
|
I don't know, the Sims and Diablo 1 and 2 work fine without. I never really saw the big advantage to iso rotation...
other than to create annoying puzzles like in Dragon Warrior 7
Quote: |
agree with ThousandKnives that it would be difficult to do lighting an the sprites, but what is more important is calculating which tiles are lit at what level at run time. I think on a 1 ghz + computer this probably wouldn't be a problem nowadays, but I read somewhere were one person used precalculated lite maps in a iso game like your talking about; thats the only way he could get it fast enough.
|
I really don't think that the sprite lighting will be as big as a problem as you and ThousandKnives think, I've played games that are 2d with dynamic lighting, and unless you are REALLY looking for it, you won't notice it.
The light tile calulation is not a problem. It's about the same amount of time/speed it takes to do a simple A* path finder, since it uses a 2d array, map based lighting system. You don't calulculate while drawing, you pre-calc whenever a change is needed (lights dim, etc), since most of the lighting won't change much. The speed change is almost nil (to the point of where, on faster computers, a slowdown is still necassay, and by faster I mean 300mghz+)
Quote: |
I don't know about the general feasibility of the graphics, but from what you've said I think it should be fairly easy to have elements which reduce the light level instead of raising it, and I think this would be really, really cool.
|
I never thought about this, but it would be really cool :) I'll keep that in mind while coding :) and credit you with that thought.
Quote: |
Will it be real-time? Games tend to be scarier that way, I think, usually, though I guess it could work either way.
|
as I said above:
"I also plan on turning this tile-lib loose on the world for other's to use and also suppkying a game maker so people can either make Parasite Eve style games (with turn based combat, being on the same map, not moving to a diffrent map like how the FF games do it), or a Resident Evil Silent Hill style real-time combat game"
right now this sin't a game, it's an engine. It will be used in games...and free for other's to use.
|
|
Back to top |
|
|
BigManJones Scholar
Joined: 22 Mar 2003 Posts: 196
|
Posted: Tue Jun 10, 2003 10:31 am Post subject: |
[quote] |
|
mandrake*rpgdx wrote: | Quote: |
I used to think about alot too. An additional feature I want in an iso game is the ability to rotate the view smoothly 360 degrees so 3d locked in iso is the only way to go for that.
|
I don't know, the Sims and Diablo 1 and 2 work fine without. I never really saw the big advantage to iso rotation...
other than to create annoying puzzles like in Dragon Warrior 7
|
In my version of The Ultimate RPG I want to have a system were the player can control large columns of soldiers and wizards - basically extending the Avernum combat system into a small, medieval tactical combat simulator. I want to rotate the view to allow the player to see behind buildings and hills. I think that would be really cool!
|
|
Back to top |
|
|
Nephilim Mage
Joined: 20 Jun 2002 Posts: 414
|
Posted: Tue Jun 10, 2003 11:23 am Post subject: |
[quote] |
|
Depending on how you implement your game, you could probably do 2D lighting like this by separating your "ground plane" lighting from the "object" lighting.
Render the ground plane first. Use the 'generic' tile, and then overlay alpha-channeled blackness over it to make pools of light wherever they should be.
Next, render objects into the scene. For this, you would need each tile prerendered with light hitting it from 8 directions. They could even have their shadows baked in, if you're okay with them being fuzzy, indistinct shadows instead of crisp shadows. Just draw each tile from top-down, choosing the version that has the correct direction to the nearest light source. For objects further away from the light source, cut the color values.
Walls would work in this scheme - just don't give them pre-baked shadows, and use a simple LOS to leave tiles beyond walls black.
The problem with this scheme is that it would be difficult to do transitions between well-lit situations and dimly lit situations. (And it's a hell of a lot of tiles to build.) *shrug*
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Tue Jun 10, 2003 3:28 pm Post subject: |
[quote] |
|
Well, the only thing that seems hard with it is getting the shadows right
and speed shouldn't be that much of a problem in mostly static scnes
you can always trade memory for speed, it's amazing how general that
concept is... _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
mandrake*rpgdx Guest
|
Posted: Tue Jun 10, 2003 8:40 pm Post subject: |
[quote] |
|
Quote: |
Well, the only thing that seems hard with it is getting the shadows right
and speed shouldn't be that much of a problem in mostly static scnes
you can always trade memory for speed, it's amazing how general that
concept is...
|
Which is what I'm doing...it's sort of a real time look-up tabel....kind of. Basicly it sucks on the memory but is uber-fast.
Quote: |
Depending on how you implement your game, you could probably do 2D lighting like this by separating your "ground plane" lighting from the "object" lighting.
|
Already have. there will be 2 game maps (well, actually ALOT more than that for some interesting stuff...but for the purpose of this discussion there will be two), each the same size. On that has tile locations, the other light locations.
So, for example, when rendering a tile I would do this:
Render_Background(buffer, tile[map[x][y]], light_map[x][y]);
if the function parameters where this:
Render_Background(BITMAP *drawto, BITMAP *tile, int light_level);
Hope that clears it up (and no- that's not the actual function...hopefully a better illustration of what I'm trying to do...)
Quote: |
Render the ground plane first. Use the 'generic' tile, and then overlay alpha-channeled blackness over it to make pools of light wherever they should be.
|
It would bne less memory expansive, easier to do dynamic tiles, and faster if I just set the lighting according to teh second light map. Then, to change lighting I would just need to lighten, darken the light map at that tile's position. If you think about it, you can see how fast this would be.
Quote: |
Next, render objects into the scene. For this, you would need each tile prerendered with light hitting it from 8 directions. They could even have their shadows baked in, if you're okay with them being fuzzy, indistinct shadows instead of crisp shadows. Just draw each tile from top-down, choosing the version that has the correct direction to the nearest light source. For objects further away from the light source, cut the color values.
|
maybe- but it might slow things down a bit much. And I'm using qaudratic lighting so I don't really need to do this.
Quote: |
Walls would work in this scheme - just don't give them pre-baked shadows, and use a simple LOS to leave tiles beyond walls black.
|
Ok, by shadows and shadow casting I don't mean shadows as in lighting, I mean shadows as in the shadow an object would cast across groung. Like, let's say you have a grandfather clock. If the light was to the right of it, it would cast a shadow across the ground to the left of it, in the generic shape of a clock. (easy to do, just use the pixel mask as a graphic (pixel mask being a mask I use to determine p*p collision...it just turns any non-see through areas black), and then rotate it accordingly). The problem with walls is that a shadow, cast by, let's say a clock, when hitting a wall goes then straight up and down, but still has a shadow leading up to the wall.
Tihs would cause a problem in the current system, as I have been thinking about implementing it.
|
|
Back to top |
|
|
DrunkenCoder Demon Hunter
Joined: 29 May 2002 Posts: 559
|
Posted: Tue Jun 10, 2003 8:45 pm Post subject: |
[quote] |
|
like to show a screenie?
just now Im imagining this quite cool, and it seems like you're using
the obvious approach of having a lightmap the size of the regular
map and having all light drawn to it then combining the two
to get the end result _________________ If there's life after death there is no death, if there's no death we never live. | ENTP
|
|
Back to top |
|
|
omega_alpha Fluffy Bunny of Doom
Joined: 07 Jun 2003 Posts: 16 Location: California
|
Posted: Tue Jun 10, 2003 10:49 pm Post subject: |
[quote] |
|
Its an intriguing idea, but I just don't think it will have the same affect in 2d as it does in 3d. But maybe thats just me :P
|
|
Back to top |
|
|
mandrake*rpgdx Guest
|
Posted: Tue Jun 10, 2003 11:12 pm Post subject: |
[quote] |
|
well, I'm going to try and get shadow-casting to work before I post a screenie :) and also some graphics that are a bit more than placeholder graphics.
and I know it won't have exactly the same effect in 2d as it does in 3d, that's not what I'm going for. But, would you say Resident Evil has good lighting? The backgrounds in those are 2d- and I would say that it (as well as Alone in teh Dark 4- which has excellent lighting effects), use a form of 2d lighting. Not exactly this one, but I do know how both RE and Alone in teh Dark do their lighting, and neither use 3d lighting.
|
|
Back to top |
|
|
BigManJones Scholar
Joined: 22 Mar 2003 Posts: 196
|
Posted: Wed Jun 11, 2003 2:02 am Post subject: |
[quote] |
|
I just remembered a system of casting a shadow on the ground I was thinking of for billboarded sprites on a 3d level:
a bmp of an ellipse with one edge centered below the character bmp with the edge furthest from the character alpha blended out. Either 1. draw it and blend algorithmically; no idea how or 2. prerender 8 of them. Does that make any sense? I'll see if I can make a sample...
Okay heres a shot using my MD2 sprite and an ellipse with MS paint:
|
|
Back to top |
|
|
|
Page 1 of 2 |
All times are GMT Goto page 1, 2 Next
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|