float u = (float) (x + px * img.getWidth()) / (float) globalXres;
float v = (float) (y + py * img.getHeight()) / (float) globalYres;
final Vector4 col;
if (tce == null) col = c.valueRGBA(u, v);
else col = tce.sample(x, y);
final Vector3 color = new Vector3();
int val;
// !!UGH TODO: optimize this!!
if (mode == 0) {