Update palette shader for 16x16 palettes (GLES2)
This commit is contained in:
parent
cb7f292e17
commit
7fcd05816c
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
"
|
Loading…
Reference in New Issue