- [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 ]) inputs[| 24] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
.setDisplay(VALUE_DISPLAY.slider_range); .setDisplay(VALUE_DISPLAY.slider_range);
inputs[| 25] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
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, 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, ["Truchet", true, 17], 18, 19, 22, 23,
]; ];
@ -101,11 +103,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;
inputs[| 5].setVisible(_mode == 0); inputs[| 5].setVisible(_mode == 0);
inputs[| 6].setVisible(_mode != 1); inputs[| 6].setVisible(_mode != 1);
inputs[| 24].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()); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid); 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 ]) inputs[| 20] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
.setDisplay(VALUE_DISPLAY.slider_range); .setDisplay(VALUE_DISPLAY.slider_range);
inputs[| 21] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [ input_display_list = [
["Output", false], 0, ["Output", false], 0,
["Pattern", false], 1, 3, 12, 2, 11, 4, 13, ["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, ["Truchet", true, 14], 15, 16, 19,
]; ];
@ -96,11 +98,17 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _mode = _data[7]; 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[| 5].setVisible(_mode == 0);
inputs[| 6].setVisible(_mode != 1); inputs[| 6].setVisible(_mode != 1);
inputs[| 20].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()); _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 ]) inputs[| 16] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
.setDisplay(VALUE_DISPLAY.slider_range); .setDisplay(VALUE_DISPLAY.slider_range);
inputs[| 17] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [ input_display_list = [
["Output", false], 0, ["Output", false], 0,
["Pattern", false], 1, 4, 13, 2, 11, 3, 12, ["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); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -81,11 +83,17 @@ function Node_Grid_Pentagonal(_x, _y, _group = noone) : Node_Processor(_x, _y, _
var _mode = _data[8]; 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[| 5].setVisible(_mode == 0);
inputs[| 6].setVisible(_mode != 1); inputs[| 6].setVisible(_mode != 1);
inputs[| 16].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()); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_grid_pentagonal); 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 ]) inputs[| 20] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ])
.setDisplay(VALUE_DISPLAY.slider_range); .setDisplay(VALUE_DISPLAY.slider_range);
inputs[| 21] = nodeValue("Use Texture Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
input_display_list = [ input_display_list = [
["Output", false], 0, ["Output", false], 0,
["Pattern", false], 1, 4, 13, 2, 11, 3, 12, ["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, ["Truchet", true, 14], 15, 16, 19,
]; ];
@ -98,11 +100,17 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _aa = _data[10]; 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[| 5].setVisible(_mode == 0);
inputs[| 6].setVisible(_mode != 1); inputs[| 6].setVisible(_mode != 1);
inputs[| 20].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()); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());

View file

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

View file

@ -243,8 +243,9 @@ void main() { #region
} }
colr = texture2D( gm_BaseTexture, uv ); colr = texture2D( gm_BaseTexture, uv );
} else if(mode == 3) { } else if(mode == 3) {
vec2 uv = clamp(tri.xy / sca, 0., 1.); vec2 uv = clamp(tri.xy / sca / vec2(dimension.x / dimension.y, c30), 0., 1.);
colr = texture2D( gm_BaseTexture, uv ); colr = texture2D( gm_BaseTexture, uv );
} }