GPWiki.org
GPWiki.org
It is currently Wed May 22, 2013 1:37 pm

All times are UTC




Post new topic Reply to topic  [ 67 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Day/Night Lights
PostPosted: Sat Jan 22, 2005 7:07 pm 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
Hello everyone,
I've searched all over the net but can't find an answer to this question :confused

What I want to do is create a day/night effect were if the player has a torch, or some other source of light, it will light up the area around him. I tried using alpha blending, but no matter how much I optimized it, it still ate up the FPS. An example of what I want is StarCraft's Fog of War.
If it helps, I'm using DirectX7 in 640x480x16 screen mode.

Thanks for taking the time to read this 8)

P.S. This would also be needed for stuff like lava, were a tile or tiles light up the area around them.

VBStrider


Last edited by VBStrider on Sat Jan 22, 2005 11:47 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 7:22 pm 
Also known as "Lucky"

Joined: Sat Aug 07, 2004 9:22 pm
Posts: 5853
Location: Vancouver, Canada
Are you talking DirectDraw or Direct3D?

And is this a tile-based game, FPS, isometric..?

More info please :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 8:42 pm 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
DDraw/D3D hybrid engine
Tile-based RPG
2D

Let me know if you need more info :)

VBStrider


Last edited by VBStrider on Sat Jan 22, 2005 11:47 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 9:05 pm 
Level 22 Norse Warrior-Librarian
User avatar

Joined: Fri Aug 20, 2004 1:58 pm
Posts: 538
Location: UK
When I did lighting a few years back in dx7 I used a seperate surface as a 'light map' surface, which was drawn down over the rest of the screen.
Used .lROP = &H8800C6, but it was hacked in at quite short notice so I don't know what it'll do with coloured light.

Anyway, it was simple enough - just drawing shapes onto the surface where it would be bright (as normally the level was dark). It was used for a night effect. For a glow around objects during daytime i'd just blt something over them with a different raster op.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 9:35 pm 
Also known as "Lucky"

Joined: Sat Aug 07, 2004 9:22 pm
Posts: 5853
Location: Vancouver, Canada
Well if you're using D3D, can't you just use a point light at the location of the torch?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 9:57 pm 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
That will be a problem, since lava tiles and town lights etc. will also need lighting.

AT: I tried that, but the colors got messed up.

Invisible


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 10:16 pm 
Sir Postalot
User avatar

Joined: Thu Aug 26, 2004 4:34 am
Posts: 2498
I will second the motion and suggest you employ the D3D lightining. That's what it's there for. If you're trying to get the neat lighting effects you used to see on isometric RPGs like on the SNES, realize they usually relied on pallette tricks to make it work right. You [i]can[i] do that if you really want to, but frankly, if they had the hardware, those game developers likely would've rather used a proper lighting engine. ^_^


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 10:24 pm 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
I think a better example of what I want is Tibia. But about the lights, I'm under the impression that after adding 2 or so lights your FPS will go down the drain, this is why I've never used them.

VBStrider


Last edited by VBStrider on Sat Jan 22, 2005 11:48 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 11:12 pm 
Also known as "Lucky"

Joined: Sat Aug 07, 2004 9:22 pm
Posts: 5853
Location: Vancouver, Canada
Well, the fastest way to do it (frames/second-wise) would be to have different sets of tiles for the different lighting conditions. The modified tiles could be generated by using some kind of per-pixel lighting algorithm, but they'd only need to be generated once (when the level loads, for example).

So, for example, you've got some lava going through a bunch of grass tiles. When the level loads it realizes this, and creates some temporary in-memory versions of the grass tiles that have "lava glow" added in.

For torchlight, every tile would need to have a few different versions of itself stored in memory. One for if the torch is directly adjacent (bright), one if the torch is two tiles away (less bright), and so on into darkness.

Basically, you'd be using more RAM, but gaining real-time speed.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 11:13 pm 
Also known as "Lucky"

Joined: Sat Aug 07, 2004 9:22 pm
Posts: 5853
Location: Vancouver, Canada
Or, you could use a hybrid approach :) For lava glow and for day/night effects, use the method I described above.

For dynamic/moving lights (such as the torch) use a D3D point light.

Since you will probably only have 1 torch (?) it surely wouldn't be much of a performance hit.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 11:46 pm 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
I considered that, but then I'd need roughly 20 diffrent versions of each tile for just changing from day to night, not to mention lighting effects.

There are more torches, yes. Every player might have one, so that's possibly 4 lights all in your viewing area.

:confused

VBStrider


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 11:52 pm 
Also known as "Lucky"

Joined: Sat Aug 07, 2004 9:22 pm
Posts: 5853
Location: Vancouver, Canada
You definitely need to look into D3D lighting then.

For day/night it shouldn't be too hard... you'd just increase/decrease the ambient lighting. And for torches you'd use point lights. Lava... I'm not too sure about.

But anyway, D3D lighting shouldn't be slow. A few point lights will not kill your fps if you implement them correctly!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 5:22 am 
P2k
User avatar

Joined: Mon Aug 16, 2004 1:47 pm
Posts: 2131
Have you giving c++ a try yet? C++ is much quicker and powerful then vb.

Im haveing problems with it, but im sure its just me.

_________________
http://www.moon.templarian.com/


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 5:24 am 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
I'm eventually going to convert the code to C++, but I want to get a few things finished first.

VBStrider


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 7:01 am 
Obfuscation Ogre
User avatar

Joined: Fri Nov 05, 2004 2:32 pm
Posts: 306
Location: Eastern Europe
As far as I know Starcraft uses some raster operations, but you can easily get the same result with the hybrid engine. You can create a tile-dimensioned surface, filled with black (probably create this tile in MSPaint) and then draw it with different opacity onto screen - to get the Fog of War effect. I haven't thought about the algorithm, but I don't think it would be too hard. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 4:42 pm 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
I've already tried alpha blending, it simply makes the surface look washed-out.

VBStrider


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 5:22 pm 
Obfuscation Ogre
User avatar

Joined: Fri Nov 05, 2004 2:32 pm
Posts: 306
Location: Eastern Europe
But you were going to make fog of war effect, weren't you? It looks wash-out - that's typical of "terra incognita" (unexplored or unlighted land). ;)

P.S. If you want to make the tile lighter try changing the blank surface's color to white. Then you'll be able to make an artificial light of any color by changing the RGB parameters. :spin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 6:48 pm 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
No, I don't want fog of war, I want a day/night effect and a darkness effect for caves. When I tried alpha-blending, the light areas look washed out because it's a white circle being drawn. Alpha blending also does not work because I will need the light circles to combine without any problems.

VBStrider


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 8:19 pm 
Obfuscation Ogre
User avatar

Joined: Fri Nov 05, 2004 2:32 pm
Posts: 306
Location: Eastern Europe
Sorry, was distracted as you mentioned StarCraft. :spin

I also wonder if we understand the same thing under alpha blending. There are two parameters in DrawSurface sub of hybrid engine (if you didn't modify it): ABOne and Alpha which have different effect. As far as I remember from Lucky's tutorials ABOne is similar to SrcAnd raster operation and that is called alpha blending. I meant you could use Alpha parameter.

If I'm mistaken and you're already using Alpha parameter I probably didn't understand what you really want: either tile-based lighting (as in StarCraft) or independent ideal circle-shaped light?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 8:35 pm 
Gamer Geek

Joined: Mon Aug 16, 2004 3:51 am
Posts: 33
The hybrid engine I am using is something I created myself, but anyways, yes, I've tried AlphaOne, but it didn't quite work.... Here are sceenshots of the diffrent tests:

Lighting Image:
Image

ROP Light:
Image

Alpha Blending Light:
Image

Alpha One Light:
Image

VBStrider


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 67 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group