OpenGL运动模糊,无累积缓冲
我尝试使用OpenGL实现实际的运动模糊,但没有累积缓冲区(因为它不能在我的显卡上工作)。这是我的想法的实现:
I'm trying to implement a real motion blur using OpenGL, but without the accumulation buffer (due to it not working on my graphics card). Here is my idea for the implementation:
- 有一个固定的数组(暂时)空白帧缓冲区&每个模糊的纹理
- 每当遇到一个新帧时,将第一个元素移动到结尾,并渲染 framebuffer
- 全部渲染,第一帧具有1 / n 不透明度,第二帧具有1 /( n / 2)一个有1个。
- Have a fixed array of (temporarily) blank framebuffers & textures for each "blur"
- Whenever a new frame is encountered, move the first element to the end, and render to that framebuffer instead
- Render them all, first frame having 1/n opacity, second one having 1/(n / 2), etc... until the newest one having 1.
有没有比这更简单/更快/更优化的方法?或者这是最好的解决方案?
Is there any simpler/faster/more optimized way than this? Or is this the best solution?
NicolBolas在他的评论中说的是正确的:模糊,由每个片段的速度控制;计算每个顶点的屏幕空间速度,并将其作为另一个统一传递给片段着色器。然后在片段速度的方向和距离上应用向量模糊。
What NicolBolas says in his comments is correct: To get real motion blur you must apply vector blur which is controlled by each fragment's speed; calculate the screen space speed of each vertex and pass that as another uniform to the fragment shader. Then apply a vector blur in the direction and distance of the fragment's speed.
因为这会模糊其他片段,最终会出现透明度排序问题。因此,您应该应用这作为后处理效果,理想地与深度剥离层。您可以通过使用先前渲染的帧来积累的积压来保存深度排序的复杂性,这实际上是您建议的framebuffer方法,添加了矢量模糊。
Since this will blur with other fragments you're ending up with a problem of transparency ordering. Hence you should apply this as a post processing effect, ideally with depth peeled layers. You can save on the depth sorting complexity by using a backlog of previously rendered frames to blend into, which is essentially the framebuffer method you suggested, with vector blur added.