- [Square, Tri, Pen, Hex Grid] Add option to use texture dimension.

This commit is contained in:
Tanasart 2024-06-22 12:29:05 +07:00
parent 2aaa206a7a
commit 2ff855332c
6 changed files with 52 additions and 18 deletions

View file

@ -70,10 +70,12 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 24] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
.setDisplay(VALUE_DISPLAY.slider_range);
inputs[| 25] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 4, 15, 2, 13, 3, 14, 9, 8, 16,
["Render", false], 10, 11, 5, 20, 6, 7, 12, 24,
["Render", false], 10, 11, 5, 20, 6, 7, 25, 12, 24,
["Truchet", true, 17], 18, 19, 22, 23,
];
@ -100,12 +102,18 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _sam = _data[ 7];
var _mode = _data[10];
var _col_gap = _data[6];
var _col_gap = _data[6];
var _tex_mode = _mode == 2 || _mode == 3;
inputs[| 5].setVisible(_mode == 0);
inputs[| 6].setVisible(_mode != 1);
inputs[| 24].setVisible(_mode == 1);
inputs[| 7].setVisible(_mode == 2 || _mode == 3);
inputs[| 7].setVisible(_tex_mode, _tex_mode);
inputs[| 25].setVisible(_tex_mode, _tex_mode);
var _tex_dim = is_surface(_sam) && _tex_mode && _data[25];
if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid);

View file

@ -66,10 +66,12 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[| 20] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
.setDisplay(VALUE_DISPLAY.slider_range);
inputs[| 21] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 3, 12, 2, 11, 4, 13,
["Render", false], 7, 8, 5, 17, 6, 9, 10, 20,
["Render", false], 7, 8, 5, 17, 6, 9, 21, 10, 20,
["Truchet", true, 14], 15, 16, 19,
];
@ -95,12 +97,18 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _sam = _data[9];
var _mode = _data[7];
var _col_gap = _data[6];
var _col_gap = _data[6];
var _tex_mode = _mode == 2 || _mode == 3;
inputs[| 5].setVisible(_mode == 0);
inputs[| 6].setVisible(_mode != 1);
inputs[| 20].setVisible(_mode == 1);
inputs[| 9].setVisible(_mode == 2 || _mode == 3);
inputs[| 9].setVisible(_tex_mode, _tex_mode);
inputs[| 21].setVisible(_tex_mode, _tex_mode);
var _tex_dim = is_surface(_sam) && _tex_mode && _data[21];
if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());

View file

@ -52,10 +52,12 @@ function Node_Grid_Pentagonal(_x, _y, _group = noone) : Node_Processor(_x, _y, _
inputs[| 16] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
.setDisplay(VALUE_DISPLAY.slider_range);
inputs[| 17] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 4, 13, 2, 11, 3, 12,
["Render", false], 8, 9, 5, 14, 6, 7, 10, 16,
["Render", false], 8, 9, 5, 14, 6, 7, 17, 10, 16,
];
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -80,12 +82,18 @@ function Node_Grid_Pentagonal(_x, _y, _group = noone) : Node_Processor(_x, _y, _
var _sam = _data[7];
var _mode = _data[8];
var _col_gap = _data[6];
var _col_gap = _data[6];
var _tex_mode = _mode == 2 || _mode == 3;
inputs[| 5].setVisible(_mode == 0);
inputs[| 6].setVisible(_mode != 1);
inputs[| 16].setVisible(_mode == 1);
inputs[| 7].setVisible(_mode == 2 || _mode == 3);
inputs[| 7].setVisible(_tex_mode, _tex_mode);
inputs[| 17].setVisible(_tex_mode, _tex_mode);
var _tex_dim = is_surface(_sam) && _tex_mode && _data[17];
if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid_pentagonal);

View file

@ -66,10 +66,12 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[| 20] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
.setDisplay(VALUE_DISPLAY.slider_range);
inputs[| 21] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 4, 13, 2, 11, 3, 12,
["Render", false], 8, 9, 5, 17, 6, 7, 10, 20,
["Render", false], 8, 9, 5, 17, 6, 7, 21, 10, 20,
["Truchet", true, 14], 15, 16, 19,
];
@ -97,12 +99,18 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _sed = _data[9];
var _aa = _data[10];
var _col_gap = _data[6];
var _col_gap = _data[6];
var _tex_mode = _mode == 2 || _mode == 3;
inputs[| 5].setVisible(_mode == 0);
inputs[| 6].setVisible(_mode != 1);
inputs[| 20].setVisible(_mode == 1);
inputs[| 7].setVisible(_mode == 2 || _mode == 3);
inputs[| 7].setVisible(_tex_mode, _tex_mode);
inputs[| 21].setVisible(_tex_mode, _tex_mode);
var _tex_dim = is_surface(_sam) && _tex_mode && _data[21];
if(_tex_dim) _dim = surface_get_dimension(_sam);
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());

View file

@ -265,9 +265,10 @@ void main() { #region
}
colr = texture2D( gm_BaseTexture, uv );
} else if(mode == 3) {
vec2 uv = clamp(abs(hc.zw) / sca, 0., 1.);
colr = texture2D( gm_BaseTexture, uv );
vec2 uv = clamp(abs(hc.zw) / sca / vec2(dimension.x / dimension.y, 1.), 0., 1.);
colr = texture2D( gm_BaseTexture, uv );
}
float _aa = 3. / max(dimension.x, dimension.y);

View file

@ -207,7 +207,7 @@ void main() { #region
}
#endregion
vec2 pos = (v_vTexcoord - position) * sca, _pos;
vec2 pos = (v_vTexcoord - position) * sca, _pos;
float ratio = dimension.x / dimension.y;
_pos.x = pos.x * ratio * cos(ang) - pos.y * sin(ang);
_pos.y = pos.x * ratio * sin(ang) + pos.y * cos(ang);
@ -226,7 +226,7 @@ void main() { #region
vec2 uv = fract(tri.xy / sca);
colr = gradientEval(random(uv));
} else if(mode == 2) {
vec2 uv = fract((_pos * vec2(1., c30) - tri.xy) + vec2(0.5, 0.));
vec2 uv = fract((_pos * vec2(1., c30) - tri.xy) + vec2(0.5, 0.));
if(textureTruchet == 1) {
float rx = random(floor(tri.xy) + truchetSeed / 100.);
@ -243,9 +243,10 @@ void main() { #region
}
colr = texture2D( gm_BaseTexture, uv );
} else if(mode == 3) {
vec2 uv = clamp(tri.xy / sca, 0., 1.);
colr = texture2D( gm_BaseTexture, uv );
vec2 uv = clamp(tri.xy / sca / vec2(dimension.x / dimension.y, c30), 0., 1.);
colr = texture2D( gm_BaseTexture, uv );
}
float _aa = 3. / max(dimension.x, dimension.y);