Skip to content

Instantly share code, notes, and snippets.

@kunofellasleep
Last active October 16, 2018 21:25
Show Gist options
  • Save kunofellasleep/ddbe307c732cff232f3b4379ccedc1c9 to your computer and use it in GitHub Desktop.
Save kunofellasleep/ddbe307c732cff232f3b4379ccedc1c9 to your computer and use it in GitHub Desktop.
kernel void sharpen(
texture2d<float, access::write> outTex [[texture(0)]],
texture2d<float, access::read> inTex [[texture(1)]],
uint2 gid [[thread_position_in_grid]]) {
float4 c = float4(0.0, 0.0, 0.0, 1.0);
//隣接ピクセルを使用して色を決定するためのパラメータ
float weight[3][3] = {
{0, -1, 0},
{-1, 5, -1},
{0, -1, 0}
};
for (int u=0; u<3; u++) {
for (int v=0; v<3; v++) {
float3 a = inTex.read(gid + uint2(u-1, v-1)).rgb;
c.rgb += weight[u][v] * a;
}
}
outTex.write(c.rgba, gid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment