Pixel-Composer/scripts/node_smoke_render/node_smoke_render.gml

79 lines
2.2 KiB
Text
Raw Normal View History

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