阴影贴图 - 多个来源

发布于 10-10 16:33 字数 244 浏览 11 评论 0原文

我正在考虑编写一些在 DX9 中执行阴影贴图的代码。我仅从一个光源获得阴影贴图的示例代码。来自多个光源的阴影贴图的性能是否可行?我的场景渲染起来非常轻 - 没有纹理,只有几百或几千个顶点。

问题是我的场景发生在太空中,靠近太阳。我打算将太阳创建为一个球体,并将每个顶点渲染为光源 - 这也将为各种科幻太空飞船效果产生一些良好的效果。但通读代码后,我非常担心这会破坏我的性能,而且我不完全确定它会产生我正在寻找的令人难以置信的灯光效果。我在这里是不是太过分了?

I'm looking at writing some code that performs shadow mapping, in DX9. The sample code that I've got only shadow maps from one light source. Is it performance viable to shadow map from more than one light source? My scene is VERY light to render otherwise- there's no textures, and only a few hundred or few thousand vertices.

The trouble is that my scene takes place in space, close to the Sun. I was going to create the Sun as a sphere, and render each vertex as a light source- this was also going to produce some good effects for various sci-fi space-ship effects. But reading through the code, I'm very concerned that this is going to destroy my performance, and I'm not entirely sure that it's going to produce the incredible lighting effects that I'm looking for. Am I just overkilling here?

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

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

发布评论

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

评论(3

兲鉂ぱ嘚淚2024-10-17 16:33:38

渲染每个投射阴影的多个灯光的简单方法是------>

对于循环中的每个光源,执行以下操作::

{

清除屏幕外 RenderTarget 黑色。

仅使用当前灯光渲染场景...在离屏渲染目标上。

然后打开混合(添加、一对一),将离屏渲染目标绘制/覆盖到主后缓冲区上。

渲染完所有

灯光后,呈现场景。因为光线最终只是相加,所以您可以根据需要渲染任意数量的灯光。
无论您是否使用不同的照明,此方法都将起作用。您还可以打开或关闭每个灯光的阴影。

如果其中任何一个不清楚&需要更好的解释让我知道......

An easy way to render multiple lights that each cast shadows is to------>

For Every Light in a loop do the following::

{

Clear a Offscreen RenderTarget black.

Render the scene with the current light only... on the Offscreen RenderTarget.

Then with Blending(Add, One to One) turned on, draw/overlay the Offscreen RenderTarget onto your main backbuffer.

}

After all the lights are rendered, present the scene. Because light is just addition in the end, you can just keep rendering as many lights as you want.
This method will work whether your using differed lighting or not. You can also turn shadows on or off for each light.

If any of this is unclear & needs a better explanation let me know...

他是夢罘是命2024-10-17 16:33:38

说实话,你实在是太过分了。来自大球体中每个顶点的光源太多了。如果您想在阴影上获得软边缘,那么您最好研究 软阴影 一般来说。

举个例子,《半条命 2》通过将阴影贴图渲染到单独的渲染缓冲区(同时使用主渲染缓冲区中的 Z 缓冲区)来实现软阴影。然后模糊该缓冲区并将其应用回主渲染缓冲区。结果是看起来非常漂亮的阴影......

TBH you ARE just overkilling. A light source from every vertex in a large sphere is waay too many. If you are after getting the soft edges on shadows then you are far better off looking into soft shadowing in general.

To give you an example Half-life 2 achieved soft shadowing by rendering the shadow maps into a seperate render buffer (while using the Z-Buffer from the main render buffer). Then blurring that buffer and apply it back on to the main render buffer. The result is pretty nice looking shadows ...

青芜2024-10-17 16:33:38

如果您正在寻找“高级”效果/技术的 DX 或 OGL 代码,请查看 Humus 3D 有一些阴影贴图示例,一个应该有多个来源。另外,GPU Gems 3 的这一部分可能也令人感兴趣。

If your ever looking for DX or OGL code for 'advanced' efects/techniques, take a look at Humus 3D there are a few samples of shadow maps, one should have multiple sources. Also this section of GPU Gems 3 might be of interest.

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