Last active
July 6, 2020 14:33
-
-
Save TheAllenChou/b4681b7c48a16884088f55a63be14021 to your computer and use it in GitHub Desktop.
Smooth Quantization of Signed Distance Field Sample Points
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
float3 quantize(float3 p, float cellSize, float strength) | |
{ | |
float3 r = p / cellSize; | |
float3 f = floor(r); | |
float3 t = r - f; | |
return (f + smoothstep(0.0f, 1.0f, strength * (t - 0.5f) + 0.5f)) * cellSize; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment