【笔记】图像技术-高斯模糊

| 发布     | 分类 游戏技术  | 标签 游戏技术 

相关文档

《英雄联盟》战争迷雾 https://technology.riotgames.com/news/story-fog-and-war

高斯模糊

img

线性采用的高效高斯模糊

img

img

img

img

uniform sampler2D image;
 
out vec4 FragmentColor;
 
uniform float offset[5] = float[](0.0, 1.0, 2.0, 3.0, 4.0);
uniform float weight[5] = float[](0.2270270270, 0.1945945946, 0.1216216216,
                                  0.0540540541, 0.0162162162);
 
void main(void) {

    FragmentColor = texture2D(image, vec2(gl_FragCoord) / 1024.0) * weight[0];

    for (int i=1; i<5; i++) {

        FragmentColor +=
            texture2D(image, (vec2(gl_FragCoord) + vec2(0.0, offset[i])) / 1024.0)
                * weight[i];

        FragmentColor +=
            texture2D(image, (vec2(gl_FragCoord) - vec2(0.0, offset[i])) / 1024.0)
                * weight[i];
    }
}

img

uniform sampler2D image;
 
out vec4 FragmentColor;
 
uniform float offset[3] = float[](0.0, 1.3846153846, 3.2307692308);
uniform float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703);
 
void main(void) {

    FragmentColor = texture2D(image, vec2(gl_FragCoord) / 1024.0) * weight[0];

    for (int i=1; i<3; i++) {

        FragmentColor +=
            texture2D(image, (vec2(gl_FragCoord) + vec2(0.0, offset[i])) / 1024.0)
                * weight[i];

        FragmentColor +=
            texture2D(image, (vec2(gl_FragCoord) - vec2(0.0, offset[i])) / 1024.0)
                * weight[i];
    }
}

图像滤镜 可分离性

上一篇: 【笔记】 图像技术-缩放图片
下一篇: 【笔记】《英雄联盟》战争迷雾