I'm trying to pass arbitrary int data to the shader by treating each of RGBA as an 8-bit int. I'm using these values as lookups into another texture. The results I've gotten so far give incorrect results, however, often performing lookups into an adjacent lookup instead.
I read that TexelFetch doesn't give correct results, here: https://github.com/godotengine/godot/issues/31732 So, I'm using the following workaround:
vec4 Get_Texel( sampler2D image, ivec2 position, int level_of_detail ) {
vec2 texel = 1.0 / vec2(textureSize(image, 0));
vec2 final_position = (vec2(position) * texel) + (texel * 0.5);
return texture(image, final_position, float(level_of_detail));
}
Are there any existing solutions for seemlessly working with int arrays in shaders?