OpenGL:立方体内部的照明
我正在创建一个场景,其中使用一个盒子来代表一个房间以及该盒子内的不同模型。当我启用照明时,我的模型可以正常亮起,但房间本身(盒子内部)不会亮起,或者更确切地说,它比应有的更暗。是因为我想照亮立方体的内部吗?我确信法线是正确的。请告诉我您的想法!
我认为法线不正确,但我如何找到立方体内部的正确法线。目前,我仅将每个面的中心点传递到 normalf 函数中。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您通过中心点,您的法线将面向错误的方向。
例如,如果您的立方体大小为 2 个单位且以原点为中心,则正 X 轴上的面的中心点将为 (1, 0, 0),并且这也恰好是立方体的正确法线该脸朝外的一面。
然而,向内的面将具有与其相反的法线,即(-1,0,0)。
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).