Multipass clip shader question

I want to clip out everything inside a view frustum with clipping planes and keep the outside.

The frustum clips away the inside but keeps the outside.

I did this with four planes and four materials on the game object.

Is there a smarter way to do this?

Can a multi pass clipping shader save clipped pieces from the planes with only one material?

Presumably you’re using a custom shader that you’re passing the plane to to clip() against?

You could just pass this “view’s” view projection matrix to the shader, and then do:

float4 frustumPos = mul(_CustomViewProjection, float4(worldPos.xyz, 1.0));
if (!any(saturate(abs(frustumPos.xyz) - frustumPos.w))))
  discard;