Archived

This topic is now archived and is closed to further replies.

Nekhmet

20 bucks if know where my lighting went.

Recommended Posts

Nekhmet    132
20 bucks to the first person who can solve this problem. I''m currently porting my engine to use D3D. Things were going OK until I tried supporting multitextured models. The problem is this: the multitextured models are multitextured, but they''re not lit - they are equally bright on all sides. The single-textured models are lit just fine. I discovered that if I remove D3DFVF_TEX2 from set of flags I''m passing to SetVertexShader, the lighting reappears. Of course, that makes the multitexturing vanish. Does anybody have a clue what''s going on? - Josh

Share this post


Link to post
Share on other sites
Moe    1256
I have no ideas what could be causing this, but a few guesses:
1) Make sure your normals are good. When you say it works with just one texture, it makes me think that this is fine.
2) Check to make sure the light was created properly. Again, since it worked with one texture, I can''t see why it wouldn''t work with 2, so this probably isn''t the problem.
3) Check to make sure your renderstates are being set correctly and that lighting isn''t being turned off for some reason when you draw the second texture.

How about posting some of the source?

Moe''s site

Share this post


Link to post
Share on other sites
Nekhmet    132
Okay. I put the source code at this URL:

egenesis.com/bug.txt

Note that the interesting routine is at the bottom of the file.

- Josh

Share this post


Link to post
Share on other sites
Pyabo    124
Er... you can''t just change the D3DFVF flags willy-nilly without also changing your vertex format struct, right? What is the complete set of flags you are passing? And what does your struct look like? Email me and I''ll send you the address you can send my $20 to.

Seriously, post your code. I know nothing about D3D.

Share this post


Link to post
Share on other sites
Nekhmet    132
I honestly don''t know whether it''s allowed to create a FVF with a tex2 field, and then not use the tex2 field. I couldn''t find an answer in the DX8 docs, but maybe I was looking in the wrong place.

The code''s at http://egenesis.com/bug.txt

- Josh

Share this post


Link to post
Share on other sites
Pyabo    124
Here is a good example
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/Graphics/ProgrammersGuide/ProgrammablePipeline/PixelShaders/PixelShaderExamples.asp

Mmmm.... what am I gonna do with that $20...

Share this post


Link to post
Share on other sites
Pyabo    124
No... not allowed. The FVF flags are telling Direct3D what your vertex structure looks like. So if you send it the wrong vertext structure definition, things aren''t going to work. Look at the examples.

Another thing you are doing wrong is that you are using D3DFVF_TEX1 | D3DFVF_TEX2. This is wrong. The D3DFVF_TEX2 flag means you have 2 sets of texture coordinate sets. Don''t use more than one TEX# flag at a time.

Share this post


Link to post
Share on other sites
Nekhmet    132
Pyabo, right on target about TEX1 | TEX2. Send me your mailing address, and I''ll send you the $20. jyelon@egenesis.com

BTW, I''ve noticed that this is a recurring feature of D3D - when I make a mistake, it doesn''t return an error code. Instead, it BSODs, or it garbles the results. Is this a problem with the NVidia DirectX driver, or is it a problem with D3D in general?

- Josh

Share this post


Link to post
Share on other sites
D3DX    122
Lucky, if you got garbage result. When I first was playing with multitexturing I also tried your way D3DFVF_TEX1 | D3DFVF_TEX2 in my Vertex Format and it would restart my computer :''(

Share this post


Link to post
Share on other sites
D3DX    122
Lucky, if you got garbage result. When I first was playing with multitexturing I also tried D3DFVF_TEX1 | D3DFVF_TEX2 in my Vertex Format and it would restart my computer and then screw up my source file hah was definitly a fun error ...:''(

Share this post


Link to post
Share on other sites
Nekhmet    132
Oh, don''t feel too great for me. I''ve been getting 2-3 BSODs a day since I started converting my code from OpenGL to DirectX.

- Josh

Share this post


Link to post
Share on other sites
IndirectX    122
quote:
Original post by Nekhmet
BTW, I''ve noticed that this is a recurring feature of D3D - when I make a mistake, it doesn''t return an error code. Instead, it BSODs, or it garbles the results. Is this a problem with the NVidia DirectX driver, or is it a problem with D3D in general?


It''s a problem with you. Check the ''DX debug mode'' thread to see what you''ve been missing.

Share this post


Link to post
Share on other sites
Pyabo    124
Nekhmet, save your $20 and put it toward an MSDN subscription. All I did was a search on "D3DFVF_TEX2" and read a few blurbs about it, and then extrapolated from your original mail what you might be doing wrong... then when you posted your code that confirmed it.

As for BSODs... what operating system are you working on? This mistake in particular can easily result in an Access Violation, which on Win98/ME will often crash the computer. Even on Win2K/XP you can put the machine in an unusable state because of DirectX. Connecting to the machine remotely and being able to kill processes remotely will help a great deal.

Share this post


Link to post
Share on other sites
Nekhmet    132
I''m using win2k.

I realized after reading some of the comments here that I wasn''t using the debug version of the driver. That may help.

- Josh

Share this post


Link to post
Share on other sites