Lighting Problems

Started by
4 comments, last by Fallen_Angel 19 years, 4 months ago
I'm having some problems trying to set up lighting in my scene. I've just finished going through the Managed DirectX 9 C# book and everything in there seemed fine. If I take the chapter there on loading models and load my model into the scene it turns out fine as shown here. However when I try to create my own project and load my model into it, it isn't quite right, as shown here. As far as I can tell the code is the same for loading the model and setting up the lighting. Also the blue bar in the second picture is actually a cylinder of length 10 and radius 5 so it obviously is not displaying correctly either. I've been going around in circles trying to work this out for the last few hours. Is there anything here that stands out as obvious as to what could be going wrong? Thanks
Advertisement
Did you check your ambient lighting level?
Make sure to pay attention to the materials you're using, also. I see your tanks are colored in the second screenshot. Perhaps you created a new material for those two colors, but left ambient color, specular color, and everything else as zero?

As AP said, you have to have some ambient light to begin with, also. When loading a model's material from a file, if that's what you're doing, the ambient values aren't filled in. The tutorials usually tell you to just copy over the diffuse values as you load the model, or you can put something else in there for a strange effect.

Also make sure you've called
device->SetRenderState(D3DRS_SHADEMODE,D3DSHADE_GOURAUD);
or your models will look very ugly indeed. This turns on nice, smoothly colored triangles, instead of ugly solid-colored ones.
VideoWorks Softwarehttp://www.3dpoolpro.com
Thanks for the help guys. This sounds like it could be my problem as I am setting up a new material but not the ambient value. I'm at work at the moment but will check it out tonight when I get home and let you know how it goes.
Thanks Tubular, this is working great now.

Ok guys, I have another problem. I am trying to texture my mesh. When I view this in the DirectX Mesh Viewer utility my mesh shows up fine with textures. However when adding it to my program the texture is applied but it appears really dark. See here to see what I mean. I have tried running this through the tutorials in the book that I have but it also appears dark. Is there any obvious setting like before that I am missing to make my model light up correctly like it does through the mesh viewer?

Thanks

[Edited by - Fallen_Angel on November 26, 2004 5:52:35 PM]
bump to top...thought the edit might have done this for me

This topic is closed to new replies.

Advertisement