1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-03-14 23:35:17 +00:00
Pixelorama/src/Shaders/SetIndices.gdshader
Emmanouil Papadeas 1dcb696c35 Use texelFetch instead of texture for indexed mode shaders
Fixes various weird issues when palettes have empty slots, and removes unnecessary calculations.
2024-11-22 20:47:05 +02:00

18 lines
465 B
Text

shader_type canvas_item;
render_mode unshaded;
#include "res://src/Shaders/FindPaletteColorIndex.gdshaderinc"
uniform sampler2D rgb_texture : filter_nearest;
uniform sampler2D palette_texture : filter_nearest;
void fragment() {
vec4 color = texture(rgb_texture, UV);
if (color.a <= 0.0001) {
COLOR.r = 0.0;
}
else {
int color_index = find_index(color, textureSize(palette_texture, 0).x, palette_texture);
COLOR.r = float(color_index + 1) / 255.0;
}
}