Skip to content

Instantly share code, notes, and snippets.

@andybak
Created August 29, 2017 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andybak/308bcb11118691fecda084c5b1aba814 to your computer and use it in GitHub Desktop.
Save andybak/308bcb11118691fecda084c5b1aba814 to your computer and use it in GitHub Desktop.
float fBoxCheap(float3 p, float3 b) { //cheap box
return vmax(abs(p) - b);
}
inline float fBox(float3 p, float3 b) {
float3 d = abs(p) - b;
return length(max(d, float3(0,0,0))) + vmax(min(d, float3(0,0,0)));
}
inline float DistanceFunction(float3 pos)
{
float t = _Time.x;
pModMirror2(pos.xy, float2(t,t));
float box = fBox(pos, float3(1,1,1));
float sphere = length(pos - float3(1,1,1)) - 1;
float d = min(box,sphere);
float guard = -fBoxCheap(pos, float3(0.25,0.25,0.25));
guard = abs(guard) + 0.05;
return d;
return min(d,guard);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment