Pixel-Composer/scripts/node_smoke_render/node_smoke_render.gml

71 lines
2 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,
2023-10-07 09:09:18 +02:00
["Render", false], 4, 1, 2, 3,
2023-02-14 02:48:33 +01:00
];
2024-08-08 06:57:51 +02:00
outputs[0] = nodeValue_Output("Smoke", self, VALUE_TYPE.surface, noone);
2023-02-14 02:48:33 +01:00
2024-08-08 06:57:51 +02:00
outputs[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 _dim = getInputData(1);
2024-08-08 06:57:51 +02:00
var _outSurf = outputs[0].getValue();
2023-04-14 12:23:25 +02:00
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
2024-08-08 06:57:51 +02:00
outputs[0].setValue(_outSurf);
2023-04-14 12:23:25 +02:00
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
2023-10-07 09:09:18 +02:00
FLUID_DOMAIN_CHECK
2023-02-14 02:48:33 +01:00
var fSurf = _dom.sf_material_0;
if(!is_surface(fSurf)) return;
2023-10-07 09:09:18 +02:00
if(_upd) fd_rectangle_update(_dom);
texture_set_interpolation(false);
2024-08-08 06:57:51 +02:00
outputs[1].setValue(_dom.sf_world);
2023-02-14 02:48:33 +01:00
2023-08-01 19:21:51 +02:00
surface_set_shader(_outSurf, sh_fd_visualize_colorize_glsl);
2023-02-14 02:48:33 +01:00
gpu_set_texfilter(_int);
2023-03-19 09:17:39 +01:00
draw_surface_stretched_safe(fSurf, 0, 0, _dim[0], _dim[1]);
2023-02-14 02:48:33 +01:00
gpu_set_texfilter(false);
if(_drw && is_surface(_dom.sf_world))
2023-03-19 09:17:39 +01:00
draw_surface_stretched_safe(_dom.sf_world, 0, 0, _dim[0], _dim[1]);
2023-08-01 19:21:51 +02:00
surface_reset_shader();
2023-03-02 07:59:14 +01:00
2023-05-03 21:42:17 +02:00
var frm = cacheCurrentFrame(_outSurf);
2023-02-14 02:48:33 +01:00
}
}