Jump to content
  • Advertisement
Sign in to follow this  
ouraqt

Difference between viewports and scissor rectangles?

This topic is 4311 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!