Pixel-Composer/scripts/node_smoke_render/node_smoke_render.gml

68 lines
1.9 KiB
Text
Raw Normal View History

2024-03-19 09:49:29 +01:00
function Node_Smoke_Render(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group) constructor {
2023-02-14 02:48:33 +01:00
name = "Render Domain";
2023-11-10 11:32:46 +01:00
color = COLORS.node_blend_smoke;
icon = THEME.smoke_sim;
2023-10-02 14:41:44 +02:00
use_cache = CACHE_USE.auto;
2023-02-14 02:48:33 +01:00
manual_ungroupable = false;
2024-08-20 10:15:53 +02:00
newInput(0, nodeValue("Domain", self, CONNECT_TYPE.input, VALUE_TYPE.sdomain, noone))
2023-02-14 02:48:33 +01:00
.setVisible(true, true);
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Dimension(self));
2023-02-14 02:48:33 +01:00
2024-08-18 06:16:20 +02:00
newInput(2, nodeValue_Bool("Interpolate", self, false));
2023-02-14 02:48:33 +01:00
2024-08-18 06:16:20 +02:00
newInput(3, nodeValue_Bool("Draw Domain", self, false));
2023-10-07 09:09:18 +02:00
2024-08-18 06:16:20 +02:00
newInput(4, nodeValue_Bool("Auto Update", self, true));
2023-02-14 02:48:33 +01:00
input_display_list = [
["Domain", false], 0,
2024-11-22 09:43:50 +01:00
["Render", false], 4, 2, 3,
2023-02-14 02:48:33 +01:00
];
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Smoke", self, VALUE_TYPE.surface, noone));
2023-02-14 02:48:33 +01:00
2024-09-04 03:57:11 +02:00
newOutput(1, nodeValue_Output("Domain", self, VALUE_TYPE.surface, noone));
2023-02-14 02:48:33 +01:00
2023-03-19 09:17:39 +01:00
attribute_surface_depth();
2023-03-02 07:59:14 +01:00
insp2UpdateTooltip = "Clear cache";
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
static onInspector2Update = function() { clearCache(); }
2023-10-09 16:07:33 +02:00
static update = function(frame = CURRENT_FRAME) {
2023-07-06 19:49:16 +02:00
if(recoverCache() || !PROJECT.animator.is_playing)
2023-05-03 21:42:17 +02:00
return;
2024-08-06 14:04:41 +02:00
var _dom = getInputData(0);
var _int = getInputData(2);
var _drw = getInputData(3);
var _upd = getInputData(4);
2023-02-14 02:48:33 +01:00
2024-11-21 12:07:07 +01:00
SMOKE_DOMAIN_CHECK
2023-02-14 02:48:33 +01:00
2024-11-22 09:43:50 +01:00
var _outSurf = outputs[0].getValue();
_outSurf = surface_verify(_outSurf, _dom.width, _dom.height, attrDepth());
outputs[0].setValue(_outSurf);
2024-11-21 12:07:07 +01:00
var fSurf = _dom.sf_material;
2023-02-14 02:48:33 +01:00
if(!is_surface(fSurf)) return;
2023-10-07 09:09:18 +02:00
2024-11-21 12:07:07 +01:00
if(_upd) _dom.update();
2023-10-07 09:09:18 +02:00
2024-08-08 06:57:51 +02:00
outputs[1].setValue(_dom.sf_world);
2023-02-14 02:48:33 +01:00
2024-11-22 09:43:50 +01:00
surface_set_shader(_outSurf, sh_fd_visualize);
2023-02-14 02:48:33 +01:00
gpu_set_texfilter(_int);
2024-11-22 09:43:50 +01:00
draw_surface_stretched_safe(fSurf, 0, 0, _dom.width, _dom.height);
2023-02-14 02:48:33 +01:00
gpu_set_texfilter(false);
2024-11-22 09:43:50 +01:00
if(_drw) draw_surface_stretched_safe(_dom.sf_world, 0, 0, _dom.width, _dom.height);
2023-08-01 19:21:51 +02:00
surface_reset_shader();
2023-03-02 07:59:14 +01:00
2024-11-21 12:07:07 +01:00
cacheCurrentFrame(_outSurf);
2023-02-14 02:48:33 +01:00
}
}