Skip to content

Instantly share code, notes, and snippets.

@gamemachine
Created November 1, 2019 20:54
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 gamemachine/d24b6fe7e092de05ed1e842f9f9b8357 to your computer and use it in GitHub Desktop.
Save gamemachine/d24b6fe7e092de05ed1e842f9f9b8357 to your computer and use it in GitHub Desktop.
void ClipBounds(float4 bounds, float2 pos) {
float2 min = bounds.xy;
float2 max = bounds.zw;
float a = step(min.x, pos.x);
float b = step(pos.x, max.x);
float c = step(min.y, pos.y);
float d = step(pos.y, max.y);
clip(3.0f - a - b - c - d);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment