开发者

OpenGL: Lighting Inside of Cube

I am creating a scene where I use a box to represent a room and different models within that box. When I enable lighting, my models light up fine but the room itself (the inside of the box) does not light up, or rather it is darker than it should be. Is it because I am trying to light up the inside of a 开发者_运维问答cube? I am sure the normals are correct. Please let me know what you think!

I suppose the normals aren't correct but how do I go about finding the correct normals for inside of the cube. Currently, I am only passing the center point of each face into the normalf function.


If you pass in the center points your normals will be facing the wrong way.

For example, if your cube is 2 units in size and centered on the origin, the center point of the face on the positive X axis will be (1, 0, 0), and that would also happen to be the correct normal for the outward facing side of that face.

However the face pointing inwards will have a normal that's the inverse of that, i.e. (-1, 0, 0).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜