Skip to content

Instantly share code, notes, and snippets.

@akella
Last active August 29, 2025 21:16
Show Gist options
  • Save akella/0bdeb9140a6a6223ee81b9f25f7c88ca to your computer and use it in GitHub Desktop.
Save akella/0bdeb9140a6a6223ee81b9f25f7c88ca to your computer and use it in GitHub Desktop.
TSL snippets
const sat = Fn(([rgb,intensity])=> {
const L = vec3(0.2125, 0.7154, 0.0721);
const grayscale = vec3(dot(rgb, L));
return mix(grayscale, rgb, intensity);
});
const uvBorder = Fn(([uv, width]) => {
let uv1 = uv;
let uv2 = uv.oneMinus()
let d = fwidth(uv1);
let d1 = fwidth(uv2);
let s = smoothstep(
mul(d, add(width, 0.5)),
mul(d, sub(width, 0.5)),
uv1
);
let s1 = smoothstep(
mul(d1, add(width, 0.5)),
mul(d1, sub(width, 0.5)),
uv2
);
let alpha = max(s.x, s.y);
let alpha1 = max(s1.x, s1.y);
let finalAlpha = max(alpha, alpha1);
return finalAlpha;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment