The voxel_table format is: { {0.93456,0.235466,0.112356}, {0.767734,0.342211,0.324235}, ... }.
I already checked that the values are random.
This is my shader code (the Lua part of the script isn't important):
Code: Select all
shader = love.graphics.newShader([[
extern vec4 voxel_table[1024];
int index;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pc)
{
vec4 pixel = Texel(texture, texture_coords); // current pixel
index=int(pixel.x);
pixel.rgba = vec4(voxel_table[index][0],voxel_table[index][1],voxel_table[index][2],voxel_table[index][3]);
return pixel;
}
]])
So I heard that indexing arrays in GLSL with a variable is glitchy or not possible at all. I don't know anything about GLSL. There is no error, but all pixels are colored one color, which is not supposed to happen (remember, I need stripes).
My suspicion is that the 'index' variable in the GLSL code doesn't want to update/assign to pixel.x for some reason. I back this statement up with the fact that when I change index to: "index = int(0)" or "index = int(5)", etc, all pixels will change to one color (but no stripes, of course). Any help would be appreciated.