为什么有些游戏显示灯光穿过墙壁发光?


28

在某些游戏中,即使将视频质量设置为高水平,我也会看到灯光穿过墙壁。

我最近玩过的一些游戏示例包括《无主之地2》(导弹爆炸)和《克苏鲁的呼唤》(灯笼;该游戏甚至使用了虚幻引擎4)。

这是错误还是出于性能原因?

示例无主之地2:https//youtu.be/9bV83qA6_mU? t = 419(几次,但很快)

额外的问题:在后一种情况下,有什么方法可以廉价地使用光线跟踪解决问题?我想昂贵的RT肯定可以解决问题,但是我想知道它是否也可以“便宜”的形式用于解决此特定问题。


21
A picture is worth 1000 words.
Evorlor

8
我必须去测试,但实际上是在漏出,还是发光的粒子效果?特别是在您的导弹爆炸示例中,我可以想象有一个附加的“火”粒子效果,它很可能会忽略碰撞。我想灯笼也可以做同样的事情以形成可见的光环……
AC

@Evorlor添加了一个示例。
Marcus

Answers:


43

Expanding on TomTsagk's correct answer, I thought it might help to describe a bit more about why games work like this.

Light in games doesn't really "travel" from the source, to the surface, to the camera, getting obstructed along the way.

To figure out how bright to draw each pixel of a surface based on a given light, we use (or approximate) a math formula that uses the facing direction of the surface and the direction from this point on the surface to the light source. That's it, just the direction it's shining from — we don't typically cast a ray to check if the light actually reaches this pixel, because doing that for every pixel on the screen and checking the ray against all the detailed geometry in the scene is usually still too expensive for realtime games.

So, by default, no game lights cast shadows. The direction to a light stays the same even if there's a shadowcaster in the way, so the math gives us the same brightness value.

If we want to simulate shadows, we have to do that separately. One common way is with what's called a Shadow Map. In this version, before we shade our scene, we first render the scene from the perspective of each light, as though that light were a camera, storing the depth of each pixel it sees into an off-screen texture.

然后,当我们为场景着色时,我们可以比较该像素到光源的数学距离与我们在阴影图中相应像素处记录的深度之间的比较。如果阴影贴图的深度较小,则表示此处与光线之间还有另一个表面,我们改为在阴影中绘制此像素。

有很多很酷的技术可以使这些基于地图的阴影看起来更好,同时减少了伪像/锯齿,但现在我将对其进行介绍。可以说,它们通常也不免费。

因为这需要从每个光源的角度再次渲染(最多)整个场景-如果点光源向各个方向(北,南,东,西,上,下}都发光,则最多可以渲染六次,我们需要重新渲染-随时移动阴影地图,这会变得非常昂贵。

So games will often focus their rendering budget on the most important lights in the scene — like the directional sun light — to ensure they have good-looking shadows. Small, short-lived, minor lights like the flash of an explosion are often forgivable if they leak past occluders a little. Often this is more palatable to players than a hitch in the framerate due to a sudden increase in rendering cost from all the extra shadow map rendering and calculation. Especially if it's a busy action scene where fluidity matters more than pixel perfection.


3
Another wrinkle is that while it's trivial to figure out whether a light source is in front of or behind a surface, preventing surfaces from glowing when lit from behind will often yield weird looking results.
supercat

And this is especially true with particle effects (which the explosion probably is, at least partially), since particles need to be especially cheap to handle to be very useful.
Luaan

2
Lights and particles are two different things. A particle can also "leak" through an obstacle, but for completely different reasons. Sometimes a particle system will also include a light to help sell the effect (think a campfire or swarm of fireflies), but a light inside a particle effect is still just a light, usually not any special variant.
DMGregory

2
An alternative approach to shadow maps is shadow volumes, which fixes the aliasing problem, but is more expensive: requiring extra geometry to be rendered (a new polygon per silhouette edge of each object for each light source), as well as extra rendering passes. I'd expect the mapping approach is good enough for most situations, though.
DarthFennec

22

Long story short, this happens for performance reasons.

When there's a light on the screen, by default it shines on all objects (obstructed or not), so the game would need to make extra calculations to see which object is affected by what.

This is easier to solve on static objects by using static and baked lighting, but this is not the same on dynamic lights, like explosions as you noted.

For your bonus question, ray tracing and cheap do not go together on the same sentence. The only reason ray tracing hasn't been mainstream up until now is performance. Assuming all lights use ray tracing, then this problem would be "solved", but at the expense of performance.


6
So is ray tracing more of a thing for CGI movies than real-time games?
Acccumulation

21
@Acccumulation That's correct. A single frame of a movie can take hours to render, while a game only has milliseconds.
NobodyNada - Reinstate Monica

16
That said, games are increasingly exploring using raytracing or raymarching in tandem with rasterization techniques, letting the rasterizer do what it's good at and the rays do what they're good at. It's not full raytracing of every pixel, but you can still get some great effects that way.
DMGregory

2
@DMGregory Indeed, games like Duke Nukem 3D already used a very simplified variant of raytracing - though it wasn't used for dynamic lighting, and it definitely didn't trace every single pixel on the screen (usually, it was done for each column of pixels), and reflections and transparency were still a special case rather than the default. Software 3D rendering has always played with similar approaches, it was the hardware 3D that closed off that avenue (until now).
Luaan

@Acccumulation Raytracing comes at different levels, so while games can on top of the line hardware shoot primary rays they still dont do enough secondary bounces or multiple bounces per pixel. So even if you were to raytrace youd still have performance tradeoffs much like this. So ability trace main lights still does not mean you can afford to render all secondary lights.
joojaa
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.