shader vertex program for pixel offset?

Apr 18, 2011 at 10:21pm

shader vertex program for pixel offset?

Hi Everyone,
Am trying to make a glsl shader for a simple task, but it continues to elude me. I just want to shift a rendered image along the x axis, by a constant _pixel_ (i.e. on-screen) value. I want to avoid perspective, so that every piece of the scene moves over (as if it were a flat picture).

I know that I can render a scene to a gl texture, but that slows things down. I have been attempting to manipulate the matrices inside the shader. Since multiplying by the gl_ModelViewProjection matrix gives you on-screen coordinates, I thought that this would do it:

gl_Position = (gl_ModelViewProjectionMatrix * gl_Vertex) + vec4(displacement,0.0, 0.0, 1.0);

but when I change displacement, I still get perspective (and it behaves the same as if I had added to the vertex first, then multiplied by the MVPM.

Any ideas?!? Thanks!

Apr 22, 2011 at 2:55pm

in case anyone was wondering, after lots of bizarre shader experimentation, I found it solvable without shaders via using glviewport (to to move the rendered image around the canvas.


You must be logged in to reply to this topic.