S
Shadowblitz16
Guest
can someone tell me what is wrong with my shader and setter script?
it just makes my sprite invisible
this is my palette
it just makes my sprite invisible
Code:
uniform sampler2D palette;
uniform float paletteIndex;
varying vec2 v_vTexcoord;
void main()
{
vec4 _color = texture2D(gm_BaseTexture, v_vTexcoord);
vec4 _indexedColor = texture2D(palette, vec2(_color.r, paletteIndex));
gl_FragColor = vec4(_indexedColor.rgb, _color.a); // This way we'll preserve alpha
}
Code:
/// @description palette_set()
/// @param palette
/// @param index
var _sampler = shader_get_sampler_index(shd_palette, "palette");
var _texture = sprite_get_texture(argument[0], 0);
var _uniform = shader_get_uniform(shd_palette, "paletteIndex");
shader_set(shd_palette)
texture_set_stage(_sampler, _texture);
shader_set_uniform_f(_uniform, argument[1]);