Search code examples
openglvertex-shader

OpenGL: blur only one part of the texture; can using vertex shader speed up?


Let's say there is one texture: 6000x6000

I only need to blur one part, let's say the center rectangle 100x100

If I use vertex shader to put the interested area to this center rectangle, by inputting the coordinates of the 4 points and their corresponding texture coordinates in the big texture, I think the fragment shader only process the pixels in the center rectangle.

In my understanding, a regular GPU cannot really handle 6000x6000 pixels concurrently; it will divide to several segments. Now with 100x100, all pixels can be processed simultaneously, so it would be faster.

Is my understanding correct?


Solution

  • You can do a "render to texture", so you can use your "vertex shader" to select the area you want to blur... and then your fragment shader will apply the blur only in that area.

    your understanding seems to be correct: consider that the GPU will only spend efford processing the fragments INSIDE the area determined by your vertex shader, so if you set your vertex to a subset of your target [just like the screen, your target may be a texture, via framebuffers], then your GPU will process only the desired area.