您可以将全向光与阴影贴图混合吗?

发布于 2024-12-10 11:07:28 字数 383 浏览 0 评论 0原文

我已经为我的 RPG 实现了 PSSM(并行分割阴影贴图)。它仅使用“太阳”(高处的一个定向光。

所以我的问题是,是否有一种特殊的技术可以将最多 4 个全向光添加到像素着色器?

它会按照这些思路工作:

At the shadowmap application (or maybe at its creation):
if in light: do as usual

else: check if any light is close enough to light this pixel (and if, don't shadow it).

也许这甚至可以在阴影贴图生成中完成(因此过滤也将应用于那些全向灯)

热烈欢迎任何提示或技巧!

I have implemented PSSM (Parallel-Split Shadow Map) for my RPG. It uses only the "sun" (one directional light high above.

So my question is, is there a special technique to add say max 4 omni-directional lights to the pixel shader?

It would work somewhat along these lines :

At the shadowmap application (or maybe at its creation):
if in light: do as usual

else: check if any light is close enough to light this pixel (and if, don't shadow it).

Maybe this can even be done in the shadowmap generation (so filtering will be applied to those omni lights too)

Any hints or tips warmly welcomed!

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

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

发布评论

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

评论(1

走走停停 2024-12-17 11:07:28

这个问题的答案是如此明显,以至于问题本身表明您对 3D 图形的技巧已经深入了解,需要记住所有这些实际上应该做什么。

阴影贴图是一种判断表面上的特定位置相对于场景中的特定光线是否处于阴影中的方法。阴影贴图回答了这个问题:“表面上的点和光源之间是否有固体?”

如果这个问题的答案是“是”,那么该光源不会参与该点的照明计算。如果答案是“否”,那么确实如此。

表面上的点的颜色基于来自所有光源的入射光以及表面上该点的表面特征(漫反射颜色、镜面光泽度、法线等)。每个光源的所有计算相加,产生该点所代表的最终颜色值。

您通常还会有各种技巧。环境术语通常用于表示大量间接照明。光照贴图可以代替您不在着色器中动态计算的其他来源的光。等等。但最终,它们都只是灯。

您的照明方程采用光参数(颜色、方向/位置,或仅环境光的环境强度)和表面特征(如上所述),并产生从表面反射的光量。由于一种灯光的反射率不受其他灯光的反射率影响,因此您可以为每种灯光独立计算该反射率。

所有这些值相加得出最终值。

事实上,您可以通过阴影贴图测试来缩短其中一个的计算,这一事实与整体方案无关。只需将各种照明术语相互添加即可,这就是您的答案。没有“特殊技术”可以做到这一点;你就去做吧。

The answer to this question is so obvious that the question itself suggests that you've gone too far into the hacks of 3D graphics and need to remember what all of this is actually supposed to be doing.

A shadowmap is a way to tell whether a particular location on a surface is in shadow relative to a particular light in the scene. The shadowmap answers the question, "Is there something solid between the point on the surface and the light source?"

If the answer to this question is "yes", then that light source does not contribute to the lighting computations for that point. If the answer is "no", then it does.

The color of a point on a surface is based on the incoming light from all light sources and the surface characteristics of that point on the surface (diffuse color, specular shininess, normal, etc). All of the computations from each light add into one another to produce the final color value that the point represents.

You generally also have various hacks. The ambient term is often used to represent lots of indirect illumination. Light maps can take the place of light from other sources that you're not computing dynamically in the shader. And so on. But in the end, they are all just lights.

Your lighting equation takes the light parameters (color, direction/position, or just the ambient intensity for the ambient light) and the surface characteristics (as stated above), and produces the quantity of light reflected from the surface. Since the reflectance from one light is not affected by the reflectance from other lights, you can compute this independently for each light.

All of these values are added together to produce the final value.

The fact that you can short-circuit the computation of one of these via a shadowmap test is irrelevant to the overall scheme. Just add the various lighting terms to one another, and that's your answer. There is no "special technique" to doing this; you just do it.

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