Last active
August 29, 2025 21:16
-
-
Save akella/0bdeb9140a6a6223ee81b9f25f7c88ca to your computer and use it in GitHub Desktop.
TSL snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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