1
\$\begingroup\$

How do I run an OpenGL shader on just a portion of an off screen texture and leave the rest of the texture unmodified? Are there any calls that restrict the sampled pixels to just a rectangle or do I have to filter out the rectangle in the shader code?

\$\endgroup\$
1
  • \$\begingroup\$ What are you actually trying to achieve? This sounds a bit like a problem you might be creating by using the wrong strategy when rendering to (or using the) render texture. \$\endgroup\$
    – Mario
    Jan 18, 2014 at 11:21

1 Answer 1

2
\$\begingroup\$

Yes, you can restrict rendering to just a rectangle by using either the viewport rect or the scissor rect. These can be set by the glViewport and glScissor calls, respectively.

The distinction is that setting the viewport will pretend that the viewport is the entire render target. Any geometry you render will be scaled down to the viewport; the viewport will always extend from -1 to 1 in NDC (post-projective) coordinates. The scissor rect, on the other hand, doesn't rescale any geometry or alter any coordinates - it simply suppresses rendering to any pixels outside the rect.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .