3D 阴影/照明因环境阴影侧面而丢失

发布于 2024-10-10 02:56:00 字数 212 浏览 5 评论 0原文

你们如何处理 3D 游戏中的阴影?我有一个定向光源,可以遮蔽由立方体组成的树的一侧。其余 3 面均仅获得环境阴影。因此,当观看两个环境阴影面时,3D 效果会丢失。我错过了什么吗?我是否应该将离光源最远的一侧遮得更暗?我试着看一下《辐射 3》,看起来有点像他们所做的,但是《我的世界》似乎用两个相对的侧面光遮蔽了一个草堆,而剩下的两个相对的侧面则有点暗,给人的效果是两个光有两个方向光阴影面和深色阴影面的环境光。

How do you guys handle shading in a 3d game? I have a directional light source that shades one side of a tree made of cubes. The remaining 3 sides all get ambient shading only. So the 3d effect is lost when looking at two ambient shaded sides. Am I missing something? Should I be shading the side furthest from the light source even darker? I tried looking at Fallout 3 and it kinda looks like this is what they do however Minecraft appears to shade a grass mound with two opposite sides light and the remaining two opposite sides dark kinda giving the effect that there are two directional lights for the two light shaded sides and ambient light for the dark shaded sides.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

伊面 2024-10-17 02:56:00

听起来您的光源当前是轴对齐的(例如方向:x、y、0 或 0、y、z)。这将完全照亮树面向光的一侧,而根本不会照亮其他部分。您可以做的一件事是稍微移动光线(通过在 x 或 z 的 0 上添加一点)来改进。这意味着两个面被照亮,但照亮量不同(假设 0 增加到 0 和 x/z 值之间的某个位置)。那么你就只有两张没有被照亮的脸了。如有必要,第二盏灯将使它们变得不那么相似。

It sounds like your light source is currently axis-aligned (e.g. has direction: x, y, 0, or 0, y, z). This will fully-light the side of your tree facing the light, and not light the others at all. One thing you could do to improve things is move the light slightly (by adding a bit to the 0 for x or z). this will mean that two faces are lit, by different amounts (assuming that the 0 is increased to somewhere between 0 and the x/z value). Then you've only got two un-lit faces. A second light will make them less similar if necessary.

豆芽 2024-10-17 02:56:00

对于由立方体制成的物体,可以保证该物体的一侧处于黑暗中。使用环境光,您会稍微照亮它,但边缘仍然不会被遮蔽。您可以使用以下几个选项:

  1. 使用立方体的纹理来帮助显示立方体的形状
  2. 进行多次传递,从镜面表面反射光线(昂贵!)
  3. 制作第二个光源(尽管这可能看起来非常不自然)

听起来你正在做的事情应该非常简单,所以我想说你当前的实现似乎令人满意。

With an object made out of cubes, you're guaranteed that one side of the object is going to be in the dark. With ambient light, you'll illuminate it a bit, but the edges will still be unshaded. There are a few options you can use:

  1. Use a texture for the cubes to help show the shape of the cubes
  2. Take multiple passes, bouncing light off specular surfaces (expensive!)
  3. Make a second light source (though this will probably look very unnatural)

It sounds like what you're doing is supposed to be very simple, so I'd say your current implementation seems satisfactory.

南七夏 2024-10-17 02:56:00

首先,尝试调用 glLightModeli 将 GL_LIGHT_MODEL_TWO_SIDE 设置为 GL_TRUE。

As a start, try calling glLightModeli to set GL_LIGHT_MODEL_TWO_SIDE set to GL_TRUE.

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