I am wondering what would be the best way to achieve pixel displacement in OpenGL in terms of performance. What I mean by pixel displacement is a way to “move” pixels around based on their parameters (color, luminosity, etc).
For example I have a texture in memory and I want to process it in a way, that X axis remains the same, but I “move” the pixels along the Y axis based on RED channel value.
What I do now is I render texture_width * texture_height points with GL_POINT, where the vertex position is the 2D position from the original image, then in Vertex Shader I read the texture pixels based on the vertex position and change the vertex position based on the criteria (mentioned RED channel).
Is there a way to do it more efficiently? Doing it in the Fragment Shader would probably be a better idea but is it possible at all?
Perhaps Compute Shader?
Thanks in advance for all the suggestions.