Skip to content

Instantly share code, notes, and snippets.

@XProger
Last active February 2, 2017 00:30
Show Gist options
  • Save XProger/fab4cc2507fc6442a308f0a5bd1051e5 to your computer and use it in GitHub Desktop.
Save XProger/fab4cc2507fc6442a308f0a5bd1051e5 to your computer and use it in GitHub Desktop.
Get average color for 3x3 kernel by 4 fetch using bilinear filter
vec4 dx = vec4(0.25, 0.96, -0.25, -0.96) * uTexelSize.xyxy + vTexCoord.xyxy;
vec4 dy = vec4(0.25, 0.96, -0.25, -0.96) * uTexelSize.yxyx + vTexCoord.yxyx;
vec4 average = (texture2D(sTex, dx.zy) + texture2D(sTex, dx.xw) +
texture2D(sTex, dy.yx) + texture2D(sTex, dy.wz)) * 0.25;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment