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

Lighting problem - directx

Started by N3wbie Jul 22, 2010 at 5:20 AM 6 replies 1.6k views
Original Post
N3wbie
N3wbie
I'm drawing a rotating cube with ambient and diffuse lighting. But the lighting isn't smooth. Instead of shading gradually as the cube rotates, the shading instantly switches between max shadow and max lit.

Any ideas how to fix that please?


[EDIT]Problem solved.

After Zao hinted on IRC that I should double check my mesh I realised that the last two sides did not have normals defined.

Many thanks all :)


[Edited by - N3wbie on July 22, 2010 6:32:23 AM]
Murdocki
Murdocki
dont confuse shadows with unlit. need more info, shaders? fixed function?
gl_Obetrotter
gl_Obetrotter
Just a thought: could be that you use per vertex lighting with a point light with a given radius. In that case, if vertex is within the light range, color is interpolated between all vertices of the triangles. Moving the vertex out of the light range when your cube rotates would result in some kind of "popping" effect.
N3wbie
N3wbie
Murdocki: what I mean by max shadow is that the diffuse lighting doesn't show, but the ambient light does. and by max lit I mean that both the ambient light and diffuse light are on, and the diffuse is at maximum for the whole surface.

If by "shaders?" you are asking if I use pixel shaders for this, the answer is no. I don't know what you mean by "fixed function?".


gl_Obetrotter: the light I use is directional.
Zao
Zao
Are your normals of unit length?
To make it is hell. To fail is divine.
N3wbie
N3wbie
Zao: yes. They are set with D3DXVECTOR3(0.0f, 0.0f, 1.0f); or D3DXVECTOR3(0.0f, -1.0f, 0.0f); etc, for example.
N3wbie
N3wbie
Problem solved.

After Zao hinted on IRC that I should double check my mesh I realised that the last two sides did not have normals defined.

Many thanks all :)
Murdocki
Murdocki
oh wth nvm

Topic Locked

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

Sign in to reply to this topic.