Jump to content
  • Advertisement

Archived

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

Aram

Need help with setting up lightning

This topic is 5997 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 have created a point light in d3d that doesn''t seem to work properly. It doesnt matter what values I put in the d3dlight structure the light doenst change, it just lits up the screen. For example if I alter the lightrange nothing happends. This has annoyed me for sometime now and I just can''t figure it out. Have I missed something?
  
	ZeroMemory( &material, sizeof( D3DMATERIAL8 ) );
		material.Diffuse = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f );

	D3dDevice->SetMaterial(&material);


	D3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
	ZeroMemory(&d3dlight, sizeof( D3DLIGHT8 ) );
		d3dlight.Type = D3DLIGHT_POINT;

		d3dlight.Diffuse  = D3DXCOLOR( 0.5f, 0.5f, 0.5f, 0.5f );

		d3dlight.Position = D3DXVECTOR3( 0.0f, 0.0f, -1.0f );
		d3dlight.Range = 200.0f;

		
	D3dDevice->SetLight( 0, &d3dlight );
	D3dDevice->LightEnable( 0, TRUE ); 

	D3dDevice->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL );
	
  

Share this post


Link to post
Share on other sites
Advertisement
Change the Attenuation values as well, to get a different range. Change the Ambient and Specular light colors as well.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!