Which light and how should I use it to light the whole world in my game? I have tried some ways and it gives me very different results, that are all are bad for some reasons.
Which light and how should I use it to light the whole world in my game? I have tried some ways and it gives me very different results, that are all are bad for some reasons.
Well, are you using OpenGL or DirectX?
If you are making a "sun", you will probably want a diffuse light source and you will want it to be quite strong.
Another option is to simply have no lighting....then everything is visible.
I am using DirectX.
I'm not absolutely sure how to do it. Maybe you could explain a bit.
This sets up fixed function diffuse and specular lighting. Keep in mind this is old school per-vertex lighting and does not produce good results. You must compute the normals for your surfaces and use an FVF format that contains D3DFVF_NORMAL for this to work.
Code:m_pDevice->SetRenderState(D3DRS_LIGHTING,TRUE); D3DLIGHT9 light; light.Diffuse = D3DXCOLOR(1.0f,1.0f,1.0f,1.0f); light.Ambient = D3DXCOLOR(0.5f,0.5f,0.5f,1.0f); light.Specular = D3DXCOLOR(0.2f,0.2f,0.2f,1.0f); light.Emissive = D3DXCOLOR(0.2f,0.2f,0.2f,1.0f); light.Power = 1.0f; light.Type = D3DLIGHT_DIRECTIONAL; light.Direction = D3DXVECTOR3(1.0f,0.0f,0.0f); m_pDevice->SetLight(0,&light); m_pDevice->LightEnable(0,TRUE); m_pDevice->SetRenderState(D3DRS_SPECULARENABLE,true);
The SDK has good documentation for this if you look at IDirect3DDevice9::SetLight().
It gives me errors on light.emissive and light.power.
MSDN doesn't mention either, http://msdn.microsoft.com/en-us/libr...66(VS.85).aspx
Aye, I got D3DLIGHT9 and D3DMATERIAL9 mixed up. D3DMATERIAL9 has emissive as well as power.
Just remove those and it should work. My apologies. I don't work with fixed function much anymore. I did check the docs while posting but guess I just missed the emissive and power.