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
Next Page
Author Previous Topic Topic Next Topic
Page: of 3

EACam
Warrior

154 Posts

Posted - Apr 24 2004 :  09:21:23 AM  Show Profile  Reply with Quote
Well...seing as Lucky's forum is having issues...I'll just post here for a while .

I had this same question on lucky's forum...but with little informative feedback...so now i'll try again considering i've done a bit more...

I tried to adapt the "introduction to lighting" tutorial by Jack Hoxley for DX8 (at DirectX4VB obviously) to work with my 2D game. So far I've been able to:

Apply the geometry to my vertices using an UNLIT vertex format.
Set the ambient light color
Add a light (i'm currently only adding a directional light)
Enable the light
Eenble DX8's lighting engine
Set the vertex shader to the unlit vertex format

and what do i get????


A BIG BLACK SCREEN!!!

I have a few things that aren't using the unlit vertices...so I set the vertex shader to FVF_UNLIT...draw the tiles which use unlit vertices (and yes...i've supposedly set their normals to the correct thing...0,0,1 as i think it should be for 2D). Then I switch the vertex shader back to FVF_LIT and draw the rest of my stuff which is showing up fine...

I have a background surface (not texture) and at one point I could actually see black tiles rotating on that surface. I thought it was because the lights weren't working that the tiles were black. I realized I had forgotten to set the vertex shader to FVF_UNLIT before drawing those...so now i've done that and I don't see ANYTHING.

Any help??? Normals are confusing me to death.

Does anyone have any sample code i could look at for lighting in 2D (NOT 3D!!!!)?

Thanks a bunch.

Eric Coleman
Gladiator

USA
811 Posts

Posted - Apr 24 2004 :  09:37:39 AM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
The problem sounds like it a bunch of different things going wrong. You need to start eliminating some possible errors. For example, instead of using 0,0,1 as a normal, try 0,0,-1.

There also must be something wrong with how you have the lighting system setup because ambient light should illuminate your scene regardless of any lights that are created. You said you enabled the light, but did you enable lighting in general? Something like .SetRenderState D3DRENDERSTATE_LIGHTING, True. Also, if you draw LIT vertices, you have to disable lighting, .SetRenderState D3DRENDERSTATE_LIGHTING, False.

Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 24 2004 :  3:10:59 PM  Show Profile  Reply with Quote
Ok...I have tried using a normal of 0,0,-1, but I guess if nothing is else is working anyway, then I can't say that didn't work. I'm getting that normal from the CreateTriangleNormal function by Jack Hoxley, so I think that it's right. At the moment I'm just setting all the vertices to have the same normal.

Ok...i'll try a little more process of elimination. It's funny but my objects using lit vertices were showing up even though I had forgotten to disable lighting...hmmm. I'll look at it all closer.

Thanks.

P.S. Any sample code?
Go to Top of Page

game_maker
Knave

Saudi Arabia
83 Posts

Posted - Apr 24 2004 :  3:28:48 PM  Show Profile  Visit game_maker's Homepage  Reply with Quote
Hi

are you using translated vertex ,,, you may need to manualy translate your vertex by orthogonal projection becouse we don't know for sure what happaning inside DX

and yes logis sais it doesn't matter (true ,, but still not 100% sure )

i wrote a tutorial for this for just 2 weeks : http://www.axdteam.com/vb/download/dxg5.zip
Go to Top of Page

Mantastic
Neophyte

2 Posts

Posted - Apr 24 2004 :  6:11:14 PM  Show Profile  Reply with Quote
I'm not too helpful, but have you applied a material to the scene(or whereever they go again...it's been awhile since I've programmed)? I recall that was my black screen problem.
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 24 2004 :  6:19:57 PM  Show Profile  Reply with Quote
Actually, that would have been really helpful if I had forgotten to do it, becuase you're right: it's absolutely necessary from what I hear.
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 24 2004 :  6:22:39 PM  Show Profile  Reply with Quote
translated? I've heard of transformed, but not translated. I'll check out that tutorial... thanks

Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - Apr 24 2004 :  6:58:49 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Well, what's different between your lighting code and the code from Jack? Did you copy and paste? and do you have Option Explicit at the top of every module, form, and class?
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 24 2004 :  8:14:27 PM  Show Profile  Reply with Quote
Yup...well, seeing as Jack's tutorial is for 3D, there's quite a lot different. I don't have an presentation matrix (or whatever), no Z buffer, etc.

The weird thing is, unless i missed something, but it seems that in Jack's tutorial, he disables lighting in the init code. And it still works...i don't know, maybe he turns it on somewhere else, I don't know.

Option Explicit? I've never programmed without it!
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 24 2004 :  8:16:52 PM  Show Profile  Reply with Quote
Has anyone ever done this before? I've never seen lighting in anyone's 2D VB game.
Go to Top of Page

Brykovian
Bryk the Cheese Slayer!

USA
58 Posts

Posted - Apr 24 2004 :  9:36:51 PM  Show Profile  Visit Brykovian's Homepage  Click to see Brykovian's MSN Messenger address  Reply with Quote
quote:
Originally posted by EACam

Has anyone ever done this before? I've never seen lighting in anyone's 2D VB game.


I believe the Safrosoft boys put lighting into ROX ... you might try to Google up where Dmitri's hanging out these days and drop him a note. (Good luck ... just spent 10 minutes on Google and didn't have much luck ...)

-Bryk

www.mwgames.com
Go to Top of Page

Spodi
Warrior

USA
142 Posts

Posted - Apr 24 2004 :  11:33:11 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
"Has anyone ever done this before? I've never seen lighting in anyone's 2D VB game."

Really? There's plenty out there. That is, unless you mean without using DX8, then theres just a few...

vbGORE
Go to Top of Page

cjb0087
Knave

Australia
76 Posts

Posted - Apr 25 2004 :  7:58:19 PM  Show Profile  Visit cjb0087's Homepage  Reply with Quote
you could always use lightmaps, since the only light kinds i think you would be using are point and ambient

www.bugsplat.tk
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 25 2004 :  8:51:15 PM  Show Profile  Reply with Quote
what's a light map? and how do I use it?

You say it's been done Spodi...example?

Edited by - EACam on Apr 25 2004 8:53:20 PM
Go to Top of Page

EACam
Warrior

154 Posts

Posted - Apr 25 2004 :  9:15:40 PM  Show Profile  Reply with Quote
Oh, and it might be useful to tell you that when I enumerate, it seems my Max Active Lights = 0. I know that -1 means unlimited, and > 0 means that's how many. But what about 0? Does that actually mean I can't have ANY active lights? I'm pretty sure it's not an error in my enumeration, becuase on my friend's computer, he gets -1 (unlimited; and his computer is older than mine). I KNOW that i've seen lighting. In all of Jack's tutorials, lighting works fine. In all the games I've played, lighting works fine.

My enumeration also says I don't have gamma correction support...though I KNOW i've done it in DD on my comp. I'm clueless.
Go to Top of Page

Spodi
Warrior

USA
142 Posts

Posted - Apr 25 2004 :  9:42:50 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
Well depends, do you mean verticy-based lighting? There's lots of 2d games that do that, such as ORE and DXRE. If you mean hardware lights (like in the DirectX4VB tutorials), I cant recall any projects off the top of my head, but I believe I've seen it before.

As for the Max Active Lights = 0, you sure you enumerated it correctly? Or did you enumerate the correct device?

vbGORE
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000

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