EACam
Warrior
154 Posts |
Posted - Apr 24 2004 : 09:21:23 AM
|
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
|
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.
|
|
|
EACam
Warrior
154 Posts |
Posted - Apr 24 2004 : 3:10:59 PM
|
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? |
|
|
game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Apr 24 2004 : 3:28:48 PM
|
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 |
|
|
Mantastic
Neophyte
2 Posts |
Posted - Apr 24 2004 : 6:11:14 PM
|
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. |
|
|
EACam
Warrior
154 Posts |
Posted - Apr 24 2004 : 6:19:57 PM
|
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. |
|
|
EACam
Warrior
154 Posts |
Posted - Apr 24 2004 : 6:22:39 PM
|
translated? I've heard of transformed, but not translated. I'll check out that tutorial... thanks
|
|
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Apr 24 2004 : 6:58:49 PM
|
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? |
|
|
EACam
Warrior
154 Posts |
Posted - Apr 24 2004 : 8:14:27 PM
|
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! |
|
|
EACam
Warrior
154 Posts |
Posted - Apr 24 2004 : 8:16:52 PM
|
Has anyone ever done this before? I've never seen lighting in anyone's 2D VB game. |
|
|
Brykovian
Bryk the Cheese Slayer!
USA
58 Posts |
Posted - Apr 24 2004 : 9:36:51 PM
|
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 |
|
|
Spodi
Warrior
USA
142 Posts |
Posted - Apr 24 2004 : 11:33:11 PM
|
"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 |
|
|
cjb0087
Knave
Australia
76 Posts |
Posted - Apr 25 2004 : 7:58:19 PM
|
you could always use lightmaps, since the only light kinds i think you would be using are point and ambient |
www.bugsplat.tk |
|
|
EACam
Warrior
154 Posts |
Posted - Apr 25 2004 : 8:51:15 PM
|
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 |
|
|
EACam
Warrior
154 Posts |
Posted - Apr 25 2004 : 9:15:40 PM
|
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. |
|
|
Spodi
Warrior
USA
142 Posts |
Posted - Apr 25 2004 : 9:42:50 PM
|
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 |
|
|