Opengl es 模糊帧缓冲区内容
我可以不模糊纹理而是模糊帧缓冲区吗?以下着色器模糊纹理:Opengl es 模糊帧缓冲区内容,opengl-es,opengl-es-2.0,blur,Opengl Es,Opengl Es 2.0,Blur,我可以不模糊纹理而是模糊帧缓冲区吗?以下着色器模糊纹理: #ifdef GL_ES precision mediump float; #endif varying vec4 v_fragmentColor; varying vec2 v_texCoord; uniform vec2 resolution; uniform float blurRadius; uniform float sampleNum; vec3 blur(vec2); void main(void) { ve
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
uniform vec2 resolution;
uniform float blurRadius;
uniform float sampleNum;
vec3 blur(vec2);
void main(void)
{
vec3 col = blur(v_texCoord);
gl_FragColor = vec4(col, 1.0) * v_fragmentColor;
}
vec3 blur(vec2 p)
{
if (blurRadius > 0.0 && sampleNum > 1.0)
{
vec3 col = vec3(0);
vec2 unit = 1.0 / resolution.xy;
float r = blurRadius;
float sampleStep = r / sampleNum;
float count = 0.0;
for(float x = -r; x < r; x += sampleStep)
{
for(float y = -r; y < r; y += sampleStep)
{
float weight = (r - abs(x)) * (r - abs(y));
col += texture2D(CC_Texture0, p + vec2(x * unit.x, y * unit.y)).rgb * weight;
count += weight;
}
}
return col / count;
}
return texture2D(CC_Texture0, p).rgb;
}
\ifdef glu
精密中泵浮子;
#恩迪夫
不同的vec4 v_碎片颜色;
可变矢量2 v_texCoord;
均匀vec2分辨率;
均匀浮动半径;
均匀浮动静压箱;
vec3模糊(vec2);
真空总管(真空)
{
vec3 col=模糊(v_texCoord);
gl_fragmentColor=vec4(col,1.0)*v_fragmentColor;
}
vec3模糊(vec2 p)
{
如果(模糊半径>0.0&&sampleNum>1.0)
{
vec3列=vec3(0);
vec2单位=1.0/分辨率.xy;
浮动r=半径;
浮动样本步骤=r/样本静压箱;
浮点数=0.0;
for(float x=-r;x
如何使已绘制的帧缓冲区像素模糊而不是纹理像素?您必须将帧缓冲区复制到纹理并使其模糊。顺便说一句,那里的2D内核相当昂贵。您可以使用高斯权重将其拆分为单独的水平和垂直操作(尽管其他函数也是可分离的)。我找到的第一个链接是。我知道这个着色器很糟糕。没有权重,复杂性是
O(n^2)
而不是O(n)
。但是为什么我必须将帧缓冲区复制到纹理@jozxyqk?因为我知道你不能从着色器中读取默认帧缓冲区。@jozxyqk我已经检查过了,因为GPU可以并行处理多个像素: