Jump to content
  • Advertisement
Sign in to follow this  
Victor17

Lighting problem with rendering customed .x mesh

This topic is 4616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I wrote a simple D3D program which renders a .x mesh file with simple directional light. The program executes just fine when dealing with .x file in the SDK samples, such as tiny.x, from the cool walking guy animation sample. Later, I modeled a customed character in Maya7.0, and export it using plug-in to a .x file. I tried many options, with or without export data containing material/textures. My program fails to render it correctly - the program render the model in completely dark, with no ambient color, with no diffuse color, nothing~~~Only a dark geometry displayed on screen. I'm still a starter for D3D. I assigned white to both ambient and diffuse coefficient of the material used in rendering, I also allow D3D to automatically normalize normals. However i just don't understand why my model can't be drawed in correct lighting result as models from SDK. Is there some data missed in my customed .x file when comparing to the sample one? or did I miss some necessary rendering procedure in my program? I've been looking for answer to this problem for days. Any suggestion is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
I can only suggest a couple of things.

Make sure that the mesh is exported correctly by the Maya plugin. Open it in the DXViewer located in the Microsoft DirectX SDK (February 2006)\Utilities\Bin\x86 directory.

Make sure using the DXViewer that the normals are there.

Other than that I'll need to see a screenshot ;).

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
There's no need to post one. Let me put it this way, if i use a white background color, you could see a pure black object in the center of my screen, and you could tell it is an 3D object but not easily(i rotate the mesh in a constant speed), for every pixel of it is completely black! if i use a black background color, u would not be able to see any thing at all, because the mesh is the same color as the background, all pixel on the entire screen are all the same - pure black!

Share this post


Link to post
Share on other sites
Ok, then it's the lighting that's not properly setup.
You can use a simple directional light to debug.
Take a look at Lights and Materials in the DirectX SDK Documentation.
What is happening is that you haven't either disabled lighting and by that I mean that Direct3D has lighting enabled by default and it's not finding any light to illuminate your mesh and thus your mesh will appear black.

You could try disabling light.
i.e.
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
Thx for the help! but i can almost sure the problem is my mesh, not my light. I created a directional light in the scene already, which means the default D3D lighting is suppressed. And the most important is, aside from the problematic mesh, I have other objects in the scene - the default "box" meshes created by using sample framework, and these box meshes can reflect my directional light just fine. Only the one that i exported from maya is black, as if it's unaffected by light.

And, i tried disabling light in RenderState, the entire scene turns black, including those ones which were ok. Shouldn't the D3D default light be turned back on after i disabled light?

Share this post


Link to post
Share on other sites
Are you sure your mesh has normals? For a mesh to render properly you must either 1) have normals, a material and (optionally) a texture, and turn on lighting; or 2) have vertex colors and turn lighting off (or you would see white).

Share this post


Link to post
Share on other sites
Although i still haven't figure out why, but i'm sure the problem is the x file exporter plugin for Maya7. It seems the x file created by this plugin is always lack of some data which i can't be sure yet. The diffuse color of d3d light couldn't affect the surface of such mesh at all(ambient light even specular light would do). Interestingly, I happened to notice there is a mesh file named tiger.x along with DX SDK has the same problem, if u try not rendering its texture, u would get the result i described. Anyone know what kind of data is missing in them? why can't they be correctly computed in diffuse lighting?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!