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

DirectX lighting Issue - Help

Started by Lateuk Mar 18, 2005 at 9:43 AM 3 replies 850+ views
Original Post
Lateuk
Lateuk
Hello, I have made a large rectangle box, the camera is in the middle of it, i have also tried to put a point light in the middle. Can anyone tell me why it is lighting up the whole of the inside of the rectangle? i wanted it just to light up a small area in the middle. I am trying to make a tunnel that you walk through, bits are dark and every so often there is a light lighting up part of the tunnel. Thanks Late
paic
paic
Hi,

First, set your light's type to D3DLIGHT_POINT
Then, fill the position, and the diffuse, specular, etc. colors
And the last step : set the attenuation factors. They specify how the lighting decrease with the distance to the light point.

There is a good chapter on light properties in the Help of the DirectX SDK, you should read it to know how to tune the attenuation factors.

But for a start, you can try Attenuation0 = 0.0f, Attenuation1 = 1.0f and Attenuation2 = 0.0f
This setting gives an intensity of the light of 1/D where D is the distance between the light point and the lighted vertex.

.:: Paic Citron ::.
DBX
DBX
Also, if you're using vertex lighting make sure your box is well tesselated.
acid2
acid2
Yes, it sounds like your problem here is because of "tesselation." What this means, in the context of your problem is that the box doesn't have enough triangles to light it. DirectX only supports vertex lighting, which basically means that the colours are only set on the vertices, and then the pixels between the vertices are interpolated.

To solve this problem you could tesselate your mesh, using a 'patch mesh', or you could use HLSL to create a per-pixel lighting shader. This means that instead of lighting the vertices and interpolating the values of the pixels, you actually light each pixel, making it much more accurate.

Hope that clears some things up for you :)
Lateuk
Lateuk
Yes the problem was with the huge box only being made from 12 triangles.

Many Thanks

Topic Locked

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

Sign in to reply to this topic.