问题描述
是否可以通过GLSL在Photoshop中使高斯模糊?我只找到了一些工作原理相同的着色器示例。但是,如果半透明的模糊效果,它们都无法返回与Photoshop相同的结果。
我进行两次通过乒乓高斯模糊处理,其中我使用两个帧缓冲区并通过统一更改方向。屏幕截图上的迭代次数和sigma都等于2。
P.S。经过两天的研究,我没有找到真正有用的答案,我不敢相信没有人愿意修复/制作此着色器。
varying vec2 uv;
uniform float iterations;
uniform float sigma;
uniform vec2 texelSize;
uniform vec2 direction;
void main() {
vec4 color = texture2D(texture,uv);
float weight = 0.0;
float totalWeight = 1.0;
for(float i = 1.0; i <= iterations; i++) {
weight = exp(-(i * i) / (2.0 * sigma * sigma)); // gaussian 1D
color += texture2D(texture,uv - i * direction * texelSize) * weight;
color += texture2D(texture,uv + i * direction * texelSize) * weight;
totalWeight += 2.0 * weight;
}
color.rgb /= totalWeight;
/*=========================*/
gl_FragColor = color;
/*==========OR============*/
gl_FragColor = vec4(color.rgb,1.0);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)