Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- varying mediump vec2 var_texcoord0; //Original texture coordinates of current pixel
- uniform mediump sampler2D texture_sampler; //I'm assuming this is objects original texture
- uniform mediump sampler2D palette; //Texture of color palettes (palette colors goes in rows)
- uniform mediump float palette_count = 1.0; //Tells the shader how many palettes you have
- uniform mediump float palette_index = 0.0; //Telss the shader which palette to choose
- void main()
- {
- float mediump increment = 1.0/palette_count; //Value for getting palette index
- float mediump y = increment * palette_index + increment * 0.5; // + safety measure for floating point imprecision
- vec4 mediump color = texture2D(texture_sampler, var_texcoord0.xy); //Original grayscale color used as collumn index
- vec4 mediump new_collor = texture2D(palette, vec2(color.r, y)); //get color from palette texture
- float mediump a = step(0.00392, color.a); //check if transparent color is less than 1/255 for backgrounds
- new_color.a *= a; //if BG is transparent, then alpha is multiplied by 0
- gl_FragColor = new_color; //Set output color
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement