Skip to content

Instantly share code, notes, and snippets.

@gamemachine
Last active September 24, 2018 23:59
Show Gist options
  • Select an option

  • Save gamemachine/d97869b20046c2f3b515679f4c7b266f to your computer and use it in GitHub Desktop.

Select an option

Save gamemachine/d97869b20046c2f3b515679f4c7b266f 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);
}
// Call from surface shader like so
ClipBounds(_Mask1, IN.worldPos.xz);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment