Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Still No Lights

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

Thanks Buckeye for answering the last question, I solved it finally by rewriting the program from scratch.

Now Back to lights,
I have set the FVF to include Normals, I have loaded in materials and I have enable lights using

D3DLIGHT9 light;
ZeroMemory(&light, sizeof(D3DLIGHT9));

m_pDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
m_pDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pDevice->SetRenderState( D3DRS_SPECULARENABLE, TRUE );
m_pDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
m_pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
m_pDevice->SetRenderState( D3DRS_LIGHTING, true );

m_pDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );

light.Type = D3DLIGHT_POINT;

light.Diffuse.r = 1.0;
light.Diffuse.g = 1.0;
light.Diffuse.b = 1.0;
light.Specular.r = 0;
light.Specular.g = 0;
light.Specular.b = 0;
//light.Ambient.r = 0.25;
//light.Ambient.g = 0.25;
//light.Ambient.b = 0.25;
light.Ambient.r = 1;
light.Ambient.g = 1;
light.Ambient.b = 1;

light.Position = m_Cam.GetPos();//D3DXVECTOR3(0.0f, 0.0f, -20.0f);
light.Direction = m_Cam.GetLookAt(); //D3DXVECTOR3( 0.0f, 0.0f, 1.0f);
light.Attenuation0 = 0.0f;
light.Attenuation1 = 0.0f;
light.Attenuation2 = 0.0f;
light.Range = ((float)sqrt(FLT_MAX));

switch( light.Type )
{
case D3DLIGHT_POINT:
light.Attenuation0 = 1.0f;
break;
case D3DLIGHT_DIRECTIONAL:
light.Position = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
break;
case D3DLIGHT_SPOT:
light.Position = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
light.Range = 1.0f;
light.Falloff = 100.0f;
light.Theta = 0.8f;
light.Phi = 1.0f;
light.Attenuation2 = 1.0f;
}

hr = m_pDevice->SetLight(0, &light );
if (FAILED(hr))
return;

light.Diffuse.r = 0.5;
light.Diffuse.g = 0.5;
light.Diffuse.b = 0.5;

hr = m_pDevice->SetLight(1, &light );
if (FAILED(hr))
return;

hr = m_pDevice->LightEnable(0, TRUE);
if (FAILED(hr))
return;

hr = m_pDevice->LightEnable(1, FALSE);
if (FAILED(hr))
return;





I add normals to a mesh by using D3DXComputeNormals(Meshcontainer);
I can see the num of materials greater than 1. But I still can't see lights.
Any thoughts?
Thanks
Jack

Share this post


Link to post
Share on other sites
Advertisement
Quote:
But I still can't see lights.

It's not clear what you mean by that. You don't "see" lights themselves - you see the effect of lights.

Setting your ambient values to 1 may mask the effect of lighting entirely. That is, everything may appear fully and evenly bright.

By default, ambient lighting is determined by the material you have set when you render a mesh. Diffuse lighting is determined by the vertex color.

Does your vertex structure have a diffuse color? Are you setting a D3DMATERIAL9 when you render the mesh ( dev->SetMaterial(&someMaterial) )?

Also, I would suggest you start with a directional light and set the direction to something oblique, such as ( -1, -1, 1 ) (normalized). The effect of a directional light does not depend on the light's position.

Share this post


Link to post
Share on other sites
The color is dull blue/dark even I am using the bright values. :(
my FVF is

m_dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL | D3DFVF_TEX1;



I've set the material before drawing subsets...
Any other chances that I might have trapped into?
Thanks
Jack

Share this post


Link to post
Share on other sites
Sometimes i really have a doubt on the materials.
Because I set the alpha channel (transparent) of some background scenery,
But there is no effect on the program...
Any further suggestions?
Thanks

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!