游戏屏幕外渲染黑屏_看Nintendos在屏幕外的精灵渲染故障

游戏屏幕外渲染黑屏

While I was capturing some game footage from Zelda II, I noticed a strange little glitch. I was in a tunnel while fighting an ax-wielding red Daira, and part of a slime flickered on the left of the screen. When I moved forward, I saw there was, in fact, a slim just off the screen.

当我从Zelda II捕获一些游戏画面时,我注意到一个奇怪的小故障。 我在和一个挥舞着斧头的红色Daira战斗时在一条隧道里,一部分粘液在屏幕左侧闪烁。 当我向前走时,我发现屏幕上确实有一个细长的屏幕。

Image for post
Half of a red slime flickers on the left of the screen
屏幕左侧有一半的红色软泥闪烁

So, why did this happen?

那么,为什么会这样呢?

ñintendo的PPU (Nintendo’s PPU)

During my research on the Nintendo PPU, picture processing unit, I learned a lot about scanline rendering in addition to what made sprites wrap around the screen. This happened when a sprite’s X position went past 255. While most players would consider this a software bug, it was a significant limitation in the NES renderer that developers had to deal with.

在对Nintendo PPU ( 图片处理单元)进行研究的过程中 ,除了使Sprite环绕屏幕外,我还学到了很多有关扫描线渲染的知识。 当精灵的X位置超过255时,就会发生这种情况。尽管大多数玩家都认为这是软件错误,但这是开发人员必须处理的NES渲染器的重大限制。

If you think about it, the NES is an 8-bit system. That means the X and Y position of any sprite on the screen can only go from 0–255. Today, we would use an unsigned integer to represent this. When you try to add 1 to an 8-bit value set to 255, it loops around back to 0. With the NES having a screen resolution of 256 x 240, that meant there was technically no place to hide sprites horizontally offscreen.

如果您考虑一下,NES是一个8位系统。 这意味着屏幕上任何子画面的XY位置只能在0-255之间。 今天,我们将使用无符号整数表示这一点。 当您尝试将1设置为设置为255的8位值时,它会循环回到0。由于NES的屏幕分辨率为256 x 240,因此从技术上讲,没有地方可以在屏幕外水平隐藏子画面。

For most of the games created on the NES, this was not ideal. With nowhere to place sprites off the screen, it presented a challenge to move them into view when scrolling. To get around this, developers took advantage of the CRT’s overscan. This was a boundary along the edge of the screen where pixels were stilled rendered but technically not visible on most TVs of the time.

对于在NES上创建的大多数游戏而言,这并不理想。 由于无法在屏幕上放置精灵,因此在滚动时将它们移到视图中是一个挑战。 为了解决这个问题,开发人员利用了CRT的过扫描功能。 这是沿屏幕边缘的边界,在该边界上像素仍被渲染,但在当时大多数电视上在技术上都不可见。

渲染场景 (Rendering A Scene)

Let’s take a look at an example of how this worked in a bit more detail. The NES could only display 32 columns and 30 rows of tiles on the screen at a given time.

让我们来看一个更详细的示例。 NES在给定时间只能在屏幕上显示32列和30行的图块。

Image for post
Graphics from the Space Ranger PV8 Art Pack — Created by Luis Zuno
太空游侠PV8艺术包中的图形-路易斯·祖诺(Luis Zuno)创建

Well, most NES developers knew that the last column of the screen was not visible on CRTs. There was a similar gutter on the bottom of the screen, but since the last visible scanline happens at 240, it wasn’t as much of an issue. The NES could skip rendering the last column and blank it out in order to create a gutter for anything offscreen.

好吧,大多数NES开发人员都知道,屏幕的最后一列在CRT上不可见。 屏幕底部有一个类似的装订线,但是由于最后一条可见的扫描线发生在240,所以这并不是什么大问题。 NES可以跳过渲染最后一列并使其空白以创建屏幕外所有内容的装订线。

Image for post
The overscan area is masked off in black on the right and bottom of the screenshot
屏幕截图的右侧和底部以黑色遮盖了过扫描区域

A lot of games took advantage of this area players couldn’t see. Unfortunately, when you play older NES games in emulators or on modern TVs, you see this area, and it’s a bit jarring.

许多游戏都利用了玩家无法看到的这一优势。 不幸的是,当您在模拟器或现代电视上播放较早的NES游戏时,您会看到此区域,这有点令人不快。

子画面包装 (Understing Sprite Wrapping)

But let’s go back to the issue I captured in Zelda II. While it’s similar to what I outlined above, there is a bit more going on here.

但是,让我们回到我在《塞尔达传说II》中捕捉到的问题。 尽管它与我上面概述的相似,但这里还有更多事情要做。

Image for post
When I kill the Daira, the slime is moving away from the player but accidentally wraps around
当我杀死Daira时,粘液从玩家身上移开,但不小心缠绕

In the above still, you can see half of the slime on the left side of the screen. Technically we expect the off-screen sprite to be hidden in the overscan area. I guess that since the sprite’s movement is still being calculated, even when it’s not visible, I happened just to capture it when it was about to come onto the screen, and its X position was precisely at 256. This would turn into 0 and momentarily wrap around the screen and accidentally render on the left side of the screen.

在上面的静止图像中,您可以在屏幕左侧看到一半的粘液。 从技术上讲,我们希望将屏幕外的精灵隐藏在过扫描区域中。 我猜想,由于精灵的移动仍在计算中,即使它不可见,我也碰巧只是捕获了它,即将它移到屏幕上时,它的X位置恰好在256。这将变成0,并暂时环绕屏幕并意外地在屏幕左侧渲染。

Most of the sprites in Zelda II are 16 pixels wide, equal to 2 sprites across. This just happened to be a rare edge-case where the overscan gutter only being 8 pixels wide wasn’t enough to hide the sprite. I love these little glitches. They add to the unique characteristics that make the NES so unique. All due to some hard limitations that developers learned to work around or ignore. Today that would be considered a more serious rendering bug.

Zelda II中的大多数精灵都是16像素宽,等于2个精灵。 这只是一种罕见的边缘情况,其中仅8像素宽的过扫描装订线不足以隐藏子画面。 我喜欢这些小故障。 它们增加了使NES如此独特的独特特征。 归因于开发人员学会解决或忽略的一些严格限制。 今天,这将被视为更严重的渲染错误。

代码示例 (Code Example)

Learning how to hide sprites in the overscan gutter is a critical technique for making more authentic looking 8-bit games. That’s why when I designed Pixel Vision 8, my Fantasy Game Console, I added support masking off the right and bottom of the screen. You can do this in the Chip Editor Tool by setting the number of columns and rows to be included in the overscan area.

学习如何在过扫描沟中隐藏子画面是制作更真实外观的8位游戏的关键技术。 这就是为什么当我设计我的Fantasy Game Console Pixel Vision 8时 ,在屏幕的右侧和底部添加了遮罩的支持。 您可以在Chip Editor Tool中通过设置要包含在过扫描区域中的列数和行数来执行此操作。

Image for post

If you are interested in learning a bit more about how this works in PV8, or in general, I wrote a little Lua code example to help visuals the overscan.

如果您有兴趣了解更多有关它在PV8中的工作方式的信息,或者总的来说,我写了一个Lua代码示例来帮助可视化过扫描。

When you run this code in PV8, it will output the following:

在PV8中运行此代码时,它将输出以下内容:

Image for post
The visible resolution of 256x240 is 248x232 taking into account the overscan
考虑到过扫描,256x240的可见分辨率为248x232

If you are new to game development or looking to make a more authentic looking 8-bit game, try to emulate some of their more interesting quarks from these systems. The NES had so many based on the hardware limitations that they helped define the look and feel of the console and still inspire game developers today.

如果您不熟悉游戏开发,或者想制作出更真实的外观8位游戏,请尝试从这些系统中模拟一些更有趣的夸克。 NES有很多基于硬件的限制,以至于它们有助于定义游戏机的外观和感觉,并仍然启发着当今的游戏开发者。

翻译自: https://medium.com/pixelvision8/a-look-at-the-nintendos-off-screen-sprite-rendering-glitches-b9086069cad3

游戏屏幕外渲染黑屏

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值