如何在 OpenGL 中快速、轻松地创建不带着色器的独立于场景的阴影

发布于 2024-10-03 10:15:03 字数 110 浏览 5 评论 0原文

让我在房间中央有一些网格(例如球体),充满立方体和一个光源。如何仅使用“标准”(固定)函数在 OpenGL 中快速且轻松进行阴影投射?注意:结果还必须包含立方体和球体阴影。

Let i have some mesh (for ex. sphere) in the center of room, full of cubes and one light source. How can i make fast and easy shadow-casting in OpenGL, using "standard" (fixed) functions only? Note: the result must contain cube and sphere shadows as well.

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

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

发布评论

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

评论(3

温柔一刀 2024-10-10 10:15:03

如果您可以生成球体的轮廓,那么您可以使用阴影体积。 nVidia 硬件还支持固定功能阴影映射一段时间。

阴影体积的缺点是填充率要求非常高。阴影贴图可以更好,但需要额外的通道。

如果您投影到单个平面上,则 将对象投影到平面上

If you can generate a silhouette of the sphere then you could use shadow volumes. nVidia hardware has also supported fixed function shadow mapping for a fair while as well.

Shadow volumes have the disadvantage of very high fill rate requirements. Shadow maps can be better but require an extra pass.

If you are projecting on to a single plane it may well be easier to just project the object on to a plane.

残龙傲雪 2024-10-10 10:15:03

没有快速简便的方法。有许多不同的技术,每种技术都有自己的优点和缺点。您可以查看我在 github 上托管的一个项目,该项目使用非常简单的代码来创建阴影,使用阴影体积技术 (http://iuiz.github.com/VolumeShadow/)。然而它是用 Java 编写的,但将其移植到任何其他语言应该不难。

创建阴影的最重要方法是所谓的“阴影映射”方法,在该方法中,您将场景(将相机置于光源处,指向每个阴影投射对象)渲染为纹理。第二种技术是shadow voulume方法(因Doom3而闻名)。

There is no fast and easy way. There are lots of differnt techiques, that each have their own pros and cons. You can look at a project I host on github, that uses very simple code to create a shadow, using the shadow volume technique (http://iuiz.github.com/VolumeShadow/). However it is written in Java, but it should not be hard to port it to any other language.

The most important ways to create shadows are the so called "shadow mapping" method, where you render your scene (with the camera at the light source, directed to each shadow casting object) to a texture. And the second technique is the shadow voulume method (made famous with Doom3).

天暗了我发光 2024-10-10 10:15:03

我找到了一种使用 StencilBuffers 的方法。有一段时间有点困惑,我终于明白了——最困难的事情是循环遍历每个光源并投影所有场景对象。这个看起来比纹理阴影更漂亮,而且比体积阴影工作得更快。 这里这里是一些资源,帮助我理解矩阵乘法步骤(当我查看恐龙演示时,它让我有点困惑)。对我来说,这种方法是最容易理解和使用的。剩下的唯一需要解决的问题是如何计算乘法矩阵。

尽管可以使用纹理稍微更改此方法如此处所示

谢谢大家! =)

I've found one way using StencilBuffers. Being a little confused for a while, i finally got the idea - whith this the most hard thing would be looping through each light source and projecting all scene objects. This one looks more pretty than texture shadowing and works faster than volumeric shadows. here and here are some resources, which helped me to understand matrix multiplication step (it confused me a bit when i was looking through dino demo). As for me, this method is most easy to understand and use. The only question left to solve is how to calculate multiplication matrix.

Although this method could be changed a bit using textures as shown here.

Thanks everybody! =)

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