Skip to content

Instantly share code, notes, and snippets.

@TheAllenChou
Last active July 6, 2020 14:33
Show Gist options
  • Save TheAllenChou/b4681b7c48a16884088f55a63be14021 to your computer and use it in GitHub Desktop.
Save TheAllenChou/b4681b7c48a16884088f55a63be14021 to your computer and use it in GitHub Desktop.
Smooth Quantization of Signed Distance Field Sample Points
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