From 6ec32374bffa6c34227776957e3bf7093c343d89 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 12 Jun 2024 12:07:56 +0700 Subject: [PATCH] - [Grids] Add level property. --- scripts/node_3d_camera/node_3d_camera.gml | 12 ++++++------ .../node_3d_camera_set/node_3d_camera_set.gml | 4 ++-- scripts/node_grid/node_grid.gml | 13 ++++++++----- scripts/node_grid_hex/node_grid_hex.gml | 13 +++++++++---- .../node_grid_pentagonal.gml | 19 ++++++++++++------- scripts/node_grid_tri/node_grid_tri.gml | 13 +++++++++---- shaders/sh_grid/sh_grid.fsh | 2 ++ shaders/sh_grid_hex/sh_grid_hex.fsh | 4 +++- .../sh_grid_pentagonal/sh_grid_pentagonal.fsh | 2 ++ shaders/sh_grid_tri/sh_grid_tri.fsh | 2 ++ 10 files changed, 55 insertions(+), 29 deletions(-) diff --git a/scripts/node_3d_camera/node_3d_camera.gml b/scripts/node_3d_camera/node_3d_camera.gml index 0b43f9a55..448f4eb9a 100644 --- a/scripts/node_3d_camera/node_3d_camera.gml +++ b/scripts/node_3d_camera/node_3d_camera.gml @@ -26,23 +26,23 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) inputs[| in_d3d + 2] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF ) .setDisplay(VALUE_DISPLAY.vector); - inputs[| in_d3d + 3] = nodeValue("Projection", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) + inputs[| in_d3d + 3] = nodeValue("Projection", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 ) .setDisplay(VALUE_DISPLAY.enum_button, [ "Perspective", "Orthographic" ]); inputs[| in_d3d + 4] = nodeValue("Scene", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3Scene, noone ) .setVisible(true, true); - inputs[| in_d3d + 5] = nodeValue("Ambient Light", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_grey ); + inputs[| in_d3d + 5] = nodeValue("Ambient Light", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_dkgrey ); inputs[| in_d3d + 6] = nodeValue("Show Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false ); inputs[| in_d3d + 7] = nodeValue("Backface Culling", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 2 ) .setDisplay(VALUE_DISPLAY.enum_button, [ "None", "CW", "CCW" ]); - inputs[| in_d3d + 8] = nodeValue("Orthographic Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1 ) + inputs[| in_d3d + 8] = nodeValue("Orthographic Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5 ) .setDisplay(VALUE_DISPLAY.slider, { range: [ 0.01, 4, 0.01 ] }); - inputs[| in_d3d + 9] = nodeValue("Postioning Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) + inputs[| in_d3d + 9] = nodeValue("Postioning Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 2 ) .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Position + Rotation", "Position + Lookat", "Lookat + Rotation" ] ); inputs[| in_d3d + 10] = nodeValue("Lookat Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ] ) @@ -51,10 +51,10 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) inputs[| in_d3d + 11] = nodeValue("Roll", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 ) .setDisplay(VALUE_DISPLAY.rotation); - inputs[| in_d3d + 12] = nodeValue("Horizontal Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 ) + inputs[| in_d3d + 12] = nodeValue("Horizontal Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 45 ) .setDisplay(VALUE_DISPLAY.rotation); - inputs[| in_d3d + 13] = nodeValue("Vertical Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 45 ) + inputs[| in_d3d + 13] = nodeValue("Vertical Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 30 ) .setDisplay(VALUE_DISPLAY.slider, { range: [0, 90, 0.1] }); inputs[| in_d3d + 14] = nodeValue("Distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4 ); diff --git a/scripts/node_3d_camera_set/node_3d_camera_set.gml b/scripts/node_3d_camera_set/node_3d_camera_set.gml index de50ea0ef..fd9f9169c 100644 --- a/scripts/node_3d_camera_set/node_3d_camera_set.gml +++ b/scripts/node_3d_camera_set/node_3d_camera_set.gml @@ -4,7 +4,7 @@ function Node_3D_Camera_Set(_x, _y, _group = noone) : Node_3D_Camera(_x, _y, _gr light_key = new __3dLightDirectional(); light_fill = new __3dLightDirectional(); - inputs[| in_cam + 0] = nodeValue("L1 H angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 45 ) + inputs[| in_cam + 0] = nodeValue("L1 H angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 30 ) .setName("Horizontal angle") .setDisplay(VALUE_DISPLAY.rotation); @@ -30,7 +30,7 @@ function Node_3D_Camera_Set(_x, _y, _group = noone) : Node_3D_Camera(_x, _y, _gr inputs[| in_cam + 6] = nodeValue("L2 Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white ) .setName("Color") - inputs[| in_cam + 7] = nodeValue("L2 Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5 ) + inputs[| in_cam + 7] = nodeValue("L2 Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.25 ) .setName("Intensity") .setDisplay(VALUE_DISPLAY.slider); diff --git a/scripts/node_grid/node_grid.gml b/scripts/node_grid/node_grid.gml index 14a74ad92..01512b6de 100644 --- a/scripts/node_grid/node_grid.gml +++ b/scripts/node_grid/node_grid.gml @@ -67,12 +67,13 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons inputs[| 23] = nodeValue("Texture angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ]) .setDisplay(VALUE_DISPLAY.rotation_range); - //inputs[| 24] = nodeValue("Random Rotate", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + inputs[| 24] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ]) + .setDisplay(VALUE_DISPLAY.slider_range); 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, + ["Render", false], 10, 11, 5, 20, 6, 7, 12, 24, ["Truchet", true, 17], 18, 19, 22, 23, ]; @@ -101,9 +102,10 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons var _col_gap = _data[6]; - inputs[| 5].setVisible(_mode == 0); - inputs[| 6].setVisible(_mode != 1); - inputs[| 7].setVisible(_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); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); surface_set_shader(_outSurf, sh_grid); @@ -124,6 +126,7 @@ function Node_Grid(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons shader_set_f("truchetThresX", _data[19]); shader_set_f("truchetThresY", _data[22]); shader_set_f("truchetAngle", _data[23]); + shader_set_f("level", _data[24]); shader_set_color("gapCol", _col_gap); diff --git a/scripts/node_grid_hex/node_grid_hex.gml b/scripts/node_grid_hex/node_grid_hex.gml index 481e63e46..090f2685b 100644 --- a/scripts/node_grid_hex/node_grid_hex.gml +++ b/scripts/node_grid_hex/node_grid_hex.gml @@ -63,10 +63,13 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) inputs[| 19] = nodeValue("Texture angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ]) .setDisplay(VALUE_DISPLAY.rotation_range); + inputs[| 20] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ]) + .setDisplay(VALUE_DISPLAY.slider_range); + input_display_list = [ ["Output", false], 0, ["Pattern", false], 1, 3, 12, 2, 11, 4, 13, - ["Render", false], 7, 8, 5, 17, 6, 9, 10, + ["Render", false], 7, 8, 5, 17, 6, 9, 10, 20, ["Truchet", true, 14], 15, 16, 19, ]; @@ -94,9 +97,10 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) var _col_gap = _data[6]; - inputs[| 5].setVisible(_mode == 0); - inputs[| 6].setVisible(_mode != 1); - inputs[| 9].setVisible(_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); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); @@ -117,6 +121,7 @@ function Node_Grid_Hex(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) shader_set_f("truchetSeed", _data[15]); shader_set_f("truchetThres", _data[16]); shader_set_f("truchetAngle", _data[19]); + shader_set_f("level", _data[20]); shader_set_gradient(_data[5], _data[17], _data[18], inputs[| 5]); diff --git a/scripts/node_grid_pentagonal/node_grid_pentagonal.gml b/scripts/node_grid_pentagonal/node_grid_pentagonal.gml index 76dc33c5d..ac408f415 100644 --- a/scripts/node_grid_pentagonal/node_grid_pentagonal.gml +++ b/scripts/node_grid_pentagonal/node_grid_pentagonal.gml @@ -49,10 +49,13 @@ 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); + input_display_list = [ ["Output", false], 0, ["Pattern", false], 1, 4, 13, 2, 11, 3, 12, - ["Render", false], 8, 9, 5, 14, 6, 7, 10, + ["Render", false], 8, 9, 5, 14, 6, 7, 10, 16, ]; outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -79,9 +82,10 @@ function Node_Grid_Pentagonal(_x, _y, _group = noone) : Node_Processor(_x, _y, _ var _col_gap = _data[6]; - inputs[| 5].setVisible(_mode == 0); - inputs[| 6].setVisible(_mode != 1); - inputs[| 7].setVisible(_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); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); surface_set_shader(_outSurf, sh_grid_pentagonal); @@ -92,9 +96,10 @@ function Node_Grid_Pentagonal(_x, _y, _group = noone) : Node_Processor(_x, _y, _ shader_set_f_map("width", _data[ 3], _data[12], inputs[| 3]); shader_set_f_map("angle", _data[ 4], _data[13], inputs[| 4]); - shader_set_i("mode", _mode); - shader_set_f("seed", _data[ 9]); - shader_set_i("aa", _data[10]); + shader_set_i("mode", _mode); + shader_set_f("seed", _data[ 9]); + shader_set_i("aa", _data[10]); + shader_set_f("level", _data[16]); shader_set_color("gapCol", _col_gap); diff --git a/scripts/node_grid_tri/node_grid_tri.gml b/scripts/node_grid_tri/node_grid_tri.gml index 81b7794b5..89c5a62d0 100644 --- a/scripts/node_grid_tri/node_grid_tri.gml +++ b/scripts/node_grid_tri/node_grid_tri.gml @@ -63,10 +63,13 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) inputs[| 19] = nodeValue("Texture angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ]) .setDisplay(VALUE_DISPLAY.rotation_range); + inputs[| 20] = nodeValue("Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 1 ]) + .setDisplay(VALUE_DISPLAY.slider_range); + input_display_list = [ ["Output", false], 0, ["Pattern", false], 1, 4, 13, 2, 11, 3, 12, - ["Render", false], 8, 9, 5, 17, 6, 7, 10, + ["Render", false], 8, 9, 5, 17, 6, 7, 10, 20, ["Truchet", true, 14], 15, 16, 19, ]; @@ -96,9 +99,10 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) var _col_gap = _data[6]; - inputs[| 5].setVisible(_mode == 0); - inputs[| 6].setVisible(_mode != 1); - inputs[| 7].setVisible(_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); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); @@ -119,6 +123,7 @@ function Node_Grid_Tri(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) shader_set_f("truchetSeed", _data[15]); shader_set_f("truchetThres", _data[16]); shader_set_f("truchetAngle", _data[19]); + shader_set_f("level", _data[20]); shader_set_gradient(_data[5], _data[17], _data[18], inputs[| 5]); diff --git a/shaders/sh_grid/sh_grid.fsh b/shaders/sh_grid/sh_grid.fsh index 2aa492dd4..2a8340b3b 100644 --- a/shaders/sh_grid/sh_grid.fsh +++ b/shaders/sh_grid/sh_grid.fsh @@ -26,6 +26,7 @@ uniform sampler2D shiftSurf; uniform vec4 gapCol; uniform int gradient_use; +uniform vec2 level; uniform int textureTruchet; uniform float truchetSeed; @@ -227,6 +228,7 @@ void main() { #region vec4 colr; if(mode == 1) { + dist = (dist - level.x) / (level.y - level.x); gl_FragColor = vec4(vec3(dist), 1.); return; } diff --git a/shaders/sh_grid_hex/sh_grid_hex.fsh b/shaders/sh_grid_hex/sh_grid_hex.fsh index c7095fe7a..cdeea04e6 100644 --- a/shaders/sh_grid_hex/sh_grid_hex.fsh +++ b/shaders/sh_grid_hex/sh_grid_hex.fsh @@ -23,6 +23,7 @@ uniform sampler2D thickSurf; uniform vec4 gapCol; uniform int gradient_use; +uniform vec2 level; uniform int textureTruchet; uniform float truchetSeed; @@ -223,7 +224,8 @@ void main() { #region vec4 colr; if(mode == 1) { - gl_FragColor = vec4(vec3(hc.y), 1.0); + float dist = (hc.y - level.x) / (level.y - level.x); + gl_FragColor = vec4(vec3(dist), 1.0); return; } diff --git a/shaders/sh_grid_pentagonal/sh_grid_pentagonal.fsh b/shaders/sh_grid_pentagonal/sh_grid_pentagonal.fsh index c56af4dde..09418f82a 100644 --- a/shaders/sh_grid_pentagonal/sh_grid_pentagonal.fsh +++ b/shaders/sh_grid_pentagonal/sh_grid_pentagonal.fsh @@ -27,6 +27,7 @@ uniform sampler2D widthSurf; uniform vec4 gapCol; uniform int gradient_use; +uniform vec2 level; float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); } @@ -279,6 +280,7 @@ void main() { colr = gradientEval(random(coord)); } else if(mode == 1) { + dist = (dist - level.x) / (level.y - level.x); colr = vec4(vec3(dist), 1.); } else if(mode == 2) { diff --git a/shaders/sh_grid_tri/sh_grid_tri.fsh b/shaders/sh_grid_tri/sh_grid_tri.fsh index 93ce3dd27..f2d7d2d48 100644 --- a/shaders/sh_grid_tri/sh_grid_tri.fsh +++ b/shaders/sh_grid_tri/sh_grid_tri.fsh @@ -24,6 +24,7 @@ uniform sampler2D widthSurf; uniform vec4 gapCol; uniform int gradient_use; +uniform vec2 level; uniform int textureTruchet; uniform float truchetSeed; @@ -216,6 +217,7 @@ void main() { #region vec4 colr; if(mode == 1) { + dist = (dist - level.x) / (level.y - level.x); gl_FragColor = vec4(vec3(dist), 1.); return; }