This commit is contained in:
Tanasart 2024-11-22 15:43:50 +07:00
parent ee78b0bd31
commit d164ab9ca9
67 changed files with 410 additions and 411 deletions

View file

@ -1508,17 +1508,15 @@
{"name":"sh_edge_shade_apply","order":2,"path":"shaders/sh_edge_shade_apply/sh_edge_shade_apply.yy",},
{"name":"sh_edge_shade_convert","order":1,"path":"shaders/sh_edge_shade_convert/sh_edge_shade_convert.yy",},
{"name":"sh_erode","order":8,"path":"shaders/sh_erode/sh_erode.yy",},
{"name":"sh_fd_add_velocity_glsl","order":1,"path":"shaders/sh_fd_add_velocity_glsl/sh_fd_add_velocity_glsl.yy",},
{"name":"sh_fd_advect_material_a_16_glsl","order":2,"path":"shaders/sh_fd_advect_material_a_16_glsl/sh_fd_advect_material_a_16_glsl.yy",},
{"name":"sh_fd_advect_velocity_glsl","order":7,"path":"shaders/sh_fd_advect_velocity_glsl/sh_fd_advect_velocity_glsl.yy",},
{"name":"sh_fd_calculate_pressure_jacobi_glsl","order":8,"path":"shaders/sh_fd_calculate_pressure_jacobi_glsl/sh_fd_calculate_pressure_jacobi_glsl.yy",},
{"name":"sh_fd_calculate_pressure_srj_glsl","order":9,"path":"shaders/sh_fd_calculate_pressure_srj_glsl/sh_fd_calculate_pressure_srj_glsl.yy",},
{"name":"sh_fd_calculate_velocity_divergence_glsl","order":10,"path":"shaders/sh_fd_calculate_velocity_divergence_glsl/sh_fd_calculate_velocity_divergence_glsl.yy",},
{"name":"sh_fd_add_velocity","order":1,"path":"shaders/sh_fd_add_velocity/sh_fd_add_velocity.yy",},
{"name":"sh_fd_advect_material","order":2,"path":"shaders/sh_fd_advect_material/sh_fd_advect_material.yy",},
{"name":"sh_fd_advect_velocity","order":7,"path":"shaders/sh_fd_advect_velocity/sh_fd_advect_velocity.yy",},
{"name":"sh_fd_clear_surface","order":24,"path":"shaders/sh_fd_clear_surface/sh_fd_clear_surface.yy",},
{"name":"sh_fd_replace_material_advanced_glsl","order":11,"path":"shaders/sh_fd_replace_material_advanced_glsl/sh_fd_replace_material_advanced_glsl.yy",},
{"name":"sh_fd_subtract_pressure_gradient_glsl","order":12,"path":"shaders/sh_fd_subtract_pressure_gradient_glsl/sh_fd_subtract_pressure_gradient_glsl.yy",},
{"name":"sh_fd_pressure_srj","order":9,"path":"shaders/sh_fd_pressure_srj/sh_fd_pressure_srj.yy",},
{"name":"sh_fd_subtract_pressure_gradient","order":12,"path":"shaders/sh_fd_subtract_pressure_gradient/sh_fd_subtract_pressure_gradient.yy",},
{"name":"sh_fd_turbulence","order":1,"path":"shaders/sh_fd_turbulence/sh_fd_turbulence.yy",},
{"name":"sh_fd_visualize_colorize_glsl","order":13,"path":"shaders/sh_fd_visualize_colorize_glsl/sh_fd_visualize_colorize_glsl.yy",},
{"name":"sh_fd_velocity_divergence","order":10,"path":"shaders/sh_fd_velocity_divergence/sh_fd_velocity_divergence.yy",},
{"name":"sh_fd_visualize","order":13,"path":"shaders/sh_fd_visualize/sh_fd_visualize.yy",},
{"name":"sh_fd_vortex","order":2,"path":"shaders/sh_fd_vortex/sh_fd_vortex.yy",},
{"name":"sh_find_boundary_stretch_x","order":1,"path":"shaders/sh_find_boundary_stretch_x/sh_find_boundary_stretch_x.yy",},
{"name":"sh_find_boundary_stretch_y","order":2,"path":"shaders/sh_find_boundary_stretch_y/sh_find_boundary_stretch_y.yy",},
@ -1528,7 +1526,6 @@
{"name":"sh_flip","order":7,"path":"shaders/sh_flip/sh_flip.yy",},
{"name":"sh_flood_fill_it","order":1,"path":"shaders/sh_flood_fill_it/sh_flood_fill_it.yy",},
{"name":"sh_flood_fill_replace","order":2,"path":"shaders/sh_flood_fill_replace/sh_flood_fill_replace.yy",},
{"name":"sh_fluid_bleach","order":23,"path":"shaders/sh_fluid_bleach/sh_fluid_bleach.yy",},
{"name":"sh_freeform_fill_cleanup","order":2,"path":"shaders/sh_freeform_fill_cleanup/sh_freeform_fill_cleanup.yy",},
{"name":"sh_freeform_fill_pass2","order":1,"path":"shaders/sh_freeform_fill_pass2/sh_freeform_fill_pass2.yy",},
{"name":"sh_FXAA","order":29,"path":"shaders/sh_FXAA/sh_FXAA.yy",},

View file

@ -2163,18 +2163,16 @@
{"id":{"name":"sh_edge_shade_convert","path":"shaders/sh_edge_shade_convert/sh_edge_shade_convert.yy",},},
{"id":{"name":"sh_edge_shade_extract","path":"shaders/sh_edge_shade_extract/sh_edge_shade_extract.yy",},},
{"id":{"name":"sh_erode","path":"shaders/sh_erode/sh_erode.yy",},},
{"id":{"name":"sh_fd_add_velocity_glsl","path":"shaders/sh_fd_add_velocity_glsl/sh_fd_add_velocity_glsl.yy",},},
{"id":{"name":"sh_fd_advect_material_a_16_glsl","path":"shaders/sh_fd_advect_material_a_16_glsl/sh_fd_advect_material_a_16_glsl.yy",},},
{"id":{"name":"sh_fd_advect_velocity_glsl","path":"shaders/sh_fd_advect_velocity_glsl/sh_fd_advect_velocity_glsl.yy",},},
{"id":{"name":"sh_fd_calculate_pressure_jacobi_glsl","path":"shaders/sh_fd_calculate_pressure_jacobi_glsl/sh_fd_calculate_pressure_jacobi_glsl.yy",},},
{"id":{"name":"sh_fd_calculate_pressure_srj_glsl","path":"shaders/sh_fd_calculate_pressure_srj_glsl/sh_fd_calculate_pressure_srj_glsl.yy",},},
{"id":{"name":"sh_fd_calculate_velocity_divergence_glsl","path":"shaders/sh_fd_calculate_velocity_divergence_glsl/sh_fd_calculate_velocity_divergence_glsl.yy",},},
{"id":{"name":"sh_fd_add_velocity","path":"shaders/sh_fd_add_velocity/sh_fd_add_velocity.yy",},},
{"id":{"name":"sh_fd_advect_material","path":"shaders/sh_fd_advect_material/sh_fd_advect_material.yy",},},
{"id":{"name":"sh_fd_advect_velocity","path":"shaders/sh_fd_advect_velocity/sh_fd_advect_velocity.yy",},},
{"id":{"name":"sh_fd_clear_surface","path":"shaders/sh_fd_clear_surface/sh_fd_clear_surface.yy",},},
{"id":{"name":"sh_fd_replace_material_advanced_glsl","path":"shaders/sh_fd_replace_material_advanced_glsl/sh_fd_replace_material_advanced_glsl.yy",},},
{"id":{"name":"sh_fd_pressure_srj","path":"shaders/sh_fd_pressure_srj/sh_fd_pressure_srj.yy",},},
{"id":{"name":"sh_fd_repulse","path":"shaders/sh_fd_repulse/sh_fd_repulse.yy",},},
{"id":{"name":"sh_fd_subtract_pressure_gradient_glsl","path":"shaders/sh_fd_subtract_pressure_gradient_glsl/sh_fd_subtract_pressure_gradient_glsl.yy",},},
{"id":{"name":"sh_fd_subtract_pressure_gradient","path":"shaders/sh_fd_subtract_pressure_gradient/sh_fd_subtract_pressure_gradient.yy",},},
{"id":{"name":"sh_fd_turbulence","path":"shaders/sh_fd_turbulence/sh_fd_turbulence.yy",},},
{"id":{"name":"sh_fd_visualize_colorize_glsl","path":"shaders/sh_fd_visualize_colorize_glsl/sh_fd_visualize_colorize_glsl.yy",},},
{"id":{"name":"sh_fd_velocity_divergence","path":"shaders/sh_fd_velocity_divergence/sh_fd_velocity_divergence.yy",},},
{"id":{"name":"sh_fd_visualize","path":"shaders/sh_fd_visualize/sh_fd_visualize.yy",},},
{"id":{"name":"sh_fd_vortex","path":"shaders/sh_fd_vortex/sh_fd_vortex.yy",},},
{"id":{"name":"sh_find_boundary_stretch_x","path":"shaders/sh_find_boundary_stretch_x/sh_find_boundary_stretch_x.yy",},},
{"id":{"name":"sh_find_boundary_stretch_y","path":"shaders/sh_find_boundary_stretch_y/sh_find_boundary_stretch_y.yy",},},
@ -2186,7 +2184,6 @@
{"id":{"name":"sh_flood_fill_it","path":"shaders/sh_flood_fill_it/sh_flood_fill_it.yy",},},
{"id":{"name":"sh_flood_fill_replace","path":"shaders/sh_flood_fill_replace/sh_flood_fill_replace.yy",},},
{"id":{"name":"sh_flood_fill_thres","path":"shaders/sh_flood_fill_thres/sh_flood_fill_thres.yy",},},
{"id":{"name":"sh_fluid_bleach","path":"shaders/sh_fluid_bleach/sh_fluid_bleach.yy",},},
{"id":{"name":"sh_freeform_fill_cleanup","path":"shaders/sh_freeform_fill_cleanup/sh_freeform_fill_cleanup.yy",},},
{"id":{"name":"sh_freeform_fill_pass1","path":"shaders/sh_freeform_fill_pass1/sh_freeform_fill_pass1.yy",},},
{"id":{"name":"sh_freeform_fill_pass2","path":"shaders/sh_freeform_fill_pass2/sh_freeform_fill_pass2.yy",},},

View file

@ -5,6 +5,12 @@ enum FD_TARGET_TYPE {
ADD_VELOCITY,
}
enum FD_BOUNDARY_TYPE {
empty,
wall,
wrap
}
function smokeSim_Domain(_width, _height) constructor {
sf_world = noone;
sf_world_update = true;
@ -17,22 +23,22 @@ function smokeSim_Domain(_width, _height) constructor {
acceleration_x = 0;
acceleration_y = 0;
time_step = 1;
initial_value_pressure = 0.5;
material_dissipation_type = 0;
material_dissipation_value = 1;
velocity_time_step = 1;
velocity_dissipation_type = 1;
velocity_dissipation_value = 0;
velocity_maccormack_weight = 0.5;
material_maccormack_weight = 0;
pressure_type = -3;
pressure_relax = 0;
material_time_step = 1;
material_maccormack_weight = 0;
texture_repeat = false;
texture_wall = false;
sf_world = 0;
sf_pressure = 0; sf_pressure_t = 0;
@ -59,7 +65,7 @@ function smokeSim_Domain(_width, _height) constructor {
}
static verify = function() {
var _f = surface_rgba16float;
var _f = surface_rgba32float;
if(!surface_valid(sf_pressure, width, height, _f)) { sf_pressure = surface_verify(sf_pressure, width, height, _f); surface_clear(sf_pressure); }
if(!surface_valid(sf_pressure_t, width, height, _f)) { sf_pressure_t = surface_verify(sf_pressure_t, width, height, _f); surface_clear(sf_pressure_t); }
@ -144,16 +150,39 @@ function smokeSim_Domain(_width, _height) constructor {
}
}
static setBoundary = function(boundary) {
switch(boundary) {
case FD_BOUNDARY_TYPE.empty :
texture_repeat = false;
texture_wall = false;
break;
case FD_BOUNDARY_TYPE.wall :
texture_repeat = false;
texture_wall = true;
break;
case FD_BOUNDARY_TYPE.wrap :
texture_repeat = true;
texture_wall = false;
break;
}
return self;
}
static addMaterial = function(surface, _x, _y, xscale, yscale, color, alpha) {
setTarget(FD_TARGET_TYPE.ADD_MATERIAL);
draw_surface_ext_safe(surface, _x, _y, xscale, yscale, 0, color, alpha);
resetTarget();
}
static addVelocity = function(surface, _x, _y, xscale, yscale, xvelo, yvelo) {
static addVelocity = function(surface, _x = 0, _y = 0, xscale = 1, yscale = 1, xvelo = 1, yvelo = 1) {
setTarget(FD_TARGET_TYPE.ADD_VELOCITY);
shader_set(sh_fd_add_velocity);
shader_set_f("velo", xvelo, yvelo);
draw_surface_ext_safe(surface, _x, _y, xscale, yscale);
shader_reset();
resetTarget();
}
@ -171,14 +200,17 @@ function smokeSim_Domain(_width, _height) constructor {
verify();
surface_set_target(sf_velocity_t);
shader_set(sh_fd_advect_velocity_glsl);
shader_set(sh_fd_advect_velocity);
shader_set_surface("texture_world", sf_world);
shader_set_surface("texture_material", sf_material);
shader_set_f("max_force", max_force);
shader_set_i("mode", acceleration_type);
shader_set_f("precalculated", velocity_time_step * tx_width, velocity_time_step * tx_height, tx_width, tx_height);
shader_set_i("repeat", texture_repeat);
shader_set_i("wall", texture_wall);
shader_set_f("precalculated", time_step * tx_width, time_step * tx_height, tx_width, tx_height);
shader_set_f("precalculated_1", velocity_dissipation_type, velocity_dissipation_value, velocity_maccormack_weight * 0.5);
shader_set_f("acceleration", acceleration_x, acceleration_y, acceleration_a, acceleration_b);
shader_set_f("texel_size", tx_width, tx_height);
draw_surface_safe(sf_velocity);
shader_reset();
@ -190,17 +222,21 @@ function smokeSim_Domain(_width, _height) constructor {
// Calculates divergence of velocity.
surface_set_target(sf_pressure);
shader_set(sh_fd_calculate_velocity_divergence_glsl);
shader_set(sh_fd_velocity_divergence);
shader_set_f("max_force", max_force);
shader_set_i("repeat", texture_repeat);
shader_set_i("wall", texture_wall);
shader_set_f("initial_value_pressure", initial_value_pressure);
shader_set_f("texel_size", tx_width, tx_height);
draw_surface_safe(sf_velocity);
shader_reset();
surface_reset_target();
shader_set(sh_fd_calculate_pressure_srj_glsl);
shader_set(sh_fd_pressure_srj);
shader_set_f("texel_size", tx_width, tx_height);
shader_set_f("max_force", max_force);
shader_set_i("repeat", texture_repeat);
shader_set_i("wall", texture_wall);
var length = array_length(pressure_relax);
for (var i = 0; i < length; ++i) {
@ -217,10 +253,12 @@ function smokeSim_Domain(_width, _height) constructor {
// Calculates the gradient of pressure and subtracts it from the velocity.
surface_set_target(sf_velocity_t);
shader_set(sh_fd_subtract_pressure_gradient_glsl);
shader_set(sh_fd_subtract_pressure_gradient);
shader_set_surface("texture_pressure", sf_pressure);
shader_set_f("texel_size", tx_width, tx_height);
shader_set_f("max_force", max_force);
shader_set_i("repeat", texture_repeat);
shader_set_i("wall", texture_wall);
draw_surface_safe(sf_velocity);
shader_reset();
surface_reset_target();
@ -243,12 +281,14 @@ function smokeSim_Domain(_width, _height) constructor {
var _scale = .5;
surface_set_target(sf_material_t);
shader_set(sh_fd_advect_material_a_16_glsl);
shader_set(sh_fd_advect_material);
shader_set_surface("texture_velocity", sf_velocity);
shader_set_surface("texture_world", sf_world);
shader_set_i("repeat", texture_repeat);
shader_set_i("wall", texture_wall);
shader_set_f("max_force", max_force);
shader_set_f("texel_size", tx_width, tx_height);
shader_set_f("precalculated", material_time_step * tx_width, material_time_step * tx_height);
shader_set_f("precalculated", time_step * tx_width, time_step * tx_height);
shader_set_f("precalculated_1", tx_width * _scale, tx_height * _scale, -tx_width * _scale, -tx_height * _scale);
shader_set_f("precalculated_2", material_dissipation_type, material_dissipation_value, material_maccormack_weight * 0.5);
draw_surface_safe(sf_material);
@ -282,13 +322,8 @@ function smokeSim_Domain(_width, _height) constructor {
break;
case FD_TARGET_TYPE.ADD_VELOCITY:
surface_set_target(sf_velocity_t);
gpu_set_blendenable(0);
draw_surface_safe(sf_velocity);
shader_set(sh_fd_add_velocity_glsl);
shader_set_f("addend", 0.5 + 0.5 * tx_width, 0.5 + 0.5 * tx_height);
shader_set_surface("texture_velocity", sf_velocity);
surface_set_target(sf_velocity);
gpu_set_blendmode_ext(bm_one, bm_one);
break;
}
}
@ -296,17 +331,6 @@ function smokeSim_Domain(_width, _height) constructor {
static resetTarget = function() {
surface_reset_target();
BLEND_NORMAL
switch (target_type) {
case FD_TARGET_TYPE.ADD_VELOCITY:
shader_reset();
gpu_set_blendenable(1);
var temporary = sf_velocity_t;
sf_velocity_t = sf_velocity;
sf_velocity = temporary;
break;
}
}
static free = function() {

View file

@ -11,7 +11,7 @@ function Node_Smoke_Add(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group) con
newInput(1, nodeValue_Surface("Fluid brush", self));
newInput(2, nodeValue_Vec2("Position", self, [0, 0]));
newInput(2, nodeValue_Vec2("Position", self, [ 0, 0 ]));
newInput(3, nodeValue_Bool("Active", self, true));
@ -21,100 +21,175 @@ function Node_Smoke_Add(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group) con
newInput(5, nodeValue_Float("Density", self, 1))
.setDisplay(VALUE_DISPLAY.slider);
newInput(6, nodeValue_Int("Expand velocity mask", self, 0));
newInput(6, nodeValue_Int("Expand velocity mask", self, 1));
newInput(7, nodeValue_Vec2("Velocity", self, [0, 0]));
input_display_list = [
["Domain", false], 0,
["Fluid", false], 3, 1, 5, 2,
["Velocity", false], 7, 4, 6,
];
newInput(8, nodeValue_Enum_Button("Type", self, 0, [ "Shape", "Surface" ]));
_prevPos = noone;
newInput(9, nodeValue_Vec2("Scale", self, [ 8, 8 ]));
newInput(10, nodeValue_Float("Repulse", self, 0));
newInput(11, nodeValue_Enum_Scroll("Shape", self, 0, [ "Disk", "Ring" ]));
newInput(12, nodeValue_Slider_Range("Level", self, [ 0, 1 ]));
newInput(13, nodeValue_Float("Spokes", self, 0));
newInput(14, nodeValue_Rotation("Twist", self, 0));
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
newOutput(0, nodeValue_Output("Domain", self, VALUE_TYPE.sdomain, noone));
temp_surface = [ surface_create(1, 1) ];
input_display_list = [ 3, 0,
["Brush", false], 8, 1, 11, 12, 2, 9,
["Fluid", false], 5,
["Push", false], 6, 7, 4,
["Repulse", false], 10, 13, 14,
];
_prevPos = noone;
temp_surface = array_create(4);
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _typ = getInputData(8);
var _mat = getInputData(1);
var _pos = getInputData(2);
var _sca = getInputData(9);
if(is_surface(_mat)) {
var sw = surface_get_width_safe(_mat) * _s;
var sh = surface_get_height_safe(_mat) * _s;
var mx = _x + _pos[0] * _s - sw / 2;
var my = _y + _pos[1] * _s - sh / 2;
var _px = _x + _pos[0] * _s;
var _py = _y + _pos[1] * _s;
if(_typ == 0) {
var sw = _sca[0] * _s;
var sh = _sca[1] * _s;
draw_surface_ext_safe(_mat, mx, my, _s, _s, 0, c_white, 0.5);
draw_set_color(c_white);
draw_set_alpha(.5);
draw_ellipse(_px - sw, _py - sh, _px + sw, _py + sh, false);
draw_set_alpha(1);
var hv = inputs[9].drawOverlay(hover, active, _px, _py, _s, _mx, _my, _snx, _sny); hover &= !hv;
} else if(_typ == 1) {
if(is_surface(_mat)) {
var sw = surface_get_width_safe(_mat) * _s;
var sh = surface_get_height_safe(_mat) * _s;
var mx = _px - sw / 2;
var my = _py - sh / 2;
draw_surface_ext_safe(_mat, mx, my, _s, _s, 0, c_white, 0.5);
}
}
inputs[2].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
}
static update = function(frame = CURRENT_FRAME) {
var _dom = getInputData(0);
var _mat = getInputData(1);
var _pos = getInputData(2);
var _act = getInputData(3);
var _inh = getInputData(4);
var _den = getInputData(5);
var _msk = getInputData(6);
var _vel = getInputData(7);
var _dom = getInputData(0);
var _typ = getInputData( 8);
var _mat = getInputData( 1);
var _den = getInputData( 5);
var _pos = getInputData( 2);
var _sca = getInputData( 9);
var _shp = getInputData(11);
var _lev = getInputData(12);
var _msk = getInputData( 6);
var _vel = getInputData( 7);
var _inh = getInputData( 4);
var _rep = getInputData(10);
var _spk = getInputData(13);
var _spk_r = getInputData(14);
inputs[ 1].setVisible(_typ == 1, _typ == 1);
inputs[ 9].setVisible(_typ == 0);
inputs[11].setVisible(_typ == 0);
inputs[12].setVisible(_typ == 0);
SMOKE_DOMAIN_CHECK
outputs[0].setValue(_dom);
if(!_act) return;
if(!is_surface(_mat)) return;
var sw = surface_get_width_safe(_mat);
var sh = surface_get_height_safe(_mat);
var dx = _vel[0];
var dy = _vel[1];
var sw = 0;
var sh = 0;
if(_prevPos != noone && _inh != 0) {
dx += (_pos[0] - _prevPos[0]) * _inh;
dy += (_pos[1] - _prevPos[1]) * _inh;
}
temp_surface[0] = surface_verify(temp_surface[0], sw, sh);
surface_set_shader(temp_surface[0], sh_fluid_bleach);
draw_surface_safe(_mat);
surface_reset_shader();
_prevPos[0] = _pos[0];
_prevPos[1] = _pos[1];
if(_typ == 0) {
sw = _sca[0] * 2;
sh = _sca[1] * 2;
if(dx != 0 || dy != 0) {
if(_msk == 0)
_dom.addVelocity(temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, dx, dy);
else {
var _vw = sw + max(0, _msk * 2);
var _vh = sh + max(0, _msk * 2);
temp_surface[0] = surface_verify(temp_surface[0], sw, sh);
surface_set_shader(temp_surface[0], sh_draw_grey_alpha);
shader_set_f("smooth", _lev);
switch(_shp) {
case 0 : draw_ellipse_color(0, 0, sw - 1, sh - 1, c_white, c_white, false); break;
case 1 : draw_ellipse_color(0, 0, sw - 1, sh - 1, c_black, c_white, false); break;
}
surface_reset_shader();
var _vmask = surface_create(_vw, _vh);
surface_set_shader(_vmask,,, BLEND.over);
draw_surface_safe(temp_surface[0], max(0, _msk), max(0, _msk));
surface_reset_shader();
var vel_mask = surface_create(_vw, _vh);
surface_set_shader(vel_mask, sh_mask_expand);
shader_set_f("dimension", _vw, _vh);
shader_set_f("amount", _msk);
draw_surface_safe(_vmask);
surface_reset_shader();
_dom.addVelocity(vel_mask, _pos[0] - _vw / 2, _pos[1] - _vh / 2, 1, 1, dx, dy);
surface_free(_vmask);
surface_free(vel_mask);
}
} else if(_typ == 1) {
if(!is_surface(_mat)) return;
sw = surface_get_width_safe(_mat);
sh = surface_get_height_safe(_mat);
temp_surface[0] = surface_verify(temp_surface[0], sw, sh);
surface_set_shader(temp_surface[0], sh_fd_visualize);
draw_surface_safe(_mat);
surface_reset_shader();
}
_dom.addMaterial(temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, c_white, _den);
_prevPos[0] = _pos[0];
_prevPos[1] = _pos[1];
////////////////////////////////////////////////////////// VELOCITY //////////////////////////////////////////////////////////
var _vw = sw + max(0, _msk * 2);
var _vh = sh + max(0, _msk * 2);
temp_surface[1] = surface_verify(temp_surface[1], _vw, _vh);
surface_set_shader(temp_surface[1],,, BLEND.over);
draw_surface_safe(temp_surface[0], max(0, _msk), max(0, _msk));
surface_reset_shader();
temp_surface[2] = surface_verify(temp_surface[2], _vw, _vh);
surface_set_shader(temp_surface[2], sh_mask_expand);
shader_set_f("dimension", _vw, _vh);
shader_set_f("amount", _msk);
draw_surface_safe(temp_surface[1]);
surface_reset_shader();
if(dx != 0 || dy != 0) _dom.addVelocity(temp_surface[2], _pos[0] - _vw / 2, _pos[1] - _vh / 2, 1, 1, dx, dy);
if(_rep != 0) {
temp_surface[3] = surface_verify(temp_surface[3], _dom.width, _dom.height, surface_rgba32float);
surface_set_shader(temp_surface[3], sh_fd_repulse);
shader_set_f("strength", _rep);
shader_set_f("spokes", _spk);
shader_set_f("rotate", degtorad(_spk_r));
shader_set_f("radius", max(_vw /_dom.width, _vh / _dom.height));
shader_set_f("center", _pos[0] / _dom.width, _pos[1] / _dom.height);
draw_empty();
surface_reset_shader();
_dom.addVelocity(temp_surface[3]);
}
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {

View file

@ -9,57 +9,103 @@ function Node_Smoke_Apply_Velocity(_x, _y, _group = noone) : Node_Smoke(_x, _y,
newInput(1, nodeValue_Surface("Brush", self));
newInput(2, nodeValue_Vec2("Position", self, [0, 0]));
newInput(2, nodeValue_Vec2("Position", self, [ 0, 0 ]));
newInput(3, nodeValue_Vec2("Velocity", self, [0, 0]));
newInput(3, nodeValue_Vec2("Velocity", self, [ 1, 0 ]));
newInput(4, nodeValue_Bool("Active", self, true));
input_display_list = [
["Domain", false], 0,
["Velocity", false], 4, 1, 2, 3
newInput(5, nodeValue_Enum_Button("Type", self, 0, [ "Shape", "Surface" ]));
newInput(6, nodeValue_Vec2("Scale", self, [ 8, 8 ]));
newInput(7, nodeValue_Float("Strength", self, 1));
input_display_list = [ 4, 0,
["Brush", false], 5, 1, 6, 2,
["Velocity", false], 3, 7,
];
newOutput(0, nodeValue_Output("Domain", self, VALUE_TYPE.sdomain, noone));
temp_surface = [ 0 ];
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _typ = getInputData(5);
var _mat = getInputData(1);
var _pos = getInputData(2);
var _sca = getInputData(6);
if(is_surface(_mat)) {
var sw = surface_get_width_safe(_mat) * _s;
var sh = surface_get_height_safe(_mat) * _s;
var mx = _x + _pos[0] * _s - sw / 2;
var my = _y + _pos[1] * _s - sh / 2;
var _px = _x + _pos[0] * _s;
var _py = _y + _pos[1] * _s;
if(_typ == 0) {
var sw = _sca[0] * _s;
var sh = _sca[1] * _s;
draw_surface_ext_safe(_mat, mx, my, _s, _s, 0, c_white, 0.5);
draw_set_color(c_white);
draw_set_alpha(.5);
draw_ellipse(_px - sw, _py - sh, _px + sw, _py + sh, false);
draw_set_alpha(1);
var hv = inputs[6].drawOverlay(hover, active, _px, _py, _s, _mx, _my, _snx, _sny); hover &= !hv;
} else if(_typ == 1) {
if(is_surface(_mat)) {
var sw = surface_get_width_safe(_mat) * _s;
var sh = surface_get_height_safe(_mat) * _s;
var mx = _px - sw / 2;
var my = _py - sh / 2;
draw_surface_ext_safe(_mat, mx, my, _s, _s, 0, c_white, 0.5);
}
}
inputs[2].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
}
static update = function(frame = CURRENT_FRAME) {
var _act = getInputData(4);
var _dom = getInputData(0);
var _typ = getInputData(5);
var _mat = getInputData(1);
var _sca = getInputData(6);
var _pos = getInputData(2);
var _vel = getInputData(3);
var _act = getInputData(4);
var _str = getInputData(7);
inputs[1].setVisible(_typ == 1, _typ == 1);
inputs[6].setVisible(_typ == 0);
SMOKE_DOMAIN_CHECK
outputs[0].setValue(_dom);
if(!_act) return;
if(!is_surface(_mat)) return;
var sw, sh;
var sw = surface_get_width_safe(_mat);
var sh = surface_get_height_safe(_mat);
if(_typ == 0) {
sw = _sca[0] * 2;
sh = _sca[1] * 2;
temp_surface[0] = surface_verify(temp_surface[0], sw, sh);
surface_set_shader(temp_surface[0], noone);
draw_ellipse_color(0, 0, sw - 1, sh - 1, c_white, c_white, false);
surface_reset_shader();
} else if(_typ == 1) {
if(!is_surface(_mat)) return;
sw = surface_get_width_safe(_mat);
sh = surface_get_height_safe(_mat);
temp_surface[0] = surface_verify(temp_surface[0], sw, sh);
surface_set_shader(temp_surface[0], sh_fd_visualize);
draw_surface_safe(_mat);
surface_reset_shader();
}
temp_surface[0] = surface_verify(temp_surface[0], sw, sh);
surface_set_shader(temp_surface[0], sh_fluid_bleach);
draw_surface_safe(_mat);
surface_reset_shader();
_dom.addVelocity(temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, _vel[0], _vel[1]);
_dom.addVelocity(temp_surface[0], _pos[0] - sw / 2, _pos[1] - sh / 2, 1, 1, _vel[0] * _str, _vel[1] * _str);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {

View file

@ -32,7 +32,11 @@ function Node_Smoke_Domain(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
newInput(10, nodeValue_Float("Velocity Maccormack weight", self, 0))
.setDisplay(VALUE_DISPLAY.slider);
newInput(11, nodeValue_Bool("Wrap", self, false));
newInput(11, nodeValue_Enum_Scroll("Boundary", self, 0, [ "Free", "Wall", "Wrap" ]));
newInput(12, nodeValue_Float("Timestep", self, 1));
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
newOutput(0, nodeValue_Output("Domain", self, VALUE_TYPE.sdomain, noone));
@ -43,13 +47,13 @@ function Node_Smoke_Domain(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
.setVisible(false);
input_display_list = [
["Domain", false], 0, 11, 1,
["Properties", false], 8, 6, 7,
["Dissipation", false], 2, 3, 4, 5,
["Huh?", true], 9, 10,
["Domain", false], 0, 1, 11, 12,
["Properties", false], 8, 6, 7,
["Dissipation", false], 3, 5,
["Advance Setings", true], 2, 4, 9, 10,
];
domain = new smokeSim_Domain(256, 256);
domain = new smokeSim_Domain(1, 1);
_dim_old = [0, 0];
static update = function(frame = CURRENT_FRAME) {
@ -66,7 +70,8 @@ function Node_Smoke_Domain(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
var inPress = getInputData( 8);
var mMac = getInputData( 9);
var vMac = getInputData(10);
var wrap = getInputData(11);
var bound = getInputData(11);
var tstp = getInputData(12);
if(IS_FIRST_FRAME || !is_surface(domain.sf_world)) {
domain.resetSize(_dim[0], _dim[1]);
@ -82,8 +87,8 @@ function Node_Smoke_Domain(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
domain.setMaterial(mdisTyp, mdis);
domain.setVelocity(vdisTyp, vdis);
domain.setMaccormack(vMac, mMac);
domain.texture_repeat = wrap;
domain.setBoundary(bound);
domain.time_step = tstp;
outputs[0].setValue(domain);
outputs[1].setValue(domain.sf_velocity);

View file

@ -19,7 +19,7 @@ function Node_Smoke_Render(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
input_display_list = [
["Domain", false], 0,
["Render", false], 4, 1, 2, 3,
["Render", false], 4, 2, 3,
];
newOutput(0, nodeValue_Output("Smoke", self, VALUE_TYPE.surface, noone));
@ -37,11 +37,6 @@ function Node_Smoke_Render(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
if(recoverCache() || !PROJECT.animator.is_playing)
return;
var _dim = getInputData(1);
var _outSurf = outputs[0].getValue();
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
outputs[0].setValue(_outSurf);
var _dom = getInputData(0);
var _int = getInputData(2);
var _drw = getInputData(3);
@ -49,6 +44,10 @@ function Node_Smoke_Render(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
SMOKE_DOMAIN_CHECK
var _outSurf = outputs[0].getValue();
_outSurf = surface_verify(_outSurf, _dom.width, _dom.height, attrDepth());
outputs[0].setValue(_outSurf);
var fSurf = _dom.sf_material;
if(!is_surface(fSurf)) return;
@ -56,12 +55,12 @@ function Node_Smoke_Render(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
outputs[1].setValue(_dom.sf_world);
surface_set_shader(_outSurf, sh_fd_visualize_colorize_glsl);
surface_set_shader(_outSurf, sh_fd_visualize);
gpu_set_texfilter(_int);
draw_surface_stretched_safe(fSurf, 0, 0, _dim[0], _dim[1]);
draw_surface_stretched_safe(fSurf, 0, 0, _dom.width, _dom.height);
gpu_set_texfilter(false);
// if(_drw) draw_surface_stretched_safe(_dom.sf_world, 0, 0, _dim[0], _dim[1]);
if(_drw) draw_surface_stretched_safe(_dom.sf_world, 0, 0, _dom.width, _dom.height);
surface_reset_shader();
cacheCurrentFrame(_outSurf);

View file

@ -75,7 +75,7 @@ function Node_Smoke_Render_Output(_x, _y, _group = noone) : Node_Group_Output(_x
if(_upd) _dom.update();
surface_set_shader(_outSurf, sh_fd_visualize_colorize_glsl);
surface_set_shader(_outSurf, sh_fd_visualize);
gpu_set_texfilter(_int);
draw_surface_stretched_safe(fSurf, 0, 0, _dim[0], _dim[1]);
gpu_set_texfilter(false);

View file

@ -14,15 +14,19 @@ function Node_Smoke_Repulse(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
newInput(3, nodeValue_Float("Strength", self, 0.10))
.setDisplay(VALUE_DISPLAY.slider, { range: [-1, 1, 0.01] });
newInput(4, nodeValue_Enum_Button("Mode", self, 0, [ "Override", "Add" ]));
newInput(4, nodeValue_Float("Spokes", self, 0));
newInput(5, nodeValue_Rotation("Twist", self, 0));
input_display_list = [
["Domain", false], 0,
["Repulse", false], 4, 1, 2, 3
["Repulse", false], 1, 2, 3, 4, 5,
];
newOutput(0, nodeValue_Output("Domain", self, VALUE_TYPE.sdomain, noone));
temp_surface = [ 0 ];
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _pos = getInputData(1);
var _rad = getInputData(2);
@ -41,30 +45,25 @@ function Node_Smoke_Repulse(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
var _pos = getInputData(1);
var _rad = getInputData(2);
var _str = getInputData(3);
var _mod = getInputData(4);
var _spk = getInputData(4);
var _spk_r = getInputData(5);
SMOKE_DOMAIN_CHECK
outputs[0].setValue(_dom);
_rad = max(_rad, 1);
var vSurface = surface_create_size(_dom.sf_velocity);
surface_set_target(vSurface)
draw_clear_alpha(0., 0.);
shader_set(sh_fd_repulse);
BLEND_OVERRIDE;
temp_surface[0] = surface_verify(temp_surface[0], _dom.width, _dom.height, surface_rgba32float);
surface_set_shader(temp_surface[0], sh_fd_repulse);
shader_set_f("strength", _str);
draw_sprite_stretched(s_fx_pixel, 0, _pos[0] - _rad, _pos[1] - _rad, _rad * 2, _rad * 2);
BLEND_NORMAL;
shader_reset();
surface_reset_target();
shader_set_f("spokes", _spk);
shader_set_f("rotate", degtorad(_spk_r));
shader_set_f("radius", max(_rad /_dom.width, _rad / _dom.height));
shader_set_f("center", _pos[0] / _dom.width, _pos[1] / _dom.height);
draw_empty();
surface_reset_shader();
_dom.setTarget(_mod? FD_TARGET_TYPE.ADD_VELOCITY : FD_TARGET_TYPE.REPLACE_VELOCITY);
draw_surface_safe(vSurface);
_dom.resetTarget();
surface_free(vSurface);
_dom.addVelocity(temp_surface[0]);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {

View file

@ -17,15 +17,15 @@ function Node_Smoke_Turbulence(_x, _y, _group = noone) : Node_Smoke(_x, _y, _gro
newInput(4, nodeValueSeed(self));
newInput(5, nodeValue_Enum_Button("Mode", self, 0, [ "Override", "Add" ]));
input_display_list = [
["Domain", false], 0,
["Turbulence", false], 5, 1, 2, 4, 3
["Turbulence", false], 1, 2, 4, 3
];
newOutput(0, nodeValue_Output("Domain", self, VALUE_TYPE.sdomain, noone));
temp_surface = [ 0 ];
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
inputs[1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
}
@ -36,14 +36,12 @@ function Node_Smoke_Turbulence(_x, _y, _group = noone) : Node_Smoke(_x, _y, _gro
var _str = getInputData(2);
var _sca = getInputData(3);
var _sed = getInputData(4);
var _mod = getInputData(5);
SMOKE_DOMAIN_CHECK
outputs[0].setValue(_dom);
temp_surface[0] = surface_verify(temp_surface[0], _dom.width, _dom.height, surface_rgba32float);
var vSurface = surface_create_size(_dom.sf_velocity);
surface_set_target(vSurface)
surface_set_target(temp_surface[0])
draw_clear_alpha(0., 0.);
shader_set(sh_fd_turbulence);
BLEND_OVERRIDE;
@ -56,11 +54,7 @@ function Node_Smoke_Turbulence(_x, _y, _group = noone) : Node_Smoke(_x, _y, _gro
shader_reset();
surface_reset_target();
_dom.setTarget(_mod? FD_TARGET_TYPE.ADD_VELOCITY : FD_TARGET_TYPE.REPLACE_VELOCITY);
draw_surface_safe(vSurface);
_dom.resetTarget();
surface_free(vSurface);
_dom.addVelocity(temp_surface[0]);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {

View file

@ -17,16 +17,16 @@ function Node_Smoke_Vortex(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
newInput(4, nodeValue_Float("Attraction", self, 0))
.setDisplay(VALUE_DISPLAY.slider, { range: [-1, 1, 0.01] });
newInput(5, nodeValue_Enum_Button("Mode", self, 0, [ "Override", "Add" ]));
input_display_list = [
["Domain", false], 0,
["Vortex", false], 5, 1, 2, 3, 4
["Vortex", false], 1, 2, 3, 4
];
newOutput(0, nodeValue_Output("Domain", self, VALUE_TYPE.sdomain, noone));
newOutput(1, nodeValue_Output("Domain", self, VALUE_TYPE.surface, noone));
temp_surface = [ 0 ];
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _pos = getInputData(1);
var _rad = getInputData(2);
@ -46,15 +46,14 @@ function Node_Smoke_Vortex(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
var _rad = getInputData(2);
var _str = getInputData(3);
var _aio = getInputData(4);
var _mod = getInputData(5);
SMOKE_DOMAIN_CHECK
outputs[0].setValue(_dom);
_rad = max(_rad, 1);
var vSurface = surface_create_size(_dom.sf_velocity);
temp_surface[0] = surface_verify(temp_surface[0], _dom.width, _dom.height, surface_rgba32float);
surface_set_target(vSurface)
surface_set_target(temp_surface[0])
draw_clear_alpha(0., 0.);
shader_set(sh_fd_vortex);
BLEND_OVERRIDE;
@ -66,11 +65,9 @@ function Node_Smoke_Vortex(_x, _y, _group = noone) : Node_Smoke(_x, _y, _group)
shader_reset();
surface_reset_target();
_dom.setTarget(_mod? FD_TARGET_TYPE.ADD_VELOCITY : FD_TARGET_TYPE.REPLACE_VELOCITY);
draw_surface_safe(vSurface);
_dom.resetTarget();
_dom.addVelocity(temp_surface[0]);
outputs[1].setValue(vSurface);
outputs[1].setValue(temp_surface[0]);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {

View file

@ -0,0 +1,10 @@
varying vec2 v_vTexcoord;
uniform vec2 velo;
void main() {
vec4 velocity = texture2D(gm_BaseTexture, v_vTexcoord);
velocity.xy *= velo.xy;
gl_FragColor = velocity;
}

View file

@ -1,5 +1,3 @@
// Passthrough vertex shader.
attribute vec4 in_Position;
attribute vec2 in_TextureCoord;

View file

@ -1,7 +1,7 @@
{
"$GMShader":"",
"%Name":"sh_fd_add_velocity_glsl",
"name":"sh_fd_add_velocity_glsl",
"%Name":"sh_fd_add_velocity",
"name":"sh_fd_add_velocity",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",

View file

@ -1,14 +0,0 @@
varying vec2 v_vTexcoord;
varying vec2 v_vScreencoord;
varying vec4 color;
uniform vec2 velo;
uniform sampler2D texture_velocity;
void main() {
vec4 velocity = texture2D(texture_velocity, v_vScreencoord);
vec3 sample = texture2D(gm_BaseTexture, v_vTexcoord).xyw;
velocity.xy += (velo.xy * sample.xy) * 8.0 * sample.z;
gl_FragColor = velocity;
}

View file

@ -1,16 +0,0 @@
attribute vec4 in_Position;
attribute vec2 in_TextureCoord;
attribute vec4 in_Colour;
varying vec2 v_vTexcoord;
varying vec2 v_vScreencoord;
varying vec4 color;
uniform vec2 addend;
void main() {
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * in_Position;
v_vTexcoord = in_TextureCoord;
v_vScreencoord = gl_Position.xy * vec2(0.5, -0.5) + addend;
color = in_Colour;
}

View file

@ -5,6 +5,8 @@ varying vec2 v_vTexcoord;
uniform sampler2D texture_velocity;
uniform sampler2D texture_world;
uniform int repeat;
uniform int wall;
uniform vec2 texel_size;
uniform vec2 precalculated; // x: time_step * texel_size.x, y: time_step * texel_size.y.
uniform vec4 precalculated_1; // x: texel_size.x * 0.5, y: texel_size.y * 0.5, z: texel_size.x * -0.5, w: texel_size.y * -0.5.

View file

@ -1,5 +1,3 @@
// Passthrough vertex shader.
attribute vec4 in_Position;
attribute vec2 in_TextureCoord;

View file

@ -1,7 +1,7 @@
{
"$GMShader":"",
"%Name":"sh_fd_advect_velocity_glsl",
"name":"sh_fd_advect_velocity_glsl",
"%Name":"sh_fd_advect_material",
"name":"sh_fd_advect_material",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",

View file

@ -4,9 +4,12 @@
varying vec2 v_vTexcoord;
uniform int mode;
uniform int repeat;
uniform int wall;
uniform sampler2D texture_world;
uniform sampler2D texture_material;
uniform vec2 texel_size; // x: time_step * texel_size.x, y: time_step * texel_size.y, z: texel_size.x, w: texel_size.y.
uniform vec4 precalculated; // x: time_step * texel_size.x, y: time_step * texel_size.y, z: texel_size.x, w: texel_size.y.
uniform vec3 precalculated_1; // x: velocity_dissipation_type, y: velocity_dissipation_value, z: velocity_maccormack_weight * 0.5.
uniform vec4 acceleration;
@ -52,7 +55,14 @@ void main() {
velocity += acceleration.xy * (acceleration.z * amount * amount + acceleration.w * amount) + world.xy * float(USE_ACCELERATION_FIELD);
}
if (world.z != 0.0) velocity = vec2(0.0, 0.0);
if(world.z != 0.0) {
velocity = vec2(0.0, 0.0);
}
if(wall == 1) {
if(v_vTexcoord.x < texel_size.x || v_vTexcoord.y < texel_size.x || v_vTexcoord.x > 1. - texel_size.y || v_vTexcoord.y > 1. - texel_size.y)
velocity = vec2(0.0, 0.0);
}
gl_FragColor = vec4(clampForce(velocity), 0., 0.);
}

View file

@ -1,7 +1,7 @@
{
"$GMShader":"",
"%Name":"sh_fd_visualize_colorize_glsl",
"name":"sh_fd_visualize_colorize_glsl",
"%Name":"sh_fd_advect_velocity",
"name":"sh_fd_advect_velocity",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",

View file

@ -1,20 +0,0 @@
varying vec2 v_vTexcoord;
uniform vec2 texel_size;
uniform float max_force;
float clampForce(float v) { return clamp(v, -max_force, max_force); }
vec2 clampForce(vec2 v) { return vec2(clampForce(v.x), clampForce(v.y)); }
void main() {
gl_FragColor.zw = texture2D(gm_BaseTexture, v_vTexcoord).zw;
float divergence = gl_FragColor.y;
float right = texture2D(gm_BaseTexture, v_vTexcoord + vec2(texel_size.x, 0.0)).x;
float left = texture2D(gm_BaseTexture, v_vTexcoord - vec2(texel_size.x, 0.0)).x;
float bottom = texture2D(gm_BaseTexture, v_vTexcoord + vec2(0.0, texel_size.y)).x;
float top = texture2D(gm_BaseTexture, v_vTexcoord - vec2(0.0, texel_size.y)).x;
gl_FragColor.x = clamp((left + right + top + bottom - divergence) * 0.25, 0., 1.);
}

View file

@ -1 +0,0 @@
// Date: 2024-10-15T09:38:04.7468164+07:00

View file

@ -1 +0,0 @@
// Date: 2024-10-15T09:38:04.7469887+07:00

View file

@ -1,12 +0,0 @@
{
"$GMShader":"",
"%Name":"sh_fd_calculate_pressure_jacobi_glsl",
"name":"sh_fd_calculate_pressure_jacobi_glsl",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -1,12 +0,0 @@
{
"$GMShader":"",
"%Name":"sh_fd_calculate_pressure_srj_glsl",
"name":"sh_fd_calculate_pressure_srj_glsl",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -1,12 +0,0 @@
{
"$GMShader":"",
"%Name":"sh_fd_calculate_velocity_divergence_glsl",
"name":"sh_fd_calculate_velocity_divergence_glsl",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -3,6 +3,8 @@ varying vec2 v_vTexcoord;
uniform vec2 texel_size;
uniform vec2 precalculated; //x: 1.0 - relaxation_parameter, y: 0.25 * relaxation_parameter.
uniform int repeat;
uniform int wall;
uniform float max_force;
float clampForce(float v) { return clamp(v, -max_force, max_force); }

View file

@ -0,0 +1,12 @@
{
"$GMShader":"",
"%Name":"sh_fd_pressure_srj",
"name":"sh_fd_pressure_srj",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -1,11 +0,0 @@
varying vec2 v_vTexcoord;
varying vec2 v_vScreencoord;
varying vec4 color;
uniform sampler2D texture_material_0;
void main() {
vec4 destination = texture2D(texture_material_0, v_vScreencoord);
vec4 source = color * texture2D(gm_BaseTexture, v_vTexcoord);
gl_FragColor = source * vec4(source.aaa, 1.0) + destination * (1.0 - source.aaaa);
}

View file

@ -1 +0,0 @@
// Date: 2024-10-15T09:38:04.7486413+07:00

View file

@ -1,16 +0,0 @@
attribute vec4 in_Position;
attribute vec2 in_TextureCoord;
attribute vec4 in_Colour;
varying vec2 v_vTexcoord;
varying vec2 v_vScreencoord;
varying vec4 color;
uniform vec2 addend;
void main() {
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * in_Position;
v_vTexcoord = in_TextureCoord;
v_vScreencoord = gl_Position.xy * vec2(0.5, -0.5) + addend;
color = in_Colour;
}

View file

@ -1 +0,0 @@
// Date: 2024-10-15T09:38:04.7488272+07:00

View file

@ -1,12 +0,0 @@
{
"$GMShader":"",
"%Name":"sh_fd_replace_material_advanced_glsl",
"name":"sh_fd_replace_material_advanced_glsl",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -1,25 +1,26 @@
//
// Simple passthrough fragment shader
//
#define TAU 6.283185307179586
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
#define PI 3.14159265359
uniform float strength;
uniform vec2 center;
uniform float radius;
uniform float spokes;
uniform float rotate;
void main() {
float inCircle = length(v_vTexcoord - vec2(0.5));
vec2 pos = v_vTexcoord - center;
float rad = length(pos);
float dist = rad * strength;
float drad = smoothstep(radius * strength, 0., dist);
if(inCircle > 0.5) {
gl_FragColor = vec4(128. / 255., 128. / 255., 0., 0.);
return;
float angle = atan(pos.y, pos.x);
if(spokes != 0.) {
float sp = TAU / spokes;
angle = floor(angle / sp) * sp + sp * .5 + rotate;
}
vec2 pos = vec2(0.5) - v_vTexcoord;
float rad = inCircle * 2.;
float angle = atan(pos.y, pos.x);
float dist = (1. - rad) * strength;
gl_FragColor = vec4(128. / 255. + cos(angle) * 0.125 * dist, 128. / 255. + sin(angle) * 0.125 * dist, 0., 1.);
gl_FragColor = vec4(cos(angle) * dist * drad, sin(angle) * dist * drad, 0., 1.);
}

View file

@ -4,6 +4,8 @@ uniform sampler2D texture_pressure;
uniform vec2 texel_size;
uniform float max_force;
uniform int repeat;
uniform int wall;
float clampForce(float v) { return clamp(v, -max_force, max_force); }
vec2 clampForce(vec2 v) { return vec2(clampForce(v.x), clampForce(v.y)); }

View file

@ -1,7 +1,7 @@
{
"$GMShader":"",
"%Name":"sh_fd_advect_material_a_16_glsl",
"name":"sh_fd_advect_material_a_16_glsl",
"%Name":"sh_fd_subtract_pressure_gradient",
"name":"sh_fd_subtract_pressure_gradient",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",

View file

@ -1,12 +0,0 @@
{
"$GMShader":"",
"%Name":"sh_fd_subtract_pressure_gradient_glsl",
"name":"sh_fd_subtract_pressure_gradient_glsl",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -1,18 +1,13 @@
//
// Simple passthrough fragment shader
//
#define PI 3.14159265359
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
#define PI 3.14159265359
uniform float scale;
uniform float strength;
uniform float seed;
float random (in vec2 st, float _seed) {
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * (43758.5453123 + (seed + _seed)));
}
float random (in vec2 st, float _seed) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * (43758.5453123 + (seed + _seed))); }
float noise (in vec2 st, float _seed) {
vec2 i = floor(st);
@ -35,5 +30,5 @@ void main() {
float sX = noise(v_vTexcoord * scale, 1.986458) * 2. - 1.;
float sY = noise(v_vTexcoord * scale, 5.648630) * 2. - 1.;
gl_FragColor = vec4(128. / 255. + sX * 0.125 * strength, 128. / 255. + sY * 0.125 * strength, 0., 1.);
gl_FragColor = vec4(sX * strength, sY * strength, 0., 1.);
}

View file

@ -3,7 +3,9 @@ varying vec2 v_vTexcoord;
uniform float initial_value_pressure;
uniform float max_force;
uniform vec2 texel_size;
uniform int repeat;
uniform int wall;
uniform vec2 texel_size;
float clampForce(float v) { return clamp(v, -max_force, max_force); }
vec2 clampForce(vec2 v) { return vec2(clampForce(v.x), clampForce(v.y)); }

View file

@ -0,0 +1,12 @@
{
"$GMShader":"",
"%Name":"sh_fd_velocity_divergence",
"name":"sh_fd_velocity_divergence",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}

View file

@ -2,6 +2,6 @@ varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
float a = texture2D(gm_BaseTexture, v_vTexcoord).w;
float a = texture2D(gm_BaseTexture, v_vTexcoord).a;
gl_FragColor = vec4(vec3(1.), a);
}

View file

@ -1,7 +1,7 @@
{
"$GMShader":"",
"%Name":"sh_fluid_bleach",
"name":"sh_fluid_bleach",
"%Name":"sh_fd_visualize",
"name":"sh_fd_visualize",
"parent":{
"name":"Shaders",
"path":"folders/nodes/data/simulation/smokeSim/Shaders.yy",

View file

@ -1,26 +1,20 @@
//
// Simple passthrough fragment shader
//
#define PI 3.14159265359
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
#define PI 3.14159265359
uniform float vortex;
uniform float angleIO;
void main() {
float inCircle = length(v_vTexcoord - vec2(0.5));
if(inCircle > 0.5) {
gl_FragColor = vec4(128. / 255., 128. / 255., 0., 0.);
return;
}
if(inCircle > 0.5) { gl_FragColor = vec4(0.); return; }
vec2 pos = v_vTexcoord - vec2(0.5);
float rad = inCircle * 2.;
vec2 pos = v_vTexcoord - vec2(0.5);
float rad = inCircle * 2.;
float angle = atan(pos.y, pos.x) + (PI / 2. + angleIO * PI / 2.);
float dist = (1. - rad) * vortex;
gl_FragColor = vec4(128. / 255. + cos(angle) * 0.125 * dist, 128. / 255. + sin(angle) * 0.125 * dist, 0., 1.);
gl_FragColor = vec4(cos(angle) * dist, sin(angle) * dist, 0., 1.);
}

View file

@ -1,10 +0,0 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
vec4 samp = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(vec3(1.), samp.a);
}

View file

@ -1 +0,0 @@
// Date: 2024-10-15T09:38:04.7633776+07:00

View file

@ -1,19 +0,0 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -1 +0,0 @@
// Date: 2024-10-15T09:38:04.7635569+07:00