像素着色器中可以实现哪种模糊? [英] What kind of blurs can be implemented in pixel shaders?

查看:204
本文介绍了像素着色器中可以实现哪种模糊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

高斯,框,径向,方向,运动模糊,缩放模糊等

Gaussian, box, radial, directional, motion blur, zoom blur, etc.

我读到高斯模糊可以通过可以在像素着色器中实现的传递进行分解,但是找不到任何样本.

I read that Gaussian blur can be broken down in passes that could be implemented in pixel shaders, but couldn't find any samples.

假定像素着色器无法实现任何与自身无关的效果,对吗?

Is it right to assume that any effect that concerns itself with pixels other than itself, can't be implemented in pixel shaders?

推荐答案

只要您能够将信息传递给着色器,就可以实现所有功能.

You can implement everything, as long you are able to pass information to the shader.

在这种情况下,技巧是执行多遍渲染.最终的着色器将使用一定数量的采样器,这些采样器是非模糊源,用于计算模糊值.

The trick, in this cases, is to perform a multiple pass rendering. The final shader will take a certain number of samplers, that are the non-blurred sources, which are used to compute blurred values.

例如,可以使用多个纹理来基于累积缓冲区来模拟效果.

For example, using multiple textures is possible to emulate effects based on the accumulation buffer.

要实现高斯模糊,请将场景渲染到frambuffer对象上,并在颜色附件上附加纹理.这是第一遍.

to implement a gaussian blur, render the scene onto a frambuffer object, with attached a texture on the color attachment. This is the first pass.

作为第二遍,渲染纹理四边形,其中纹理是第一步中生成的纹理四边形.纹理坐标从顶点阶段传递到片段阶段,并在四边形上进行插值.确实,每个片段都有纹理坐标.为每个坐标应用一个偏移量以获取基础坐标周围的纹理,并执行高斯模糊.

As second pass, render a textured quad, where the texture is the one generated in the first step. Textures coordinates are passed from vertex stage to fragment stage, interpolated across the quad. Indeed you have texture coordinate for each fragment; apply a offset for each coordinate to fetch textels around the underlying one, and perform the gaussian blur.

这篇关于像素着色器中可以实现哪种模糊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆