I think I got one last mystery problem.
I fill texture:
GL11.glTexImage1D(target, 0, ARBTextureRg.GL_R16F, 2, 0, GL11.GL_RGBA, GL11.GL_FLOAT, makeLightData());
with this data:
buffer.put(1f).put(0).put(0).put(0);
buffer.put(0).put(1).put(0).put(0);
As you can see I make 2 pixel wide texture, which’s first pixel is red, and second pixel is green.
In fragment shader, I multiply the output of my game color by this:
vec4 col = texture(u_lights, 0.0);
so that I know what kind of color I’m picking from my 1d texture.
The problem is that when texcoord is 0.0, it picks the red color. When texoord is 1.0, it still picks the red texel. Any suggestions?
EDIT-
I fixed it.
I needed to do image for GL_RED so that I only had 1 component / texel.
GL11.glTexImage1D(target, 0, ARBTextureRg.GL_R16F, 2, 0, GL11.GL_RED, GL11.GL_FLOAT, makeLightData());
ARBTextureRg.GL_R16F allows to send floats bigger than 1. That means you can send 10 or 800 or 10055 or whatever you want and that value will arrive to the shader.
Also, trying to access 1.0 texel basically tells GLSL to access texel of 0.0, because it probably does inputTexel%1, which means it is capped to 1.0.
So now I can basically send an array of floats to shaders via texture and access that array by doing:
float index=float(i) / arraySize;
texture(u_lights, index).r;
There is a lot to explain so I will just write a tutorial in a few days.