Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Lighting in 2D using DX8
 New Topic  Reply to Topic
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 3

cjb0087
Knave

Australia
76 Posts

Posted - Apr 25 2004 :  9:57:04 PM  Show Profile  Visit cjb0087's Homepage  Reply with Quote
lightmaps: http://www.flipcode.com/tutorials/tut_lightmaps.shtml
gives a short thing of what they are

it basically takes a greyscale representation of the light on a texture and is multiplied over it

and als try making you device REF, and see what the enum says then


www.bugsplat.tk
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 26 2004 :  10:19:24 AM  Show Profile  Reply with Quote
Ahh, with REF, I can unlimited lights. I've even checked the Caps viewer utility that came with the SDK and even it says i have 0 max active lights.

(oh, and that gamma thing, it was because I was checking CANCALIBRATEGAMMA instead of FULLSCREENGAMMA)
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - Apr 26 2004 :  10:22:17 AM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Since you're creating a 2D game, it might be easier for you to do lighting manually by using lit vertices.
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 26 2004 :  11:28:46 AM  Show Profile  Reply with Quote
I was actually highly considering that...it would be tremendously easy, not very slow, and give me far more control. As of now, I'm thinking i should just calculate what tile the light is in, then determine the distance of all the nearby vertices to the light and light them accordingly. Does this sound like a good method?

Thanks.
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - Apr 26 2004 :  11:46:20 AM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
You haven't really given many details other than it is 2D. You mention a tile in your most recent post, so I'll just guess that the entire map is a tile map? If that's the case, then the smaller your tiles the better the light system will be. Also, you might consider using 4 triangles per tile instead of the traditional 2.

Manual lighting can be really fast depending on how your map is organized. If your map is a 2D array, then I would create a restriction of making lights only effect a certain area. Omnidirectional lights, or spot lights with a short range. Any further suggestions on my part would really be based on speculation on how your tile engine is designed.

Perhaps you can give a few more technical speicifications, such as average map size, tile size, number of tiles displayed on the screen, etc. Also, what kind of lights are you trying to create in the game? Omni, spot, directional?
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 26 2004 :  12:26:14 PM  Show Profile  Reply with Quote
mostly spotlights...the game is a scolling tile game, and there could be any where from 20x20 tiles to 100x100 tiles +. all tiles are 32x32 but the sprites can be bigger or smaller. hmmm, 4 triangles? i'm wondering how i would set that up, i'm not to great in the geometry department.

Go to Top of Page

Spodi
Warrior

USA
142 Posts

Posted - Apr 26 2004 :  5:24:36 PM  Show Profile  Visit Spodi's Homepage  Send Spodi an AOL message  Click to see Spodi's MSN Messenger address  Send Spodi a Yahoo! Message  Reply with Quote
Instead of:
____
xxx/x
xx/xx
x/xxx
/____

Just do
________
|\xxxxx/x|
|xx\xx/xx|
|xxx\/xxx|
|xx/x\xxx|
|x/xxxx\x|
|/______\|

vbGORE
Go to Top of Page

VBBR
Moderator

Brazil
617 Posts

Posted - Apr 26 2004 :  6:34:12 PM  Show Profile  Reply with Quote
BTW Spodi how's DXRE going?

Whatever. Who knows...
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 26 2004 :  8:42:46 PM  Show Profile  Reply with Quote
yeah, I knew that much Spodi...sorry, i wasn't very specific, I was refering to using that for lighting and rotating it. I think I'll just stick with 4 vertices.

BTW, What IS DXRE? I downloaded it once, but couldn't figure out what it did. I couldn't do anything except watch identical people walk all over the place. Good graphix tho.

Edited by - EACam on Apr 26 2004 8:44:11 PM
Go to Top of Page

Spodi
Warrior

USA
142 Posts

Posted - Apr 26 2004 :  9:50:13 PM  Show Profile  Visit Spodi's Homepage  Send Spodi an AOL message  Click to see Spodi's MSN Messenger address  Send Spodi a Yahoo! Message  Reply with Quote
Heh, DXRE is mainly just an engine. Most people who use it say they really like it, only problem is there is no documentation or anything, I'm too lazy. I've stopped on it since the last release (2 months ago now I believe) since I started on something else. I'll probably get back into it to finish it off finally during summer vacation. I just kinda got discouraged since I cant update my site (FTP dun work and cant get ahold of my host).

http://mindless.sytes.net/ or http://mindless.dragonbound.com/

But going more then that, sorry EACam, I have no idea. :)

vbGORE
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - Apr 27 2004 :  07:32:59 AM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Spotlights don't look very good on a tiled map. If the light ever gets rotated, then you'll see effects from the Gourard shading. Omni lights work best because their area of effect is always a circle, that makes them easier to manipulate and calculate. Spotlights are generally either ellipses when projected at an angle, and their projected light is generally somewhat constant througout the lit area. If you want to use spotlights, then I would suggest using a lightmap.
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 27 2004 :  08:50:05 AM  Show Profile  Reply with Quote
did i say spot? I totally meant point
Go to Top of Page

Spodi
Warrior

USA
142 Posts

Posted - Apr 27 2004 :  6:37:44 PM  Show Profile  Visit Spodi's Homepage  Send Spodi an AOL message  Click to see Spodi's MSN Messenger address  Send Spodi a Yahoo! Message  Reply with Quote
Okay, yeah, it should be possible to do point lights. Though, I've always had a problem with the lighting - it always looks more like a diamond then a triangle. Say you have this for example (each X represents a tile, the O represents the light origin.)

XXX
XOX
XXX

Okay, so if the middle tile has full lighting (255 argb) then the point(s) of the other tiles that point at the middle have full lighting and the outside points have, lets say 200, it will look like a diamond more then anything. I mainly ran into this problem when trying to apply Fog to DXRE (4 textures, each 1/4 of the screen, using same method as above, ended up looking like CRAP). Theoretically, this should make a circle, or close, right?

vbGORE
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 28 2004 :  09:08:31 AM  Show Profile  Reply with Quote
It should, and i'm almost positive it will. I think your method may be what's causing that. I'm going to do this:

Say, again, the light is O. Now say it has a range of 100. Well, considering my tiles are 32x32, it's range will extend to 4 tiles (1/32=3.1, and remember, if it's even 0.0000001 more than a number, it'll be rounded UP to the next one, since the next tile WILL get SOME lighting.) Ok, so in memory it'll look like this:

XXXXXXX
XXXXXXX
XXXXXXX
XXXOXXX
XXXXXXX
XXXXXXX
XXXXXXX

To ensure ALL lighting is applied, I make sure that the full length is considered in all four cardinal directions (up, down, left, right). Notice the radius is 3, but the diameter is actually 7 (2x3 + 1) because the light takes up one tile, this isn't exactly how it'll look, but text limits what I can draw . Now, some of tiles in the corners of this box will receive NO lighting, but that's ok.
So from here, I simply loop through every vertex of every tile in this box and light it according to its distance from the light using pythagoras' good old theorem. This is the hard part, because "light it according to its distance" is easier said then done. But with a little trial and error, i'll get it looking fine...


I hope.
Go to Top of Page

VBBR
Moderator

Brazil
617 Posts

Posted - Apr 28 2004 :  11:04:43 AM  Show Profile  Reply with Quote
quote:
"light it according to its distance" is easier said then done

I think it's not that hard. you just calculate the distance between the center and the desired point, and then make some calculations.
Check this out:

http://216.5.163.53/DirectX4VB/Tutorials/GeneralVB/GM_Lighting.asp

Whatever. Who knows...

Edited by - VBBR on Apr 28 2004 11:42:37 AM
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.14 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.