diff --git a/palette_mat.tres b/palette_mat.tres index 899f2dc..d7f53a7 100644 --- a/palette_mat.tres +++ b/palette_mat.tres @@ -1,6 +1,6 @@ [gd_resource type="ShaderMaterial" load_steps=2 format=2] -[ext_resource path="res://shaders/palette_shader.tres" type="Shader" id=1] +[ext_resource path="res://shaders/palette_shader.gdshader" type="Shader" id=1] [resource] shader = ExtResource( 1 ) diff --git a/shaders/palette_shader.tres b/shaders/palette_shader.gdshader similarity index 74% rename from shaders/palette_shader.tres rename to shaders/palette_shader.gdshader index f37265d..096abfb 100644 --- a/shaders/palette_shader.tres +++ b/shaders/palette_shader.gdshader @@ -1,7 +1,4 @@ -[gd_resource type="Shader" format=2] - -[resource] -code = "shader_type canvas_item; +shader_type canvas_item; //uniform usampler2D tex; uniform sampler2D palette; const float index_scale = 255.0 / 16.0; @@ -14,8 +11,9 @@ void fragment() { COLOR.a = 0.0;*/ // GLES2 float color_idx = texture(TEXTURE, UV).a * index_scale; - COLOR = texture(palette, vec2(color_idx, 0.5)); + float row = trunc(color_idx) / 16.0; + float col = fract(color_idx); + COLOR = texture(palette, vec2(col, row)); if (color_idx == 0.0) COLOR.a = 0.0; } -"