使用 4x3 矩阵创建平面阴影?
只是想知道如何从 4x3 矩阵创建平面阴影,我见过的所有在线演示都使用 4x4 矩阵。
Was just wondering how I would go about creating a planar shadow from a 4x3 matrix, all online demos I've seen use 4x4 matrices instead.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜想这是通过将 3D 对象投影到平面上来完成的,这实际上需要第四个坐标来表示无穷大。 如果只使用3个坐标,则只能表示|R^3。 然而,对于像阴影这样的投影,您将需要完整的 3 空间,因此包括无穷大 - 所以您需要第四个坐标。
我想你可以用三角函数而不是矩阵来解决这个问题。
你想要实现什么目标?
I guess that this is done by projecting a 3D object onto a plane, which essentially needs a fourth coordinate to represent infinity. If you only use 3 coordinates, you can only represent |R^3. However, for projections like shadows you will need full 3-space, thus including infinity - so you need the fourth coordinate.
I guess you can solve this with trigonometry and not matrices at all.
What is it you are trying to accomplish?
正如另一个答案中所述,您确实需要 4x4 来编码投影。
如果有任何帮助,您可以通过将高度轴缩放到 0 并将压缩的几何体平移到地平面来直接制作头顶阴影。 有点垃圾,但可能是你可以使用的东西。 几年前,我在一个真正想要这样的阴影的项目中使用过一次。
As noted in the other answer, you really need 4x4 to encode a projection.
If it's any help at all you can do directly overhead shadows by scaling your height axis to 0 and translating the squashed geometry to your ground plane. A bit rubbish, but might be something you could use. I used this once a few years ago on a project that actually wanted shadows like that.
有什么原因不能使用阴影贴图吗? 要制作阴影贴图,您需要渲染光源的深度值。 然后,在渲染普通图像时,您将像素转换到光的空间。 如果其深度大于阴影贴图中的深度,则其被阴影化,否则其不被阴影化。
维基百科有一个很好的解释。 网络上还有更多资源。 谷歌搜索“阴影映射”
Any reason you couldn't use a shadow map? To do a shadow map you render depth values from a light source. Then when rendering the normal image you translate the pixel to the light's space. If its depth is greater than the depth in the shadow map then its shadowed otherwise its not shadowed.
Wikipedia has a pretty good explanation. Lots more resources around the net. Google for "Shadow Mapping"