Skip to main content
gamedev.net
🔒 Locked

D3D9 lighting problem

Started by DorRaba 2 replies 500+ views
Original Post
DorRaba
DorRaba
Hi, I use a Spot Light that lights on a 20x20 surface, the problem is that the light is not shown as a circle on the surface, its shape is very sharp, the light is like its created from the triangles of the surface. this is how i created my light, if there is something wrong please tell me how to fix it ZeroMemory(&d3dlight1, sizeof(D3DLIGHT9)); d3dlight1.Type=D3DLIGHT_SPOT; d3dlight1.Diffuse.r=1.0f; d3dlight1.Diffuse.g=0.0f; d3dlight1.Diffuse.b=0.0f; d3dlight1.Ambient.r=0.0f; d3dlight1.Ambient.g=0.0f; d3dlight1.Ambient.b=0.0f; d3dlight1.Specular.r=0.0f; d3dlight1.Specular.g=0.0f; d3dlight1.Specular.b=0.0f; d3dlight1.Position.x=0; d3dlight1.Position.y=5; d3dlight1.Position.z=0; d3dlight1.Direction.x=0; d3dlight1.Direction.y=-1; d3dlight1.Direction.z=0; d3dlight1.Falloff=0.0f; d3dlight1.Phi=0.5f; d3dlight1.Theta=1.0f; d3dlight1.Attenuation0=1.0f; d3dlight1.Attenuation1=0.0f; d3dlight1.Attenuation2=0.0f; d3dlight1.Range=100.0f; g_pd3dDevice->SetLight(1, &d3dlight1); g_pd3dDevice->LightEnable(1, TRUE); the surface has no Y axis so the light should down to the surface and make a round circle.
DDDDor RRRRaba
Palidine
Palidine
that''s just how lights are done with dynamic lighting. they are done on a per-vertex basis, which is why it''s called per-vertex lighting. to get nice circle lights either use a more detailed mesh or look into lightmaps which is how most games get good looking spotlights. or look into pixel shaders which you can get to do just about anything AFAIK....

-me
DorRaba
DorRaba
I saw in the microsoft directx sdk samples, the Lighting sample, and they didn''t use anything special in there, maybe i''m not getting smooth circle of light because I didn''t make the surface using mesh object, instead I used only a vertex buffer, could it be the problem, are meshes, respond to light better then a regular polygon?
DDDDor RRRRaba
Wavewash
Wavewash
Their mesh has a high resolution (many triangles). Per vertex lighting needs many triangles to look good.

~Wave

Topic Locked

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

Sign in to reply to this topic.