Skip to main content
GameDev.net gamedev.net
🔒 Locked

d3d Light

Started by chenmy1 Oct 12, 2006 at 1:13 PM 0 replies 1k views
Original Post
chenmy1
chenmy1
hi, i learn d3d. directx light on and model black? setting: //------ D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE| D3DFVF_TEX1 //------ D3DMATERIAL9 Material; ZeroMemory(&Material, sizeof(D3DMATERIAL9)); Material.Diffuse.r = 1.0f; Material.Ambient.r = 1.0f; Material.Diffuse.g = 1.0f; Material.Ambient.g = 1.0f; Material.Diffuse.b = 1.0f; Material.Ambient.b = 1.0f; Material.Diffuse.a = 1.0f; Material.Ambient.a = 1.0f; d3daygit->SetMaterial(&Material); D3DXVECTOR3 Direction; D3DLIGHT9 LightSource; LightSource.Type = D3DLIGHT_DIRECTIONAL; LightSource.Range = 1000.0f; LightSource.Diffuse.r = 0.5f; LightSource.Diffuse.g = 0.5f; LightSource.Diffuse.b = 0.5f; LightSource.Diffuse.a = 1.0f; Direction = D3DXVECTOR3(0.0f, 0.0f, 1.0f); D3DXVec3Normalize((D3DXVECTOR3*)&LightSource.Direction, &Direction); d3daygit->SetLight(0, &LightSource); d3daygit->LightEnable(0, TRUE); d3daygit->SetRenderState( D3DRS_LIGHTING, TRUE ); d3daygit->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE); d3daygit->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_COLORVALUE(0.5, 0.5, 0.5, 1.0));
Mos2d/3d engine by Vedat Meydaneri.http://mosengine.inativa.com/
sirob
sirob
Either make sure you vertice's diffuse color isn't black, or set D3DRS_DIFFUSEMATERIALSOURCE to only D3DMCS_MATERIAL.

Also, make sure that D3DTA_DIFFUSE is used in one of the Texture Stage States. For debugging purposes, you'd be best off setting Stage 0 to SelectArg1 and Arg1 to D3DTA_DIFFUSE, and disabling Stage 1.

Hope this helps.
Sirob Yes.» - status: Work-O-Rama.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.