OpenGL:立方体内部的照明

发布于 2024-10-01 20:18:03 字数 193 浏览 1 评论 0原文

我正在创建一个场景,其中使用一个盒子来代表一个房间以及该盒子内的不同模型。当我启用照明时,我的模型可以正常亮起,但房间本身(盒子内部)不会亮起,或者更确切地说,它比应有的更暗。是因为我想照亮立方体的内部吗?我确信法线是正确的。请告诉我您的想法!

我认为法线不正确,但我如何找到立方体内部的正确法线。目前,我仅将每个面的中心点传递到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2024-10-08 20:18:03

如果您通过中心点,您的法线将面向错误的方向。

例如,如果您的立方体大小为 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文