inline preview

This commit is contained in:
Tanasart 2024-12-02 08:45:17 +07:00
parent fe66f66a30
commit 0b5ffeb9d5
20 changed files with 117 additions and 75 deletions

View file

@ -101,6 +101,7 @@
{"name":"strandSim","order":5,"path":"folders/nodes/data/simulation/strandSim.yy",},
{"name":"VFX","order":6,"path":"folders/nodes/data/simulation/VFX.yy",},
{"name":"generators","order":1,"path":"folders/nodes/data/simulation/VFX/generators.yy",},
{"name":"__legacy","order":12,"path":"folders/nodes/data/simulation/VFX/__legacy.yy",},
{"name":"tiler","order":31,"path":"folders/nodes/data/tiler.yy",},
{"name":"shaders","order":2,"path":"folders/nodes/data/tiler/shaders.yy",},
{"name":"sprites","order":4,"path":"folders/nodes/data/tiler/sprites.yy",},
@ -1183,10 +1184,9 @@
{"name":"node_VFX_boids","order":10,"path":"scripts/node_VFX_boids/node_VFX_boids.yy",},
{"name":"node_VFX_destroy","order":3,"path":"scripts/node_VFX_destroy/node_VFX_destroy.yy",},
{"name":"node_VFX_group_inline","order":5,"path":"scripts/node_VFX_group_inline/node_VFX_group_inline.yy",},
{"name":"node_VFX_group","order":4,"path":"scripts/node_VFX_group/node_VFX_group.yy",},
{"name":"node_VFX_oscillate","order":9,"path":"scripts/node_VFX_oscillate/node_VFX_oscillate.yy",},
{"name":"node_VFX_override","order":6,"path":"scripts/node_VFX_override/node_VFX_override.yy",},
{"name":"node_VFX_renderer_output","order":8,"path":"scripts/node_VFX_renderer_output/node_VFX_renderer_output.yy",},
{"name":"node_VFX_renderer_output","order":1,"path":"scripts/node_VFX_renderer_output/node_VFX_renderer_output.yy",},
{"name":"node_VFX_renderer","order":7,"path":"scripts/node_VFX_renderer/node_VFX_renderer.yy",},
{"name":"node_VFX_repel","order":4,"path":"scripts/node_VFX_repel/node_VFX_repel.yy",},
{"name":"node_VFX_spawner","order":9,"path":"scripts/node_VFX_spawner/node_VFX_spawner.yy",},

View file

@ -190,6 +190,7 @@
{"$GMFolder":"","%Name":"VFX","folderPath":"folders/nodes/data/simulation/VFX.yy","name":"VFX","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"affector","folderPath":"folders/nodes/data/simulation/VFX/affector.yy","name":"affector","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"generators","folderPath":"folders/nodes/data/simulation/VFX/generators.yy","name":"generators","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"__legacy","folderPath":"folders/nodes/data/simulation/VFX/__legacy.yy","name":"__legacy","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"tiler","folderPath":"folders/nodes/data/tiler.yy","name":"tiler","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"shaders","folderPath":"folders/nodes/data/tiler/shaders.yy","name":"shaders","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"sprites","folderPath":"folders/nodes/data/tiler/sprites.yy","name":"sprites","resourceType":"GMFolder","resourceVersion":"2.0",},

View file

@ -183,5 +183,6 @@ function Node_VFX_effector(_x, _y, _group = noone) : Node(_x, _y, _group) constr
draw_sprite_fit(node_draw_icon, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
getPreviewingNode = VFX_PREVIEW_NODE;
static getPreviewingNode = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewingNode() : self; }
static getPreviewValues = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewValues() : self; }
}

View file

@ -16,4 +16,7 @@ function Node_Smoke(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
_to.node.updateForward(frame);
}
}
static getPreviewingNode = function() { return is(inline_context, Node_Smoke_Group_Inline)? inline_context.getPreviewingNode() : self; }
static getPreviewValues = function() { return is(inline_context, Node_Smoke_Group_Inline)? inline_context.getPreviewValues() : self; }
}

View file

@ -38,7 +38,7 @@ function Node_FLIP_Domain(_x, _y, _group = noone) : Node(_x, _y, _group) constru
newInput(12, nodeValue_Float("Wall Elasticity", self, 0.))
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] });
newInput(13, nodeValue_Rotation("Gravity Direction", self, 0));
newInput(13, nodeValue_Rotation("Gravity Direction", self, -90));
input_display_list = [
["Domain", false], 0, 1, 9, 12,

View file

@ -5,8 +5,8 @@
"isDnD":false,
"name":"node_VFX_group",
"parent":{
"name":"VFX",
"path":"folders/nodes/data/simulation/VFX.yy",
"name":"__legacy",
"path":"folders/nodes/data/simulation/VFX/__legacy.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",

View file

@ -88,5 +88,6 @@ function Node_VFX_Override(_x, _y, _group = noone) : Node(_x, _y, _group) constr
draw_sprite_fit(node_draw_icon, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
getPreviewingNode = VFX_PREVIEW_NODE;
static getPreviewingNode = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewingNode() : self; }
static getPreviewValues = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewValues() : self; }
}

View file

@ -115,4 +115,9 @@ function Node_VFX_Renderer(_x, _y, _group = noone) : Node(_x, _y, _group) constr
cacheCurrentFrame(_outSurf);
}
static getPreviewValues = function() {
var val = outputs[preview_channel].getValue();
return is_surface(val)? val : temp_surface[0];
}
}

View file

@ -5,8 +5,8 @@
"isDnD":false,
"name":"node_VFX_renderer_output",
"parent":{
"name":"VFX",
"path":"folders/nodes/data/simulation/VFX.yy",
"name":"__legacy",
"path":"folders/nodes/data/simulation/VFX/__legacy.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",

View file

@ -89,13 +89,6 @@ function Node_VFX_Spawner(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y
static getGraphPreviewSurface = function() { return getInputData(0); }
static getPreviewingNode = function() {
if(!is(inline_context, Node_VFX_Group_Inline)) return self;
return inline_context.getPreviewingNode();
}
static getPreviewValues = function() {
if(!is(inline_context, Node_VFX_Group_Inline)) return self;
return inline_context.getPreviewValues();
}
static getPreviewingNode = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewingNode() : self; }
static getPreviewValues = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewValues() : self; }
}

View file

@ -1,6 +1,6 @@
function Node_VFX_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "VFX Trail";
setDimension(96, 48);;
setDimension(96, 48);
manual_ungroupable = false;
@ -160,4 +160,7 @@ function Node_VFX_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) construct
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_vfx_trail, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
static getPreviewingNode = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewingNode() : self; }
static getPreviewValues = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewValues() : self; }
}

View file

@ -4,13 +4,13 @@ function Node_VFX_Triangulate(_x, _y, _group = noone) : Node(_x, _y, _group) con
icon = THEME.vfx;
use_cache = CACHE_USE.auto;
function _Point(part) constructor { #region
function _Point(part) constructor {
self.part = part;
x = part.x;
y = part.y;
static equal = function(point) { INLINE return x == point.x && y == point.y; }
} #endregion
}
manual_ungroupable = false;
@ -38,15 +38,15 @@ function Node_VFX_Triangulate(_x, _y, _group = noone) : Node(_x, _y, _group) con
static onInspector2Update = function() { clearCache(); }
static step = function() { #region
static step = function() {
var _ith = getInputData(4);
var _icl = getInputData(5);
inputs[2].setVisible(!_ith);
inputs[3].setVisible(!_icl);
} #endregion
}
static update = function() { #region
static update = function() {
var _dim = getInputData(0);
var _par = getInputData(1);
@ -124,5 +124,8 @@ function Node_VFX_Triangulate(_x, _y, _group = noone) : Node(_x, _y, _group) con
surface_reset_shader();
cacheCurrentFrame(_surf);
} #endregion
}
static getPreviewingNode = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewingNode() : self; }
static getPreviewValues = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewValues() : self; }
}

View file

@ -86,5 +86,6 @@ function Node_VFX_Variable(_x, _y, _group = noone) : Node(_x, _y, _group) constr
draw_sprite_fit(node_draw_icon, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
getPreviewingNode = VFX_PREVIEW_NODE;
static getPreviewingNode = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewingNode() : self; }
static getPreviewValues = function() { return is(inline_context, Node_VFX_Group_Inline)? inline_context.getPreviewValues() : self; }
}

View file

@ -3,6 +3,7 @@ function Node_Color_OKLCH(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
setDimension(96, 48);
newInput(0, nodeValue_Float("Lightness", self, .5))
.setDisplay(VALUE_DISPLAY.slider)
.setVisible(true, true);
newInput(1, nodeValue_Float("Chroma", self, .2))
@ -81,7 +82,7 @@ function Node_Color_OKLCH(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
);
}
inspector_info.text = _inrange? "" : "Color(s) outside 8-bit rgb range\nOutput will not be accurate.";
inspector_info.text = _inrange? "" : "Color(s) is outside the 8-bit rgb range\nOutput will not be accurate.";
return [ col, rgb ];
}

View file

@ -2,7 +2,6 @@ function Node_Smoke_Add(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group) con
name = "Add Emitter";
color = COLORS.node_blend_smoke;
icon = THEME.smoke_sim;
// setDimension(96, 96);
manual_ungroupable = false;
@ -194,9 +193,15 @@ function Node_Smoke_Add(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group) con
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
var _typ = getInputData(8);
if(_typ == 0) {
draw_circle_ui(bbox.xc, bbox.yc, min(bbox.w, bbox.h) * .25, 0);
} else {
var _mat = getInputData(1);
if(!is_surface(_mat)) return;
draw_surface_fit(_mat, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}
}

View file

@ -57,8 +57,6 @@ function Node_Smoke_Domain(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
_dim_old = [0, 0];
static update = function(frame = CURRENT_FRAME) {
RETURN_ON_REST
var _dim = getInputData( 0);
var coll = getInputData( 1);
var mdisTyp = getInputData( 2);

View file

@ -14,4 +14,17 @@ function Node_Smoke_Group_Inline(_x, _y, _group = noone) : Node_Collection_Inlin
addNode(_domain);
addNode(_render);
}
static getPreviewingNode = function() {
for( var i = 0, n = array_length(nodes); i < n; i++ )
if(is(nodes[i], Node_Smoke_Render)) return nodes[i];
return self;
}
static getPreviewValues = function() {
for( var i = 0, n = array_length(nodes); i < n; i++ )
if(is(nodes[i], Node_Smoke_Render)) return nodes[i].getPreviewValues();
return noone;
}
}

View file

@ -2,7 +2,7 @@ function Node_Smoke_Render(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
name = "Render Domain";
color = COLORS.node_blend_smoke;
icon = THEME.smoke_sim;
use_cache = CACHE_USE.auto;
use_cache = CACHE_USE.manual;
manual_ungroupable = false;
@ -30,13 +30,18 @@ function Node_Smoke_Render(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
setTrigger(2, "Clear cache", [ THEME.cache, 0, COLORS._main_icon ]);
temp_surface = [ 0 ];
static onInspector2Update = function() { clearCache(); }
static update = function(frame = CURRENT_FRAME) {
var _dom = getInputData(0);
if(is(_dom, smokeSim_Domain))
temp_surface[0] = surface_verify(temp_surface[0], _dom.width, _dom.height, attrDepth());
if(recoverCache() || !PROJECT.animator.is_playing)
return;
var _dom = getInputData(0);
var _int = getInputData(2);
var _drw = getInputData(3);
var _upd = getInputData(4);
@ -64,4 +69,11 @@ function Node_Smoke_Render(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
cacheCurrentFrame(_outSurf);
}
static getPreviewingNode = function() { return self; }
static getPreviewValues = function() {
var val = outputs[preview_channel].getValue();
return is_surface(val)? val : temp_surface[0];
}
}

View file

@ -422,7 +422,8 @@ function gamut_clip_preserve_chroma(rgb) {
if (rgb[0] < 1 && rgb[1] < 1 && rgb[2] < 1 && rgb[0] > 0 && rgb[1] > 0 && rgb[2] > 0)
return rgb;
var lab = linear_srgb_to_oklab(rgb);
// var lab = linear_srgb_to_oklab(rgb);
var lab = convertLrgbToOklab(rgb2srgbLinear(rgb))
var L = lab[0];
var eps = 0.00001;
@ -437,7 +438,8 @@ function gamut_clip_preserve_chroma(rgb) {
var L_clipped = L0 * (1 - t) + t * L;
var C_clipped = t * C;
return oklab_to_linear_srgb([ L_clipped, C_clipped * a_, C_clipped * b_ ]);
// return oklab_to_linear_srgb([ L_clipped, C_clipped * a_, C_clipped * b_ ]);
return srgbLinear2rgb(convertOklabToLrgb([ L_clipped, C_clipped * a_, C_clipped * b_ ]));
}
function gamut_clip_project_to_0_5(rgb) {

View file

@ -977,9 +977,7 @@ function Panel_Preview() : PanelContent() constructor {
surface_reset_shader();
}
switch(splitView) {
case 0 :
if(_ps0) {
if(splitView == 0 && _ps0) {
preview_node[0].previewing = 1;
switch(tileMode) {
@ -1010,7 +1008,8 @@ function Panel_Preview() : PanelContent() constructor {
draw_surface_tiled_ext_safe(preview_surface[0], psx, psy, ss, ss, 0, c_white, 1); break;
}
}
break;
switch(splitView) {
case 1 :
var sp = splitPosition * w;
@ -1033,6 +1032,7 @@ function Panel_Preview() : PanelContent() constructor {
draw_surface_part_ext_safe(preview_surface[1], sX, 0, ssw - sX, ssh, spx, ssy, ss, ss, 0, c_white, 1);
}
break;
case 2 :
var sp = splitPosition * h;