I'm guessing that you put your array of data into an image (via SkBitmap?), and then sampled from that?
Yes, that's right.
What do you mean by the values being incorrect?
Let me give you an example that shows what the problem is.
Assuming the first element of array/texture is vec4(1, 2, 3, 255), the code below will produce the image that has one color - (1,2,3,255).
uniform shader uCoord;
vec4 main(float2 p) {
vec4 coord = sample(uCoord, float2(0.5, 0.5)); // get first element
return coord;
}
Now let's add a simple comparison as shown below.
vec4 main(float2 p) {
vec4 coord = sample(uCoord, float2(0.5, 0.5));
if (coord.r == 1) { <- it should be true
return vec4(0,255,0,255);
}
return coord; <- but still returns here
}
In the example above, I would expect the output to be vec4 (0, 255, 0, 255), but it is still (1, 2, 3, 255).
3) If you happen to be using any color management in your Skia application, then making an image shader to hold your data will apply color space conversion, which might not be what you want. You can prevent that from happening by creating a "raw" image shader instead [1].
I'm afraid that the raw shader is not available in the Android implementation. I couldn't find makeRawShader at
https://cs.android.com/.
I see that you're using sample(), so you must be on an older branch. That was renamed (so it would now look like `uCoord.eval(coord)`). You may need to update to a newer branch to get raw shader support, for example.