Hey guys,
does Unity3d allow us to perform scissor test (draw only in a certain rectangle on the screen) per-object? It can certainly be emulated by a shader, but I’m sure it isn’t an optimal solution.
Cheers!
Hey guys,
does Unity3d allow us to perform scissor test (draw only in a certain rectangle on the screen) per-object? It can certainly be emulated by a shader, but I’m sure it isn’t an optimal solution.
Cheers!
I know this is old, but I haven’t seen this mentioned. When I want a scissor rect, I simply set the X-Y ranges of the rectangle as a uniform float4 in my pixel shader, and then I use the “clip” function to reject any pixels outside of that. This solution avoids messing with (potentially messing up) projection matrices, or having special cameras to support this functionality which conceptually has nothing to do with cameras or projection.
See also: http://forum.unity3d.com/threads/37612-Scissor-rectangle
You have to use Camera’s Culling Mask functionality.
In your case, you would probably have two cameras which would both have the same transform (position, rotation)
Create a new layer ‘ClippedObjects’.
The second camera which is used for clipping should have its Normalized View Rect and Culling Mask (to ‘ClippedObjects’) changed appropriately, also set Clear Flags to Don’t clear, and set Depth value to 1, so this Camera would render objects after the first Camera.
For objects which should be clipped set Layer to ‘ClippedObjects’ aswell.
And there you have it, so rendering will look something like this:
Camera1 renders:
Camera2 renders: