Difference between viewports and scissor rectangles?

Started by
3 comments, last by ouraqt 17 years, 2 months ago
I know that viewports are used to render only to a particular rectangle on the window - but from what I understand, using scissor tests does the same thing. What is the difference between these two, and should I prefer one over the other?
Advertisement
Viewports are basically scaled views, the left side is 0 and the right side is 1. The entire view will be scaled down into that viewport after everything is projected.

Scissor tests clip to a rectangle inside that viewport. Instead of rendering from 0 to 1, you render from .2 to .8, with black bars on the outside. This actually cuts off a portion of what would normally be visible (if you used a viewport of the same size, you'd see the same amount but shrunk slightly).

Viewports are used for full views (consider 3D Studio Max, each viewport is the full view from that angle, but fit into a single square). Scissor tests are used to cut out extra pixels that you don't want/need to be affected (lights in deferred rendering, for instance, everything outside the range is not affected, so why bother calculating that if you already know it's not lit, just scissor around the projected sphere and forget about everything beyond that).
Oh, so basically with viewports, you get the whole scene rendered but at the size and position of your choosing, and scissor tests actually mask stuff out.

Nice. Are scissored areas always rectangular?
Another way of considering the difference is that viewports change the actual output and functionality yet, for the most part, scissor rects are an optimization. There are a few articles around that use scissor rects to reduce shadowing fill-rate requirements - by creating a 2D bounding area for a stencil shadow pass you can vastly improve the fill-rate utilization...

Quote:Original post by ouraqt
Are scissored areas always rectangular?
Given that the function prototype expects a RECT input, yes! [smile]

If you want per-pixel masking you might want to consider a stencil buffer.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Thanx!

This topic is closed to new replies.

Advertisement