PDA

View Full Version : Tranlsating Texture Channels (R,G,B,A separately)



Rennie Johnson
11-08-2011, 04:19 PM
Is there a way in OpenGL or GLSL to translate an RGBA 2D texture by any number of texels (more than GL_MIN_PROGRAM_TEXEL_OFFSET & GL_MAX_PROGRAM_TEXEL_OFFSET allow for)separately for Red, Geen, Blue and Alpha Channels?

I am taking film scans that have separate color channels captures that are out of registration and aligning them to a reference.

For example, I want to move the red channel 2 texels left and 5 texels down, and the green channel 24 texels right and 13 texels up, etc.

I know I can move texel locations in a Vertx Shader without limitation, but I wouldn't know how to offset individual color channels.

I appreciate your guidence.

Alfonse Reinheart
11-08-2011, 04:58 PM
Access the texture multiple times from the shader, and pick out the components you want for the final color.

Bruce Wheaton
11-09-2011, 11:54 AM
You have a film scan with an alpha channel? That's quite a trick.

Anyway, yes, use a fragment shader and sample in a slightly different place for each color component as needed, then combine.

That has the advantage of not needing to be the same across the whole image, which might help, depending on how your color shift happened.

Bruce

V-man
11-11-2011, 05:05 AM
What is GL_MAX_PROGRAM_TEXEL_OFFSET for?

Alfonse Reinheart
11-11-2011, 11:16 AM
What is GL_MAX_PROGRAM_TEXEL_OFFSET for?

It is the maximum offset that can be used in the GLSL `textureOffset` or `texelOffset` functions.