black sampler2D
sampler2D palettnr is for some reason completely black.
The other sampler2D variable works.
My other two custom variables are set correctly (from, to).
Fragment shader:
uniform sampler2D sol_texture;
uniform sampler2D palettenr;
//0 means unused since first color in palette is transparent
uniform vec4 from;
uniform vec4 to;
in vec2 sol_vtex_coord;
out vec4 FragColor;
void main() {
vec4 tex_color = texture(sol_texture, sol_vtex_coord);
FragColor = tex_color;
for(int i = 0; i < 4; i++){
if(from[i] > 0 && tex_color == texture(palettenr,vec2(from[i],0)))
FragColor = texture(palettenr,vec2(to[i],0));
}
if(tex_color == vec4(0.0, 0.0, 0.0, 1.0))
FragColor = texture(palettenr,vec2(15,0));
}
Lua code:
local sprite = self:get_sprite()
local shad = sol.shader.create("colorswitch")
shad:set_uniform("palettenr", sol.surface.create("palette.png"))
shad:set_uniform("from", {26,29,27,30})
shad:set_uniform("to", {24,49,23,17})
sprite:set_shader(shad)
palette.png:
OS: ArchLinux
Solarus Version: 1.6.0-1
Edited by Sebastian Riedel