Doing basic distortion in a fragment shader

HI I have a program that currently renders a bunch of stuff onto a texture. I was hoping to be able to re render that texture with various distortion effects based on user interaction. I can figure out the whole user interaction thing by myself but I do not know any distortion techniques. An ideal situation is if I would be able to make a texture that is a map for distortion (sorta like a bump map) and then have the shader do it.

You can use a texture to map texture coordinates, e.g.

in vec2 texcoord;
uniform sampler2D u_coord_map; // GL_RG
uniform sampler2D u_texture;

void main() {
    vec2 t = texture(u_coord_map, texcoord).st;
    vec4 color = texture(u_texture, t);

How much use that is depends upon how easy it is to generate the coordinate mapping.

When you say “like a bump map”, it seems that you want to be able to generate texture coordinates based upon local distortion. That typically requires deconvolution, for which this technique may be useful.

Another technique which may be useful (it’s hard to say; “distortion” is a rather vague concept) is a radial basis network. This allows you to define a N-dimensional mapping using (source,destination) pairs of vertices such that each source vertex maps exactly to the corresponding destination vertex and the mapping is continuous. WebGL example.