void main() {
// calculate what image pixel we're on within texture [width*3 x height]
vec2 pixel_pos = vec2(floor(mImageWidth * 3.0 * gl_TexCoord[0].x),
floor(mImageHeight * gl_TexCoord[0].y));
// only process pixels within width
if (pixel_pos.x > mImageWidth)
{
gl_FragColor = vec4(0, 0, 0, 0.0);
}
else
{
float test_offset = 0.5; // only works if test_offset == 0.5; why??
float r_indx = (pixel_pos.x*3.0)+0.0+test_offset;
float g_indx = (pixel_pos.x*3.0)+1.0+test_offset;
float b_indx = (pixel_pos.x*3.0)+2.0+test_offset;
float r_tex = texture2D(mTextureSampler, vec2(r_indx/(mImageWidth*3.0), gl_TexCoord[0].y)).x;
float g_tex = texture2D(mTextureSampler, vec2(g_indx/(mImageWidth*3.0), gl_TexCoord[0].y)).x;
float b_tex = texture2D(mTextureSampler, vec2(b_indx/(mImageWidth*3.0), gl_TexCoord[0].y)).x;
vec3 rgb = vec3(r_tex, g_tex, b_tex);
gl_FragColor = vec4(rgb, 1.0);
}
}