- [Supporter] New Cristal noise node.

This commit is contained in:
Tanasart 2024-06-09 12:49:43 +07:00
parent 770aa23d81
commit b4c46e6ffb
17 changed files with 277 additions and 13 deletions

View file

@ -859,6 +859,7 @@
{"name":"node_move_point","order":8,"path":"scripts/node_move_point/node_move_point.yy",},
{"name":"node_noise_aniso","order":1,"path":"scripts/node_noise_aniso/node_noise_aniso.yy",},
{"name":"node_noise_bubble","order":17,"path":"scripts/node_noise_bubble/node_noise_bubble.yy",},
{"name":"node_noise_cristal","order":19,"path":"scripts/node_noise_cristal/node_noise_cristal.yy",},
{"name":"node_noise_fbm","order":3,"path":"scripts/node_noise_fbm/node_noise_fbm.yy",},
{"name":"node_noise_hex","order":5,"path":"scripts/node_noise_hex/node_noise_hex.yy",},
{"name":"node_noise_simplex","order":7,"path":"scripts/node_noise_simplex/node_noise_simplex.yy",},
@ -1435,6 +1436,7 @@
{"name":"sh_node_widget_scalar_cross","order":2,"path":"shaders/sh_node_widget_scalar_cross/sh_node_widget_scalar_cross.yy",},
{"name":"sh_node_widget_scalar_line","order":3,"path":"shaders/sh_node_widget_scalar_line/sh_node_widget_scalar_line.yy",},
{"name":"sh_noise_bubble","order":2,"path":"shaders/sh_noise_bubble/sh_noise_bubble.yy",},
{"name":"sh_noise_cristal","order":18,"path":"shaders/sh_noise_cristal/sh_noise_cristal.yy",},
{"name":"sh_noise_fbm","order":3,"path":"shaders/sh_noise_fbm/sh_noise_fbm.yy",},
{"name":"sh_noise_flow","order":4,"path":"shaders/sh_noise_flow/sh_noise_flow.yy",},
{"name":"sh_noise_fold","order":5,"path":"shaders/sh_noise_fold/sh_noise_fold.yy",},
@ -1678,6 +1680,7 @@
{"name":"s_node_condition_type","order":9,"path":"sprites/s_node_condition_type/s_node_condition_type.yy",},
{"name":"s_node_convolution","order":12,"path":"sprites/s_node_convolution/s_node_convolution.yy",},
{"name":"s_node_corner","order":13,"path":"sprites/s_node_corner/s_node_corner.yy",},
{"name":"s_node_cristal","order":53,"path":"sprites/s_node_cristal/s_node_cristal.yy",},
{"name":"s_node_crop_content","order":13,"path":"sprites/s_node_crop_content/s_node_crop_content.yy",},
{"name":"s_node_crop","order":2,"path":"sprites/s_node_crop/s_node_crop.yy",},
{"name":"s_node_cross_product_2d","order":1,"path":"sprites/s_node_cross_product_2d/s_node_cross_product_2d.yy",},

View file

@ -1292,6 +1292,7 @@
{"id":{"name":"node_move_point","path":"scripts/node_move_point/node_move_point.yy",},},
{"id":{"name":"node_noise_aniso","path":"scripts/node_noise_aniso/node_noise_aniso.yy",},},
{"id":{"name":"node_noise_bubble","path":"scripts/node_noise_bubble/node_noise_bubble.yy",},},
{"id":{"name":"node_noise_cristal","path":"scripts/node_noise_cristal/node_noise_cristal.yy",},},
{"id":{"name":"node_noise_fbm","path":"scripts/node_noise_fbm/node_noise_fbm.yy",},},
{"id":{"name":"node_noise_hex","path":"scripts/node_noise_hex/node_noise_hex.yy",},},
{"id":{"name":"node_noise_simplex","path":"scripts/node_noise_simplex/node_noise_simplex.yy",},},
@ -1962,6 +1963,7 @@
{"id":{"name":"sh_node_widget_scalar_line","path":"shaders/sh_node_widget_scalar_line/sh_node_widget_scalar_line.yy",},},
{"id":{"name":"sh_node_widget_scalar","path":"shaders/sh_node_widget_scalar/sh_node_widget_scalar.yy",},},
{"id":{"name":"sh_noise_bubble","path":"shaders/sh_noise_bubble/sh_noise_bubble.yy",},},
{"id":{"name":"sh_noise_cristal","path":"shaders/sh_noise_cristal/sh_noise_cristal.yy",},},
{"id":{"name":"sh_noise_fbm","path":"shaders/sh_noise_fbm/sh_noise_fbm.yy",},},
{"id":{"name":"sh_noise_flow","path":"shaders/sh_noise_flow/sh_noise_flow.yy",},},
{"id":{"name":"sh_noise_fold","path":"shaders/sh_noise_fold/sh_noise_fold.yy",},},
@ -2245,6 +2247,7 @@
{"id":{"name":"s_node_convolution","path":"sprites/s_node_convolution/s_node_convolution.yy",},},
{"id":{"name":"s_node_corner","path":"sprites/s_node_corner/s_node_corner.yy",},},
{"id":{"name":"s_node_counter","path":"sprites/s_node_counter/s_node_counter.yy",},},
{"id":{"name":"s_node_cristal","path":"sprites/s_node_cristal/s_node_cristal.yy",},},
{"id":{"name":"s_node_crop_content","path":"sprites/s_node_crop_content/s_node_crop_content.yy",},},
{"id":{"name":"s_node_crop","path":"sprites/s_node_crop/s_node_crop.yy",},},
{"id":{"name":"s_node_cross_product_2d","path":"sprites/s_node_cross_product_2d/s_node_cross_product_2d.yy",},},

View file

@ -34,6 +34,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
hold_select = true;
layer_dragging = noone;
layer_remove = -1;
layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region
PROCESSOR_OVERLAY_CHECK
@ -45,6 +46,8 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _h = 4;
for(var i = 0; i < amo; i++)
_h += lh + 4 + properties_expand[i] * eh;
_h = max(16, _h);
layer_renderer.h = _h;
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _y, _w, _h, COLORS.node_composite_bg_blend, 1);
@ -151,10 +154,18 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
draw_surface_ext_safe(_surf, _sx0, _sy0, _sss, _sss, 0, c_white, 1);
draw_set_text(f_p1, fa_left, fa_center, hover? COLORS._main_text_accent : COLORS._main_text);
var _txt = inputs[| index].name;
var _txx = _sx1 + 12;
var _txy = _cy + lh / 2 + 2;
var _txw = string_width(_txt);
var _txh = string_height(_txt);
draw_set_alpha(aa);
draw_text(_sx1 + 12, _cy + lh / 2 + 2, inputs[| index].name);
draw_text(_txx, _txy, _txt);
draw_set_alpha(1);
if(surface_selecting == index)
draw_sprite_stretched_add(THEME.menu_button_mask, 1, _txx - ui(8), _txy - _txh / 2 - ui(2), _txw + ui(16), _txh + ui(4), COLORS._main_icon, 0.3);
if(_hover && point_in_rectangle(_m[0], _m[1], _x, _cy, _x + _w, _cy + lh)) {
hoverIndex = ind;
if(layer_dragging != noone) {
@ -178,8 +189,10 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
draw_sprite_ui_uniform(THEME.arrow, _exp? 3 : 0, _bx, _cy + lh / 2 + _exp * 2, 1, cc);
if(hover && layer_dragging == noone || layer_dragging == ind) {
if(mouse_press(mb_left, _focus))
if(mouse_press(mb_left, _focus)) {
layer_dragging = ind;
surface_selecting = index;
}
}
_cy += _lh;

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "generator",
"path": "folders/nodes/data/generator.yy",
},
"resourceVersion": "1.0",
"name": "node_gradient",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -0,0 +1,36 @@
function Node_Noise_Cristal(_x, _y, _group = noone) : Node_Shader_Generator(_x, _y, _group) constructor {
name = "Cristal Noise";
shader = sh_noise_cristal;
inputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
.setDisplay(VALUE_DISPLAY.vector);
addShaderProp(SHADER_UNIFORM.float, "position");
inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 1 ] )
.setDisplay(VALUE_DISPLAY.vector);
addShaderProp(SHADER_UNIFORM.float, "scale");
inputs[| 3] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, seed_random(6))
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[| 3].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
addShaderProp(SHADER_UNIFORM.float, "seed");
inputs[| 4] = nodeValue("Iteration", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 15 );
addShaderProp(SHADER_UNIFORM.integer, "iteration");
inputs[| 5] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white );
addShaderProp(SHADER_UNIFORM.color, "color");
inputs[| 6] = nodeValue("Gamma", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1 )
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] });
addShaderProp(SHADER_UNIFORM.float, "gamma");
inputs[| 7] = nodeValue("Phase", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 30 )
.setDisplay(VALUE_DISPLAY.rotation);
addShaderProp(SHADER_UNIFORM.float, "phase");
input_display_list = [ 3,
["Output", true], 0,
["Noise", false], 1, 2, 4, 7,
["Render", false], 5, 6,
];
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"",
"%Name":"node_noise_cristal",
"isCompatibility":false,
"isDnD":false,
"name":"node_noise_cristal",
"parent":{
"name":"noise",
"path":"folders/nodes/data/generator/noise.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -722,6 +722,7 @@ function __initNodes() {
addNodeObject(generator, "Strand Noise", s_node_strand_noise, "Node_Noise_Strand", [1, Node_Noise_Strand]).setVersion(11650);
addNodeObject(generator, "Bubble Noise", s_node_bubble_noise, "Node_Noise_Bubble", [1, Node_Noise_Bubble]).patreonExtra();
addNodeObject(generator, "Flow Noise", s_node_flow_noise, "Node_Flow_Noise", [1, Node_Flow_Noise]).patreonExtra();
addNodeObject(generator, "Cristal Noise", s_node_cristal, "Node_Noise_Cristal", [1, Node_Noise_Cristal]).patreonExtra();
ds_list_add(generator, "Patterns");
addNodeObject(generator, "Stripe", s_node_stripe, "Node_Stripe", [1, Node_Stripe],, "Generate stripe pattern.");

View file

@ -712,7 +712,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
function fullView() { #region
INLINE
toCenterNode(array_empty(nodes_selecting)? nodes_list : node_selecting);
toCenterNode(array_empty(nodes_selecting)? nodes_list : nodes_selecting);
graph_s_to = 1;
} #endregion

View file

@ -254,10 +254,7 @@ function Panel_Inspector() : PanelContent() constructor {
attribute_hovering = noone;
for( var i = 0, n = array_length(meta_display); i < n; i++ ) {
if(i == 3) {
var context = PANEL_GRAPH.getCurrentContext();
if(context == noone) continue;
}
if(i == 3 && PANEL_GRAPH.getCurrentContext() == noone) continue;
var _meta = meta_display[i];
var _txt = array_safe_get_fast(_meta, 0);

View file

@ -175,7 +175,7 @@
_map.timelines = timelines.serialize();
_map.notes = array_map(notes, function(note) { return note.serialize(); } );
_map.composer = composer == noone? -4 : composer.serialize();
_map.composer = composer;
__node_list = [];
array_foreach(allNodes, function(node) { if(node.active) array_push(__node_list, node.serialize()); })
@ -209,6 +209,7 @@
if(struct_has(_map, "graphGrid")) struct_override(graphGrid, _map.graphGrid);
if(struct_has(_map, "attributes")) struct_override(attributes, _map.attributes);
if(struct_has(_map, "metadata")) meta.deserialize(_map.metadata);
if(struct_has(_map, "composer")) composer = _map.composer;
setPalette();
@ -222,8 +223,6 @@
if(struct_has(_map, "global")) globalNode.deserialize(_map.global);
else if(struct_has(_map, "global_node")) globalNode.deserialize(_map.global_node);
if(struct_has(_map, "composer") && _map.composer != -4)
composer.deserialize(_map.composer);
addons = {};
if(struct_has(_map, "addon")) {

View file

@ -71,10 +71,10 @@ function rotator(_onModify, _step = -1) : widget() constructor {
if(dragging) {
_kc = COLORS._main_icon_light;
var real_val = round(dragging.delta_acc + drag_sv);
var val = key_mod_press(CTRL)? round(real_val / 15) * 15 : real_val;
var real_val = dragging.delta_acc + drag_sv;
var val = key_mod_press(CTRL)? value_snap(real_val, 15) : real_val;
if(valStep != -1) val = round(real_val / valStep) * valStep;
if(valStep != -1) val = value_snap(real_val, valStep);
if(onModify(val))
UNDO_HOLDING = true;

View file

@ -0,0 +1,66 @@
//Cristal noise by doolhong
//https://www.shadertoy.com/view/XX33zs
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
#define PI 3.141592
#define TAU 6.283184
uniform vec2 u_resolution;
uniform vec2 scale;
uniform vec2 position;
uniform int iteration;
uniform float seed;
uniform vec4 color;
uniform float gamma;
uniform float phase;
mat2 rotMat(in float r){
r = radians(r);
float c = cos(r);
float s = sin(r);
return mat2(c, -s, s, c);
}
float abs1d(in float x){ return abs(fract(x) - 0.5); }
vec2 abs2d(in vec2 v) { return abs(fract(v) - 0.5); }
float cos1d(float p) { return cos(p * TAU) * 0.25 + 0.25;}
float sin1d(float p) { return sin(p * TAU) * 0.25 + 0.25;}
vec3 Oilnoise(in vec2 pos, in vec3 RGB) {
vec2 q = vec2(0.0);
float result = 0.0;
float s = 2.2;
float gain = 6.6 / float(iteration);
vec2 aPos = abs2d(pos) * 0.5;//add pos
for(int i = 0; i < iteration; i++) {
pos *= rotMat(phase);
q = pos * s + seed;
q = pos * s + aPos + seed;
q = vec2(cos(q));
result += sin1d(dot(q, vec2(0.3))) * gain;
s *= 1.07;
aPos += cos(smoothstep(0.0,0.15,q));
aPos *= rotMat(5.0);
aPos *= 1.232;
}
result = pow(result, 4.504);
return clamp( RGB / abs1d(dot(q, vec2(-0.240, 0.))) * .5 / result, vec3(0.), vec3(1.));
}
void main() {
vec2 pos = v_vTexcoord * scale + position;
vec3 col = Oilnoise(pos, color.rgb * gamma);
gl_FragColor = vec4(col, 1.0);
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,12 @@
{
"$GMShader":"",
"%Name":"sh_noise_cristal",
"name":"sh_noise_cristal",
"parent":{
"name":"noise",
"path":"folders/shader/generator/noise.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

@ -0,0 +1,90 @@
{
"$GMSprite":"",
"%Name":"s_node_cristal",
"bboxMode":0,
"bbox_bottom":63,
"bbox_left":0,
"bbox_right":63,
"bbox_top":0,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"cc867d54-08e4-4d4c-bf13-5f73d8d09ec1","name":"cc867d54-08e4-4d4c-bf13-5f73d8d09ec1","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"f92cb671-62bd-41b2-80fa-4d1b25b9960a","blendMode":0,"displayName":"default","isLocked":false,"name":"f92cb671-62bd-41b2-80fa-4d1b25b9960a","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_cristal",
"nineSlice":null,
"origin":4,
"parent":{
"name":"generator",
"path":"folders/nodes/icons/generator.yy",
},
"preMultiplyAlpha":false,
"resourceType":"GMSprite",
"resourceVersion":"2.0",
"sequence":{
"$GMSequence":"",
"%Name":"s_node_cristal",
"autoRecord":true,
"backdropHeight":768,
"backdropImageOpacity":0.5,
"backdropImagePath":"",
"backdropWidth":1366,
"backdropXOffset":0.0,
"backdropYOffset":0.0,
"events":{
"$KeyframeStore<MessageEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MessageEventKeyframe>",
"resourceVersion":"2.0",
},
"eventStubScript":null,
"eventToFunction":{},
"length":1.0,
"lockOrigin":false,
"moments":{
"$KeyframeStore<MomentsEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
"resourceVersion":"2.0",
},
"name":"s_node_cristal",
"playback":1,
"playbackSpeed":30.0,
"playbackSpeedType":0,
"resourceType":"GMSequence",
"resourceVersion":"2.0",
"showBackdrop":true,
"showBackdropImage":false,
"timeUnits":1,
"tracks":[
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"cc867d54-08e4-4d4c-bf13-5f73d8d09ec1","path":"sprites/s_node_cristal/s_node_cristal.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"2724b187-9118-4240-bce5-47e25620c74a","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange":null,
"volume":1.0,
"xorigin":32,
"yorigin":32,
},
"swatchColours":null,
"swfPrecision":0.5,
"textureGroupId":{
"name":"Default",
"path":"texturegroups/Default",
},
"type":0,
"VTile":false,
"width":64,
}