Scissor test/early rejection

Is it possible to reject fragments from a camera’s rendering pipeline through either a scissor test, early rejection, or anything else? I need a camera to only render part of what it can see for performance reasons and no matter what I do I just absolutely cannot figure it out.

Currently Unity’s shaderlab syntax doesn’t support hardware scissor tests. However you can use this Scissor script which has been posted on this forum thread to modify the projection matrix of your camera.

Other than that you could write a shader where you can pass scissor planes or a scissor rect as parameter. Of course you have to do the clipping yourself inside the fragment shader.
One 3d plane can be represented by a single Vector4 (normal vector + distance).

I’m not sure how Unity actually implements it’s frustum culling. If it uses the camera’s actual projection matrix then the Scissor script would be much more effective as Unity would already filter out objects which bounds are outside the view frustum so they aren’t send to the GPU at all.

To those that responded to this topic, and to tothers: Thank you for trying to answer, but unfortunately that scissor script isn’t capable of increasing performance like I was looking for- it merely modifies the matrix, the number of fragments being drawn is still the same and unless I wanted to have a dynamically-allocated RT (which is expensive) what I wanted to do would not be possible. To solve this problem, I manually drew a mesh using a command buffer with a material on it that writes to the stencil, then it blits a fullscreen mat that writes 1 to the depth buffer on all but the stenciled area. This fires during BeforeForwardOpaque, which rejects fragments from being rendered that are not visible.

Here is the commandbuffer code:

        stencilObj.transform.position = targetPortal.transform.position;
        stencilObj.transform.rotation = targetPortal.transform.rotation;
        stencilObj.transform.Rotate(Vector3.up, 180, Space.Self);
        //stencilObj.transform.localScale = transform.lossyScale + new Vector3(0.01f, 0, 0);
        stencilObj.transform.localScale = transform.lossyScale + new Vector3(0, 0, 0.01f);
        _stencilBuffer.DrawMesh(gameObject.GetComponent<MeshFilter>().mesh, stencilObj.transform.localToWorldMatrix, depthHole);
        _stencilBuffer.Blit(BuiltinRenderTextureType.CurrentActive, BuiltinRenderTextureType.CurrentActive, depthMat);