2023-02-28 09:43:01 +01:00
|
|
|
function Node_Fluid_Render(_x, _y, _group = noone) : Node_Fluid(_x, _y, _group) constructor {
|
2023-02-14 02:48:33 +01:00
|
|
|
name = "Render Domain";
|
|
|
|
color = COLORS.node_blend_fluid;
|
|
|
|
icon = THEME.fluid_sim;
|
2023-03-02 07:59:14 +01:00
|
|
|
use_cache = true;
|
2023-02-14 02:48:33 +01:00
|
|
|
|
|
|
|
inputs[| 0] = nodeValue("Fluid Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.fdomain, noone)
|
|
|
|
.setVisible(true, true);
|
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 1] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
|
2023-02-14 02:48:33 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
|
|
|
inputs[| 2] = nodeValue("Interpolate", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
|
|
|
|
|
|
|
inputs[| 3] = nodeValue("Draw Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
|
|
|
|
|
|
|
input_display_list = [
|
|
|
|
["Domain", false], 0,
|
|
|
|
["Render", false], 1, 2, 3,
|
|
|
|
];
|
|
|
|
|
|
|
|
outputs[| 0] = nodeValue("Fluid", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
|
|
|
|
outputs[| 1] = nodeValue("Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
|
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-08-01 19:21:51 +02:00
|
|
|
static step = function() {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _dim = getInputData(1);
|
2023-08-01 19:21:51 +02:00
|
|
|
var _outSurf = outputs[| 0].getValue();
|
|
|
|
if(!is_surface(_outSurf)) {
|
|
|
|
_outSurf = surface_create_valid(_dim[0], _dim[1], attrDepth());
|
|
|
|
outputs[| 0].setValue(_outSurf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-06 19:49:16 +02:00
|
|
|
static update = function(frame = PROJECT.animator.current_frame) {
|
|
|
|
if(recoverCache() || !PROJECT.animator.is_playing)
|
2023-05-03 21:42:17 +02:00
|
|
|
return;
|
|
|
|
|
2023-04-14 12:23:25 +02:00
|
|
|
var _dim = inputs[| 1].getValue(frame);
|
|
|
|
var _outSurf = outputs[| 0].getValue();
|
|
|
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
|
|
|
|
outputs[| 0].setValue(_outSurf);
|
|
|
|
|
2023-02-14 02:48:33 +01:00
|
|
|
var _dom = inputs[| 0].getValue(frame);
|
|
|
|
var _int = inputs[| 2].getValue(frame);
|
|
|
|
var _drw = inputs[| 3].getValue(frame);
|
|
|
|
|
|
|
|
if(_dom == noone || !instance_exists(_dom)) return;
|
|
|
|
|
|
|
|
var fSurf = _dom.sf_material_0;
|
|
|
|
if(!is_surface(fSurf)) return;
|
|
|
|
outputs[| 1].setValue(_dom.sf_world);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|