Jump to content
  • Advertisement
Sign in to follow this  
shalrath

Hardware lighting, And .X files

This topic is 4849 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

Is there any special state you need to have turned on to allow a textured .x model to be lit with hardware lights? When I don't use the texture, my model is lit by the hardware lights, but if I enable the texture (in the material), no lighting is done on the model... I've read through the documentation, there seems to be nothing at all with relation to this issue.

Share this post


Link to post
Share on other sites
Advertisement
Hi there shalrath,
How are you doing?

[The Problem]
Your model is lit but when you place a texture on the model it's not lit anymore.

[a Possible solution]
Maybe giving us the code you use the initialize your materials and textures we might find something out of place?

1) Check to see if your ambient color isn't white, this means that the lighting won't work as expected.
2) Check if the material you applied to the model does not have an ambient value of white.

I hope this helps.
Keep cool.

Share this post


Link to post
Share on other sites
The frames are rendered as such:


for (DWORD i = 0; i < m_dwNumMtrls; i++)
{
m_pDMD3D->ReturnDevice()->SetMaterial(&m_pMeshMtrls);
m_tex.SetTexture();

m_pMesh->DrawSubset(i);
}



And the lights in my scene set like so:

m_pD3DDev9->SetLight(i, &m_lights);
m_pD3DDev9->LightEnable(i, true);
m_pD3DDev9->SetRenderState(D3DRS_LIGHTING, true);



The materials are simply loaded from the .x file, with the code from the SDK

Thanks.

Share this post


Link to post
Share on other sites
Hi there Shalrath,

[Resolve/Conclusion]
Could you possibly give us an example of both situations in screenshot form?
Use imageshack and paste the links if you don't mind.

I cannot see anything from your code that might be causing this unless one of your materials associated with the mesh has an ambient color of white.

Maybe someone will come along and be a little more insightful.

Keep cool.

Share this post


Link to post
Share on other sites
Here we have two screens... although not particularly enlightening...

The non textured sphere (the one that gets lit)



The textured sphere (the one that doesn't get lit for some reason, the dark patches are just the texture)

Share this post


Link to post
Share on other sites
Hi there shalrath,

[The Problem]
It still seems that your material might have a ambient value.
To test my theory try one of the .X meshes in the sdk media directory.

[The SDK Media Directory]
SDK Directory\Samples\Media\Tiger

If it has the same effect, we can take it from there.

Share this post


Link to post
Share on other sites
1) Could you please show us how you create your light?
2) Are you setting any materials, if so.. that code too.

Share this post


Link to post
Share on other sites
The actual settings for the light are as follows:


ZeroMemory(&m_lights, sizeof(D3DLIGHT9));
m_lights.Type = D3DLIGHT_POINT;
m_lights.Diffuse.a = 1.0f;
m_lights.Diffuse.r = 0.25f;
m_lights.Diffuse.g = 0.1f;
m_lights.Diffuse.b = 0.1f;
m_lights.Specular.a = 1.0f;
m_lights.Specular.r = 0.25f;
m_lights.Specular.g = 0.1f;
m_lights.Specular.b = 0.1f;
m_lights.Ambient.a = 1.0f;
m_lights.Ambient.r = 0.5f;
m_lights.Ambient.g = 0.5f;
m_lights.Ambient.b = 0.5f;
m_lights.Direction.x = 0;
m_lights.Direction.y = 0;
m_lights.Direction.z = 0;
m_lights.Range = 17.5f;
m_lights.Attenuation0 = 1.0f;

Share this post


Link to post
Share on other sites
Hi Shalrath,
Sorry this is taking it's time.
I could probably look at your source and debug it. Let's wait for a bit. Maybe someone here has a solution.

I still still very convinced that either one of the materials are Ambient white or you have d3dDevice->SetRenderState(D3DRS_AMBIENT, 0xFFFFFFFF); set or something similar.

If you don't get a response then we can take it one step further if you want and you can send me your source.

Sorry for the delay.

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!