Skip to content

Instantly share code, notes, and snippets.

@toxicFork
Created March 14, 2015 19:25
Show Gist options
  • Save toxicFork/b2f3244b2c8db42d9d2b to your computer and use it in GitHub Desktop.
Save toxicFork/b2f3244b2c8db42d9d2b to your computer and use it in GitHub Desktop.
float4 _planePos;
float4 _planeNorm;
#if (CLIP_TWO || CLIP_THREE)
float4 _planePos2;
float4 _planeNorm2;
#endif
#if (CLIP_THREE)
float4 _planePos3;
float4 _planeNorm3;
#endif
void PlaneClip(float3 posWorld) {
#if CLIP_THREE
clip(float3(
distanceToPlane(_planePos.xyz, _planeNorm.xyz, posWorld),
distanceToPlane(_planePos2.xyz, _planeNorm2.xyz, posWorld),
distanceToPlane(_planePos3.xyz, _planeNorm3.xyz, posWorld)
));
#else //CLIP_THREE
#if CLIP_TWO
clip(float2(
distanceToPlane(_planePos.xyz, _planeNorm.xyz, posWorld),
distanceToPlane(_planePos2.xyz, _planeNorm2.xyz, posWorld)
));
#else //CLIP_TWO
clip(distanceToPlane(_planePos.xyz, _planeNorm.xyz, posWorld));
#endif //CLIP_TWO
#endif //CLIP_THREE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment