Weird Issue with LUT shader

I am attempting to write a LUT shader similar to this or this, but am encountering problems when trying to implement the blue channel portion of the lookup algorithm. Whenever I add it to my code, a lot of the pixels become miss-colored :


Here is what the original colors are supposed to be like without the shader enabled:

And without the blue offset enabled:

Here is the fragment shader which performs the mappings:

"void main() {",
            "    highp vec2 uv = vUv0; // variable_vertex.xy; // interpolated at pixel's center",
            "",
            "float blueOffset[9] = float[](0.,0.125,0.25,0.375,0.5,0.625,0.75,0.875,0.875);",
    
            "vec4 color = texture2D(uColorBuffer,uv);",
             "int blueIndexY= int(floor(color.b * 8.));",

              "int blueIndexX = int(floor(mod(color.b * 64.,8.)));",
              "float lutX = color.r /8. + blueOffset[blueIndexX] ;",
               "float lutY =color.g /8. + blueOffset[blueIndexY];",
             "float filterOffset = 0.5/512.;",
             "vec2 newUV = vec2(lutX + filterOffset,lutY + filterOffset );",
             "vec4 checkColor = texture2D(uLUTTexture,newUV);",
             "gl_FragColor = checkColor;",

            "}"

I used an array to store the potential values of the blue offset in order to get rid of some of the potential issues from casting/to get rid of some casts. I have also calculated the values directly in the code but the output is the same. I assume it is an issue with rounding but none of my fixes have worked :frowning_with_open_mouth:.

Here is my scene: https://playcanvas.com/editor/scene/2181714

I was able to get around most of the discoloration by using a 1D LUT and clamping the blue offset from 0.5 to 1. I assume it is an issue by how I am using it to get into the texture.