Updated after many stupid questions
Objective: To apply the texture palette means GL-shaders (emulate Indexed8 texture format). Internet is full of articles on a subject, and all contained the same solution. I have it, unfortunately, it don't work for me.
So.
The fragment shader:
uniform sampler2D texture;
uniform sampler2D palette;
uniform int paletteIndex;
layout (origin_upper_left) in vec4 gl_FragCoord;
void main()
{
int colorIndex = int(texture2D(texture, gl_TexCoord[0].xy, 0).r * 255);
gl_FragColor = texelFetch(palette, ivec2(colorIndex, paletteIndex), 0);
}
Vertex shader:
void main () {
gl_Position = ftransform ();
gl_TexCoord [0] = gl_MultiTexCoord0;
}
This is my result (left - my picture, right - original):
Damn, I just set incorrect vertex coords! >.<
Thanks for good man who tried to help. Now I know that different from texture2d and fetchTexel and found reason of issue! D:
Well...
I made a few mistakes:
GL.Viewport (0, 0, w * 2, h * 2);
because of this, the image is twice the original.All these problems have been solved, and now correctly applies palette to the original image. Correct shaders shown above. Thank you for your attention.