- [Particle] Fix error when connecting empty array as input.

This commit is contained in:
Tanasart 2024-06-01 12:35:08 +07:00
parent 39d2d4ce59
commit ae76739bba
14 changed files with 132 additions and 25 deletions

View file

@ -1910,6 +1910,7 @@
{"name":"s_node_rigidSim_renderer","order":1,"path":"sprites/s_node_rigidSim_renderer/s_node_rigidSim_renderer.yy",},
{"name":"s_node_rigidSim_wall","order":11,"path":"sprites/s_node_rigidSim_wall/s_node_rigidSim_wall.yy",},
{"name":"s_node_rm_primitive","order":51,"path":"sprites/s_node_rm_primitive/s_node_rm_primitive.yy",},
{"name":"s_node_rm_terrain","order":52,"path":"sprites/s_node_rm_terrain/s_node_rm_terrain.yy",},
{"name":"s_node_sampler","order":19,"path":"sprites/s_node_sampler/s_node_sampler.yy",},
{"name":"s_node_scale_algo","order":7,"path":"sprites/s_node_scale_algo/s_node_scale_algo.yy",},
{"name":"s_node_scale","order":6,"path":"sprites/s_node_scale/s_node_scale.yy",},

View file

@ -2484,6 +2484,7 @@
{"id":{"name":"s_node_rigidSim_wall","path":"sprites/s_node_rigidSim_wall/s_node_rigidSim_wall.yy",},},
{"id":{"name":"s_node_rigidSim","path":"sprites/s_node_rigidSim/s_node_rigidSim.yy",},},
{"id":{"name":"s_node_rm_primitive","path":"sprites/s_node_rm_primitive/s_node_rm_primitive.yy",},},
{"id":{"name":"s_node_rm_terrain","path":"sprites/s_node_rm_terrain/s_node_rm_terrain.yy",},},
{"id":{"name":"s_node_sampler","path":"sprites/s_node_sampler/s_node_sampler.yy",},},
{"id":{"name":"s_node_scale_algo","path":"sprites/s_node_scale_algo/s_node_scale_algo.yy",},},
{"id":{"name":"s_node_scale","path":"sprites/s_node_scale/s_node_scale.yy",},},

View file

@ -232,6 +232,8 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
var _posDist = [];
if(array_empty(_inSurf)) return;
random_set_seed(seed); seed++;
var _amo = irandom_range(_spawn_amount[0], _spawn_amount[1]);
if(_distrib == 2) _posDist = get_points_from_dist(_dist_map, _amo, seed);
@ -335,8 +337,8 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
static getSurfaceCache = function() { #region
var surfs = getInputData(0);
if(!is_array(surfs)) surfs = [ surfs ];
if(array_empty(surfs)) return;
if(!is_array(surfs)) surfs = [ surfs ];
for( var i = 0, n = array_length(surfs); i < n; i++ ) {
var _s = surfs[i];
@ -496,7 +498,10 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
var _spr = getInputData(0);
if(is_array(_spr)) _spr = _spr[0];
if(array_empty(_spr)) return;
if(is_array(_spr))
_spr = _spr[0];
var _flag = is_instanceof(_spr, SurfaceAtlas)? 0b0001 : 0b0011;
inputs[| 3].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, _flag);

View file

@ -753,7 +753,7 @@ function __initNodes() {
ds_list_add(generator, "Ray Marching");
addNodeObject(generator, "RM Primitive", s_node_rm_primitive, "Node_RM_Primitive", [1, Node_RM_Primitive], ["ray marching"]).setVersion(11720);
addNodeObject(generator, "RM Terrain", s_node_rm_primitive, "Node_RM_Terrain", [1, Node_RM_Terrain], ["ray marching"]).setVersion(11720);
addNodeObject(generator, "RM Terrain", s_node_rm_terrain, "Node_RM_Terrain", [1, Node_RM_Terrain], ["ray marching"]).setVersion(11720);
ds_list_add(generator, "MK Effects");
addNodeObject(generator, "MK Rain", s_node_mk_rain, "Node_MK_Rain", [1, Node_MK_Rain]).setVersion(11600);

View file

@ -23,7 +23,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
shape_types_str[i] = new scrollItem(shape_types[i], s_node_shape_3d, _ind++, COLORS._main_icon_light);
}
inputs[| 1] = nodeValue("Shape", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
inputs[| 1] = nodeValue("Shape", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
.setDisplay(VALUE_DISPLAY.enum_scroll, shape_types_str);
inputs[| 2] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
@ -41,7 +41,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
inputs[| 6] = nodeValue("View Range", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 3, 6 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 7] = nodeValue("Depth", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
inputs[| 7] = nodeValue("Depth", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider);
inputs[| 8] = nodeValue("Light Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ -.5, -.5, 1 ])
@ -113,6 +113,10 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
inputs[| 29] = nodeValue("Tile Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 30] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
inputs[| 31] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
outputs[| 0] = nodeValue("Surface Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ 0,
@ -121,7 +125,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
["Deform", true], 15, 16, 17, 18, 19,
["Transform", false], 2, 3, 4,
["Camera", false], 13, 14, 5, 6,
["Render", false], 7, 9, 10, 8,
["Render", false], 31, 30, 7, 9, 10, 8,
["Tile", false], 20, 29,
];
@ -257,6 +261,8 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
var _radR = _data[27];
var _sizz = _data[28];
var _tilA = _data[29];
var _bgc = _data[30];
var _bgd = _data[31];
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
@ -265,7 +271,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
var tx = 1024;
surface_set_shader(temp_surface[0]);
draw_surface_stretched_safe(_extr, tx * 0, tx * 0, tx, tx);
surface_reset_shader();
gpu_set_texfilter(true);
@ -334,9 +340,11 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
shader_set_f("tileSize", _tile);
shader_set_f("tileAmount", _tilA);
shader_set_color("ambient", _amb);
shader_set_f("ambientIntns", _ambI);
shader_set_f("lightPosition", _lPos);
shader_set_i("drawBg", _bgd);
shader_set_color("background", _bgc);
shader_set_color("ambient", _amb);
shader_set_f("ambientIntns", _ambI);
shader_set_f("lightPosition", _lPos);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
surface_reset_shader();

View file

@ -51,6 +51,8 @@ uniform float depthInt;
uniform vec3 tileSize;
uniform vec3 tileAmount;
uniform int drawBg;
uniform vec4 background;
uniform vec4 ambient;
uniform float ambientIntns;
uniform vec3 lightPosition;
@ -384,7 +386,7 @@ float sceneSDF(vec3 p) {
p = el.xyz;
}
if(shape == 100) d = sdPlane(p, vec3(0., 0., 1.), 0.);
if(shape == 100) d = sdPlane(p, vec3(0., -1., 0.), 0.);
else if(shape == 101) d = sdBox(p, size / 2.);
else if(shape == 102) d = sdBoxFrame(p, size / 2., thickness);
@ -440,7 +442,7 @@ float march(vec3 camera, vec3 direction) {
}
void main() {
gl_FragColor = vec4(0., 0., 0., 1.);
gl_FragColor = drawBg == 1? background : vec4(0.);
mat3 rx = rotateX(rotation.x);
mat3 ry = rotateY(rotation.y);
@ -469,18 +471,18 @@ void main() {
vec3 c = ambient.rgb;
float distNorm = 1. - (dist - viewRange.x) / (viewRange.y - viewRange.x);
distNorm = smoothstep(.0, .3, distNorm) + .2;
c *= mix(vec3(1.), vec3(distNorm), depthInt);
///////////////////////////////////////////////////////////
float distNorm = (dist - viewRange.x) / (viewRange.y - viewRange.x);
distNorm = 1. - distNorm;
distNorm = smoothstep(.0, .3, distNorm);
c = mix(background.rgb, c, mix(1., distNorm, depthInt));
vec3 norm = normal(coll);
vec3 light = normalize(lightPosition);
float lamo = dot(norm, light) + ambientIntns;
c *= lamo;
// if(sin((wcoll.y + time * PI * 2.) * 96.) < -.9)
// c *= 4.;
c = mix(background.rgb, c, lamo);
// c *= lamo;
gl_FragColor = vec4(c, 1.);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -2,24 +2,24 @@
"$GMSprite":"",
"%Name":"s_node_rm_primitive",
"bboxMode":0,
"bbox_bottom":63,
"bbox_bottom":62,
"bbox_left":2,
"bbox_right":60,
"bbox_top":1,
"bbox_top":3,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"1edabec3-254d-42f4-8d2c-52898860ab0c","name":"1edabec3-254d-42f4-8d2c-52898860ab0c","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
{"$GMSpriteFrame":"","%Name":"96237c8e-e704-42b8-af43-7cb2d40b21a8","name":"96237c8e-e704-42b8-af43-7cb2d40b21a8","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"30e25e94-92fd-4e97-87a4-b6fe46ef67a9","blendMode":0,"displayName":"default","isLocked":false,"name":"30e25e94-92fd-4e97-87a4-b6fe46ef67a9","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
{"$GMImageLayer":"","%Name":"ccdc9f3a-1460-4a95-9125-e0cac7676f79","blendMode":0,"displayName":"default","isLocked":false,"name":"ccdc9f3a-1460-4a95-9125-e0cac7676f79","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_rm_primitive",
"nineSlice":null,
@ -69,8 +69,8 @@
"tracks":[
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"1edabec3-254d-42f4-8d2c-52898860ab0c","path":"sprites/s_node_rm_primitive/s_node_rm_primitive.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"22ee247f-a875-4591-afa7-cb8d52f409c7","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"96237c8e-e704-42b8-af43-7cb2d40b21a8","path":"sprites/s_node_rm_primitive/s_node_rm_primitive.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"4a891850-7d27-44e0-81b2-e7192095161f","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange":null,

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -0,0 +1,90 @@
{
"$GMSprite":"",
"%Name":"s_node_rm_terrain",
"bboxMode":0,
"bbox_bottom":61,
"bbox_left":2,
"bbox_right":62,
"bbox_top":3,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"1d619a24-5a8f-49bc-af1f-b8dd8c730cc3","name":"1d619a24-5a8f-49bc-af1f-b8dd8c730cc3","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"73a74463-1f16-42f3-961d-556967f4f8cc","blendMode":0,"displayName":"default","isLocked":false,"name":"73a74463-1f16-42f3-961d-556967f4f8cc","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_rm_terrain",
"nineSlice":null,
"origin":4,
"parent":{
"name":"generator",
"path":"folders/nodes/icons/generator.yy",
},
"preMultiplyAlpha":false,
"resourceType":"GMSprite",
"resourceVersion":"2.0",
"sequence":{
"$GMSequence":"",
"%Name":"s_node_rm_terrain",
"autoRecord":true,
"backdropHeight":768,
"backdropImageOpacity":0.5,
"backdropImagePath":"",
"backdropWidth":1366,
"backdropXOffset":0.0,
"backdropYOffset":0.0,
"events":{
"$KeyframeStore<MessageEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MessageEventKeyframe>",
"resourceVersion":"2.0",
},
"eventStubScript":null,
"eventToFunction":{},
"length":1.0,
"lockOrigin":false,
"moments":{
"$KeyframeStore<MomentsEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
"resourceVersion":"2.0",
},
"name":"s_node_rm_terrain",
"playback":1,
"playbackSpeed":30.0,
"playbackSpeedType":0,
"resourceType":"GMSequence",
"resourceVersion":"2.0",
"showBackdrop":true,
"showBackdropImage":false,
"timeUnits":1,
"tracks":[
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"1d619a24-5a8f-49bc-af1f-b8dd8c730cc3","path":"sprites/s_node_rm_terrain/s_node_rm_terrain.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"f90ac6b1-5887-446e-8ce7-3e2f5f29765d","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange":null,
"volume":1.0,
"xorigin":32,
"yorigin":32,
},
"swatchColours":null,
"swfPrecision":0.5,
"textureGroupId":{
"name":"Default",
"path":"texturegroups/Default",
},
"type":0,
"VTile":false,
"width":64,
}