mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-10 12:34:06 +01:00
- Fix palette limit to actually 1024 (fr this time).
This commit is contained in:
parent
017aa7ac2b
commit
091e4156ac
@ -59,8 +59,7 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||
|
||||
if(_use_pal) {
|
||||
surface_set_shader(_outSurf, sh_posterize_palette);
|
||||
shader_set_f("palette", paletteToArray(_pal));
|
||||
shader_set_i("keys", array_length(_pal));
|
||||
shader_set_palette(_pal, "palette", "keys");
|
||||
shader_set_i("alpha", _alp);
|
||||
shader_set_i("space", _spce);
|
||||
|
||||
@ -151,10 +150,6 @@ function Node_Posterize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||
|
||||
draw_surface_safe(_surf);
|
||||
surface_reset_shader();
|
||||
|
||||
// surface_set_shader(_outSurf);
|
||||
// draw_surface_safe(_sMax);
|
||||
// surface_reset_shader();
|
||||
}
|
||||
|
||||
return _outSurf;
|
||||
|
@ -32,7 +32,7 @@ function loadPalette(path) {
|
||||
var pal = array_create(_sw * _sh);
|
||||
for( var i = 0; i < _sh; i++ )
|
||||
for( var j = 0; j < _sw; j++ )
|
||||
pal[i * _sh + j] = surface_getpixel(_s, j, i);
|
||||
pal[i * _sh + j] = cola(surface_getpixel(_s, j, i));
|
||||
|
||||
surface_free(_s);
|
||||
|
||||
@ -54,13 +54,11 @@ function loadPalette(path) {
|
||||
var _r = string_hexadecimal(string_copy(_w, 1, 2));
|
||||
var _g = string_hexadecimal(string_copy(_w, 3, 2));
|
||||
var _b = string_hexadecimal(string_copy(_w, 5, 2));
|
||||
var _a = string_length(_w) > 6? string_hexadecimal(string_copy(_w, 7, 2)) : 255;
|
||||
|
||||
if(string_length(_w) > 6) {
|
||||
var _a = string_hexadecimal(string_copy(_w, 7, 2));
|
||||
pal[_index++] = make_color_rgba(_r, _g, _b, _a);
|
||||
} else
|
||||
pal[_index++] = make_color_rgb(_r, _g, _b);
|
||||
pal[_index++] = make_color_rgba(_r, _g, _b, _a);
|
||||
break;
|
||||
|
||||
case ".gpl" :
|
||||
case ".pal" :
|
||||
if(string_char_at(_w, 1) == "#") break;
|
||||
@ -68,7 +66,7 @@ function loadPalette(path) {
|
||||
_c = array_filter(_c, function(s) { return s != ""; });
|
||||
|
||||
if(array_length(_c) == 3)
|
||||
pal[_index++] = make_color_rgb(toNumber(_c[0]), toNumber(_c[1]), toNumber(_c[2]));
|
||||
pal[_index++] = make_color_rgba(toNumber(_c[0]), toNumber(_c[1]), toNumber(_c[2]), 255);
|
||||
else if(array_length(_c) >= 4)
|
||||
pal[_index++] = make_color_rgba(toNumber(_c[0]), toNumber(_c[1]), toNumber(_c[2]), toNumber(_c[3]));
|
||||
break;
|
||||
|
@ -97,7 +97,7 @@ function shader_set_f_map_s(uniform, value, surface, junc) {
|
||||
shader_set_i(uniform + "UseSurf", junc.attributes.mapped && is_surface(surface));
|
||||
}
|
||||
|
||||
function shader_set_uniform_f_array_safe(uniform, array, max_length = 128) {
|
||||
function shader_set_uniform_f_array_safe(uniform, array, max_length = 4096) {
|
||||
INLINE
|
||||
|
||||
if(!is_array(array)) return;
|
||||
@ -161,14 +161,15 @@ function shader_set_color(uniform, col, alpha = 1) {
|
||||
function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount", max_length = 1024) {
|
||||
INLINE
|
||||
|
||||
shader_set_i(amo_uni, min(max_length, array_length(pal)));
|
||||
var _amo = min(max_length, array_length(pal));
|
||||
if(_amo == 0) return;
|
||||
|
||||
var _pal = [];
|
||||
for( var i = 0, n = min(max_length, array_length(pal)); i < n; i++ )
|
||||
for( var i = 0, n = _amo; i < n; i++ )
|
||||
array_append(_pal, colToVec4(pal[i]));
|
||||
|
||||
if(array_length(_pal))
|
||||
shader_set_f(pal_uni, _pal);
|
||||
shader_set_i(amo_uni, _amo);
|
||||
shader_set_f(pal_uni, _pal);
|
||||
}
|
||||
|
||||
#region prebuild
|
||||
|
@ -4,9 +4,9 @@ varying vec4 v_vColour;
|
||||
#define PALETTE_LIMIT 1024
|
||||
|
||||
uniform vec4 palette[PALETTE_LIMIT];
|
||||
uniform int keys;
|
||||
uniform int alpha;
|
||||
uniform int space;
|
||||
uniform int keys;
|
||||
uniform int alpha;
|
||||
uniform int space;
|
||||
|
||||
vec3 rgb2xyz( vec3 c ) {
|
||||
vec3 tmp;
|
||||
@ -45,7 +45,7 @@ float colorDifferentRGB(in vec4 c1, in vec4 c2) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 _col = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
vec4 _col = texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
vec4 col = alpha == 1? _col * _col.a : _col;
|
||||
|
||||
int closet_index = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user