Applying pixel shader effect not to the entire texture

Started by
3 comments, last by Crusty 15 years, 6 months ago
Simple question: how to use the "pixel shader" not to an entire texture (screen) but just a part of it. (part square)
Advertisement
A pixel shader is only applied to pixel in the geometry that you're rendering. Usually with post-processing, where you want the shader to be applied to the entire screen, you render a full-screen quad (usually using transformed vertices). If you modify the coordinates of the vertices you're rendering, you can have the shader applied to any shape you want.
Sirob Yes.» - status: Work-O-Rama.
In any case, one can always use a "mask" texture to determine where specific code is executed in any given shader. You could for instance apply a certain section of code to only areas where the alpha channel of a texture is greater than 0.5.

This can be explicitly done using if() blocks, or implicitly using lerp.
Or simplier, just using Scissor Test...
or test for U,V coordinates

if(u > 0.2 && u < 0.8)
{
//do shader
}
... nothing impossible ...

This topic is closed to new replies.

Advertisement