2D 运动模糊解决方案

发布于 2024-07-26 06:09:06 字数 392 浏览 2 评论 0原文

我正在考虑将运动模糊加入到我的 2D 程序中,但我怀疑当前算法的结果。

我的方法目前看起来像这样:

  • 绘制到后台缓冲区。
  • 当时间到 更新前缓冲区,混合 后缓冲区到前缓冲区。
  • 重复

造成“运动模糊”效果的显然是混合,因为运动中的物体会留下淡出的痕迹。

这显然对硬件要求不是很高,双缓冲无论如何都会完成,唯一的额外步骤是 alpha 混合,这是一个简单的计算。 然而,轨迹会非常清晰,一点也不模糊,这可能看起来有点奇怪。 我可以在混合步骤之前在后台缓冲区上进行框模糊,但感觉这对于像任天堂 DS 这样的低端系统来说可能会非常繁重。

是否有任何解决方案可以让我更有效地完成工作或产生更好看的结果?

I'm thinking of chucking motion blur into my 2D program, but I doubt the results of my current algorithm.

My approach looks like this at the moment:

  • Draw to backbuffer.
  • When time to
    update front buffer, blend the
    backbuffer onto the front buffer.
  • Repeat

What would cause the "motion blur" effect is obviously the blending, as objects in motion will leave a fading trail.

This is clearly not very demanding on the hardware, the double buffering will be done anyway and the only extra step is the alpha blending, which is a simple calculation. However, the trails will be very sharp, and not blurry at all which may looks a bit strange. I could do a box blur on the back buffer before the blending step, but it feels like it could be very taxing on low-end systems like the Nintendo DS.

Are there any solutions that let me do it more efficiently or yield a better looking result?

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

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

发布评论

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

评论(3

荒芜了季节 2024-08-02 06:09:06

实际上,您应该渲染许多中间帧并将它们混合成一个结果。 例如,假设您的输出帧速率为 50 fps。 如果您以 500 fps 进行内部渲染,并将十帧组混合在一起,然后再向用户显示,您可能会得到合理的结果。

您目前使用的方法模拟持久性,就好像您正在使用慢速荧光粉在旧 CRT 上进行渲染一样。 这实际上与运动模糊不同。 如果帧持续时间为 20 毫秒 (1000/50),则运动模糊帧由跨越 20 毫秒帧持续时间的渲染组成,所有渲染都具有相同的 Alpha 权重。 持久化解决方案由20、40、60、80、100毫秒前的渲染组成,逐渐淡出。

Really you should render many intermediate frames and blend them into one result. Say, for example, that your output frame rate is 50 fps. You'd probably get a reasonable result if you rendered internally at 500 fps and blended groups of ten frames together before showing that to the user.

The approach you are using at the moment simulates persistence, as if you were rendering onto an old CRT with slow phosphor. This isn't really the same thing as motion blur. If your frame duration is 20ms (1000/50) then a motion blurred frame consists of renderings spanning the 20ms frame duration, all with the same alpha weighting. The persistence solution consists of renderings from 20, 40, 60, 80, 100ms ago, gradually fading out.

泅渡 2024-08-02 06:09:06

据我所知,没有真正的方法可以更有效地做到这一点。 这就是它的效率。 如果帧速率良好并且运动也不太尖锐的话,它看起来相当不错。

最好看的计划是,对于每个像素,从新位置到旧位置绘制一条半透明线。 然而,这并不是一个简单的计算。

There is no real way to do it more efficiently to my knowledge. Thats about as efficient as it gets. It looks pretty good if frame rate is good and movement isn't too sharp as well.

The best looking plan would be to, for each pixel, draw a semi-transparent line from the new position to the old position. This is not a trivial calculation, however.

陈独秀 2024-08-02 06:09:06

它可能根本不是很锐利。 这完全取决于所使用的混合函数。 例如,前一个/当前图像分别为 0.1/0.9 将提供一些微弱的痕迹。

我可能会补充一点,这本质上就是 OpenGL 中运动模糊的完成方式(通过累积缓冲区)

It might not be very sharp at all. It all depends on the blending function used. For instance 0.1/0.9 for previous/current image respectively will provide some faint trail.

I might add that this is essentially how motion blurring in OpenGL is done (through accumulation buffer)

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