Hi there,
This is my first post on these boards, so if i’m doing something wrong im very sorry!
I’m trying to use a lookup table in a fragment shader to change the location of pixels of a texture (eg: warping an image).
From my research it seems the best way to do this is to use a Texture as a lookup table, and then i can do something like:
uniform sampler2D texCol;
uniform sampler2D texLUT;
void main(void)
{
vec4 uv = texture2D( texLUT, gl_TexCoord[0].xy );
vec4 col = texture2D(texCol,uv.xy);
gl_FragColor = col;
}
This seems to work well, but since the texture values are normalised between 0 and 1, i have to normalise my coordinates in my lookup table. This is leading to a degredation of quality, I can only assume because of rounding issues. (I’m using very large textures 1920 x 1080)
I’m using an NVidia Geforce 9800 gt card so judging by a couple of posts i’ve read (unfortunately i cant find the links to hand now) it looks like unfortunately i cannot use texelfetch to get my coordinates.
Edit:
I’m also working in Java and using JOGL, so theoretically should have access to texture rectangles (since the JOGL texture class stores textures as a texture rectangle by befault) but i can’t seem to get the textureRect command to work in my fragment shader…
Does anyone have any suggestions about how i can a) use unnormalised coordinates in a lookup table (the values in the table will need to be between 1920 and 1080 roughly) or b) improve the accuracy of the normalised floating point values in the lookup table.
Thanks!