Search code examples
opengldirectxpost-processing

Adding whirl effect on DirectX/OpenGL application


After we have finished rendering a frame either using DirectX or OpenGL in C++, I would like to add this "swirling" effect just on a portion of the frame. Something like this below:

enter image description here

So how do we normally achieve this?


Solution

  • You could either:

    1. Render a grid of vertices and use a vertex shader to rotate each vertex around the center according to its distance from the center. This would require lots of vertices towards the center, to maintain clean curvature.
    2. Render a single quad and use a fragment shader to similarly rotate the texture-coordinate. This would render more accurately, but would also be slower than the fragment shader.