# 反向

``````void main()
{
FragColor = vec4(vec3(1.0 - texture(screenTexture, TexCoords)), 1.0);
}
``````

# 灰度

``````void main()
{
FragColor = texture(screenTexture, TexCoords);
float average = (FragColor.r + FragColor.g + FragColor.b) / 3.0;//取所有的颜色分量，将它们平均化
FragColor = vec4(average, average, average, 1.0);
}
``````

``````FragColor = texture(screenTexture, TexCoords);
float average = 0.2126 * FragColor.r + 0.7152 * FragColor.g + 0.0722 * FragColor.b;
FragColor = vec4(average, average, average, 1.0);
``````

# 核效果

``````const float offset = 1.0 / 300.0;
``````
``````	vec2 offsets[9] = vec2[](
vec2(-offset,  offset), // 左上
vec2( 0.0f,    offset), // 正上
vec2( offset,  offset), // 右上
vec2(-offset,  0.0f),   // 左
vec2( 0.0f,    0.0f),   // 中
vec2( offset,  0.0f),   // 右
vec2(-offset, -offset), // 左下
vec2( 0.0f,   -offset), // 正下
vec2( offset, -offset)  // 右下
);

float kernel[9] = float[](
-1, -1, -1,
-1,  9, -1,
-1, -1, -1
);

vec3 sampleTex[9];
for(int i = 0; i < 9; i++)
{
sampleTex[i] = vec3(texture(screenTexture, TexCoords.st + offsets[i]));//纹理坐标(s,t,p,q)
}
vec3 col = vec3(0.0);
for(int i = 0; i < 9; i++)
col += sampleTex[i] * kernel[i];

FragColor = vec4(col, 1.0);
``````