mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
- [Grid] Add accurate mode.
This commit is contained in:
parent
6d352c7c71
commit
24882f60e5
4 changed files with 70 additions and 14 deletions
|
@ -141,9 +141,9 @@ event_inherited();
|
||||||
var mtx = ui(4);
|
var mtx = ui(4);
|
||||||
var mty = yy;
|
var mty = yy;
|
||||||
|
|
||||||
for (var i = 0, n = array_length(META_TAGS); i < n; i++) {
|
for (var i = 0, n = array_length(STEAM_TAGS); i < n; i++) {
|
||||||
|
|
||||||
var tg = META_TAGS[i];
|
var tg = STEAM_TAGS[i];
|
||||||
var _sel = array_exists(meta_filter, tg);
|
var _sel = array_exists(meta_filter, tg);
|
||||||
draw_set_text(f_p2, fa_left, fa_center, _sel? COLORS._main_text : COLORS._main_text_sub);
|
draw_set_text(f_p2, fa_left, fa_center, _sel? COLORS._main_text : COLORS._main_text_sub);
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
.setDisplay(VALUE_DISPLAY.vector)
|
.setDisplay(VALUE_DISPLAY.vector)
|
||||||
.setUnitRef(function(index) { return getDimension(index); });
|
.setUnitRef(function(index) { return getDimension(index); });
|
||||||
|
|
||||||
inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 2, 2 ])
|
inputs[| 2] = nodeValue("Grid Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 8, 8 ])
|
||||||
.setDisplay(VALUE_DISPLAY.vector)
|
.setDisplay(VALUE_DISPLAY.vector)
|
||||||
.setMappable(13);
|
.setMappable(13);
|
||||||
|
|
||||||
inputs[| 3] = nodeValue("Gap", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
|
inputs[| 3] = nodeValue("Gap", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2)
|
||||||
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 0.5, 0.001] })
|
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 0.5, 0.001] })
|
||||||
.setMappable(14);
|
.setMappable(14);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
.setDisplay(VALUE_DISPLAY.enum_button, ["X", "Y"]);
|
.setDisplay(VALUE_DISPLAY.enum_button, ["X", "Y"]);
|
||||||
|
|
||||||
inputs[| 10] = nodeValue("Render type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
inputs[| 10] = nodeValue("Render type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||||
.setDisplay(VALUE_DISPLAY.enum_scroll, ["Colored tile", "Height map", "Texture grid", "Texture sample"]);
|
.setDisplay(VALUE_DISPLAY.enum_scroll, ["Colored tile", "Colored tile (Accurate)", "Height map", "Texture grid", "Texture sample"]);
|
||||||
|
|
||||||
inputs[| 11] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, seed_random(6))
|
inputs[| 11] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, seed_random(6))
|
||||||
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[| 11].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
|
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[| 11].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
|
||||||
|
@ -72,9 +72,13 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
|
|
||||||
inputs[| 25] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
inputs[| 25] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||||
|
|
||||||
|
inputs[| 26] = nodeValue("Gap Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
|
||||||
|
|
||||||
|
inputs[| 27] = nodeValue("Diagonal", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
input_display_list = [
|
input_display_list = [
|
||||||
["Output", false], 0,
|
["Output", false], 0,
|
||||||
["Pattern", false], 1, 4, 15, 2, 13, 3, 14, 9, 8, 16,
|
["Pattern", false], 1, 4, 15, 2, 13, 3, 26, 27, 14, 9, 8, 16,
|
||||||
["Render", false], 10, 11, 5, 20, 6, 7, 25, 12, 24,
|
["Render", false], 10, 11, 5, 20, 6, 7, 25, 12, 24,
|
||||||
["Truchet", true, 17], 18, 19, 22, 23,
|
["Truchet", true, 17], 18, 19, 22, 23,
|
||||||
];
|
];
|
||||||
|
@ -110,11 +114,17 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
var _mode = _data[10];
|
var _mode = _data[10];
|
||||||
|
|
||||||
var _col_gap = _data[6];
|
var _col_gap = _data[6];
|
||||||
var _tex_mode = _mode == 2 || _mode == 3;
|
var _tex_mode = _mode == 3 || _mode == 4;
|
||||||
|
|
||||||
inputs[| 5].setVisible(_mode == 0);
|
inputs[| 5].setVisible(_mode == 0 || _mode == 1);
|
||||||
inputs[| 6].setVisible(_mode != 1);
|
inputs[| 3].setVisible(_mode == 0 || _mode == 3 || _mode == 4);
|
||||||
inputs[| 24].setVisible(_mode == 1);
|
inputs[| 24].setVisible(_mode == 2);
|
||||||
|
inputs[| 26].setVisible(_mode == 1);
|
||||||
|
|
||||||
|
inputs[| 4].setVisible(_mode != 1);
|
||||||
|
inputs[| 8].setVisible(_mode != 1);
|
||||||
|
inputs[| 9].setVisible(_mode != 1);
|
||||||
|
inputs[| 27].setVisible(_mode == 1);
|
||||||
|
|
||||||
inputs[| 7].setVisible(_tex_mode, _tex_mode);
|
inputs[| 7].setVisible(_tex_mode, _tex_mode);
|
||||||
inputs[| 25].setVisible(_tex_mode, _tex_mode);
|
inputs[| 25].setVisible(_tex_mode, _tex_mode);
|
||||||
|
@ -142,6 +152,8 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
shader_set_f("truchetThresY", _data[22]);
|
shader_set_f("truchetThresY", _data[22]);
|
||||||
shader_set_2("truchetAngle", _data[23]);
|
shader_set_2("truchetAngle", _data[23]);
|
||||||
shader_set_2("level", _data[24]);
|
shader_set_2("level", _data[24]);
|
||||||
|
shader_set_f("gapAcc", _data[26]);
|
||||||
|
shader_set_i("diagonal", _data[27]);
|
||||||
|
|
||||||
shader_set_color("gapCol", _col_gap);
|
shader_set_color("gapCol", _col_gap);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
function __initSteamUGC() { #region
|
function __initSteamUGC() { #region
|
||||||
globalvar STEAM_SUBS, STEAM_COLLECTION, STEAM_PROJECTS;
|
globalvar STEAM_SUBS, STEAM_COLLECTION, STEAM_PROJECTS, STEAM_TAGS;
|
||||||
|
|
||||||
STEAM_SUBS = ds_list_create();
|
STEAM_SUBS = ds_list_create();
|
||||||
STEAM_COLLECTION = ds_list_create();
|
STEAM_COLLECTION = ds_list_create();
|
||||||
STEAM_PROJECTS = ds_list_create();
|
STEAM_PROJECTS = ds_list_create();
|
||||||
|
STEAM_TAGS = [];
|
||||||
|
|
||||||
if(DEMO) return;
|
if(DEMO) return;
|
||||||
if(!STEAM_ENABLED) return;
|
if(!STEAM_ENABLED) return;
|
||||||
|
@ -15,6 +17,7 @@ function steamUCGload() { #region
|
||||||
ds_list_clear(STEAM_SUBS);
|
ds_list_clear(STEAM_SUBS);
|
||||||
ds_list_clear(STEAM_COLLECTION);
|
ds_list_clear(STEAM_COLLECTION);
|
||||||
ds_list_clear(STEAM_PROJECTS);
|
ds_list_clear(STEAM_PROJECTS);
|
||||||
|
STEAM_TAGS = [];
|
||||||
|
|
||||||
steam_ugc_get_subscribed_items(STEAM_SUBS);
|
steam_ugc_get_subscribed_items(STEAM_SUBS);
|
||||||
|
|
||||||
|
@ -103,4 +106,7 @@ function __loadSteamUGCProject(file_id, f, path) { #region
|
||||||
var meta = file.getMetadata(true);
|
var meta = file.getMetadata(true);
|
||||||
meta.steam = FILE_STEAM_TYPE.steamOpen;
|
meta.steam = FILE_STEAM_TYPE.steamOpen;
|
||||||
meta.file_id = file_id;
|
meta.file_id = file_id;
|
||||||
|
|
||||||
|
for (var i = 0, n = array_length(meta.tags); i < n; i++)
|
||||||
|
array_push_unique(STEAM_TAGS, meta.tags[i]);
|
||||||
} #endregion
|
} #endregion
|
|
@ -24,10 +24,13 @@ uniform vec2 shift;
|
||||||
uniform int shiftUseSurf;
|
uniform int shiftUseSurf;
|
||||||
uniform sampler2D shiftSurf;
|
uniform sampler2D shiftSurf;
|
||||||
|
|
||||||
|
uniform float gapAcc;
|
||||||
uniform vec4 gapCol;
|
uniform vec4 gapCol;
|
||||||
uniform int gradient_use;
|
uniform int gradient_use;
|
||||||
uniform vec2 level;
|
uniform vec2 level;
|
||||||
|
|
||||||
|
uniform int diagonal;
|
||||||
|
|
||||||
uniform int textureTruchet;
|
uniform int textureTruchet;
|
||||||
uniform float truchetSeed;
|
uniform float truchetSeed;
|
||||||
uniform float truchetThresX;
|
uniform float truchetThresX;
|
||||||
|
@ -199,6 +202,41 @@ void main() { #region
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
if(mode == 1) {
|
||||||
|
vec2 px = floor((v_vTexcoord - position) * dimension);
|
||||||
|
|
||||||
|
sca = floor(sca);
|
||||||
|
vec2 scaG = sca - (gapAcc + 1.);
|
||||||
|
|
||||||
|
if(diagonal == 0) {
|
||||||
|
vec2 fl = floor(px / sca) * sca;
|
||||||
|
vec2 fr = px - fl;
|
||||||
|
|
||||||
|
if(fr.x > scaG.x || fr.y > scaG.y)
|
||||||
|
gl_FragColor = gapCol;
|
||||||
|
|
||||||
|
else
|
||||||
|
gl_FragColor = gradientEval(random(fl));
|
||||||
|
|
||||||
|
} else if(diagonal == 1) {
|
||||||
|
float _x = px.x + px.y;
|
||||||
|
float _y = -px.x + px.y;
|
||||||
|
|
||||||
|
float mx = mod(_x, sca.x);
|
||||||
|
float my = mod(_y, sca.y);
|
||||||
|
|
||||||
|
if(mx > scaG.x || my > scaG.y)
|
||||||
|
gl_FragColor = gapCol;
|
||||||
|
|
||||||
|
else
|
||||||
|
gl_FragColor = gradientEval(random(vec2(_x, _y) - vec2(mx, my)));
|
||||||
|
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sca = dimension / sca;
|
||||||
|
|
||||||
vec2 pos = v_vTexcoord - position, _pos;
|
vec2 pos = v_vTexcoord - position, _pos;
|
||||||
float ratio = dimension.x / dimension.y;
|
float ratio = dimension.x / dimension.y;
|
||||||
_pos.x = pos.x * ratio * cos(ang) - pos.y * sin(ang);
|
_pos.x = pos.x * ratio * cos(ang) - pos.y * sin(ang);
|
||||||
|
@ -227,7 +265,7 @@ void main() { #region
|
||||||
|
|
||||||
vec4 colr;
|
vec4 colr;
|
||||||
|
|
||||||
if(mode == 1) {
|
if(mode == 2) {
|
||||||
dist = (dist - level.x) / (level.y - level.x);
|
dist = (dist - level.x) / (level.y - level.x);
|
||||||
gl_FragColor = vec4(vec3(dist), 1.);
|
gl_FragColor = vec4(vec3(dist), 1.);
|
||||||
return;
|
return;
|
||||||
|
@ -236,7 +274,7 @@ void main() { #region
|
||||||
if(mode == 0) {
|
if(mode == 0) {
|
||||||
colr = gradientEval(random(sqSt));
|
colr = gradientEval(random(sqSt));
|
||||||
|
|
||||||
} else if(mode == 2) {
|
} else if(mode == 3) {
|
||||||
vec2 uv = fract(_pos * sca);
|
vec2 uv = fract(_pos * sca);
|
||||||
|
|
||||||
if(textureTruchet == 1) {
|
if(textureTruchet == 1) {
|
||||||
|
@ -252,7 +290,7 @@ void main() { #region
|
||||||
|
|
||||||
colr = texture2D( gm_BaseTexture, uv );
|
colr = texture2D( gm_BaseTexture, uv );
|
||||||
|
|
||||||
} else if(mode == 3) {
|
} else if(mode == 4) {
|
||||||
vec2 uv = fract(sqSt);
|
vec2 uv = fract(sqSt);
|
||||||
colr = texture2D( gm_BaseTexture, uv );
|
colr = texture2D( gm_BaseTexture, uv );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue