ray marching primitive

This commit is contained in:
Tanasart 2024-05-28 18:51:21 +07:00
parent 542e9da47d
commit 0e260e2e09
7 changed files with 19 additions and 17 deletions

View file

@ -556,7 +556,7 @@ function __initNodes() {
addNodeObject(filter, "Blend", s_node_blend, "Node_Blend", [0, Node_create_Blend], global.node_blend_keys, "Blend 2 images using different blend modes.");
addNodeObject(filter, "RGBA Combine", s_node_RGB_combine, "Node_Combine_RGB", [1, Node_Combine_RGB],, "Combine 4 image in to one. Each image use to control RGBA channel.").setVersion(1070);
addNodeObject(filter, "HSV Combine", s_node_HSV_combine, "Node_Combine_HSV", [1, Node_Combine_HSV],, "Combine 4 image in to one. Each image use to control HSVA channel.").setVersion(1070);
addNodeObject(filter, "Override Channel", s_node_ovreride_channel, "Node_Override_Channel", [1, Node_Override_Channel],, "Replace RGBA value of one surface with anothers.").setVersion(11640);
addNodeObject(filter, "Override Channel", s_node_ovreride_channel, "Node_Override_Channel", [1, Node_Override_Channel],, "Replace RGBA value of one surface with another.").setVersion(11640);
ds_list_add(filter, "Blurs");
addNodeObject(filter, "Blur", s_node_blur, "Node_Blur", [1, Node_Blur], ["gaussian blur"], "Blur image smoothly.");
@ -722,7 +722,7 @@ function __initNodes() {
ds_list_add(generator, "Patterns");
addNodeObject(generator, "Stripe", s_node_stripe, "Node_Stripe", [1, Node_Stripe],, "Generate stripe pattern.");
addNodeObject(generator, "Zigzag", s_node_zigzag, "Node_Zigzag", [1, Node_Zigzag],, "Generate zigzag pattern.");
addNodeObject(generator, "Checker", s_node_checker, "Node_Checker", [1, Node_Checker],, "Genearte checkerboard pattern.");
addNodeObject(generator, "Checker", s_node_checker, "Node_Checker", [1, Node_Checker],, "Generate checkerboard pattern.");
addNodeObject(generator, "Grid", s_node_grid, "Node_Grid", [1, Node_Grid], ["tile"], "Generate grid pattern.");
addNodeObject(generator, "Triangular Grid", s_node_grid_tri, "Node_Grid_Tri", [1, Node_Grid_Tri],, "Generate triangular grid pattern.");
addNodeObject(generator, "Hexagonal Grid", s_node_grid_hex, "Node_Grid_Hex", [1, Node_Grid_Hex],, "Generate hexagonal grid pattern.");

View file

@ -6,6 +6,7 @@ varying vec4 v_vColour;
const int MAX_MARCHING_STEPS = 255;
const float EPSILON = .0001;
const float PI = 3.14159265358979323846;
uniform int shape;
uniform vec3 size;
@ -274,12 +275,12 @@ uniform vec3 lightPosition;
}
vec3 wave(vec3 p) {
p.x += sin(p.y * waveAmp.y + waveShift.x) * waveInt.x +
sin(p.z * waveAmp.z + waveShift.x) * waveInt.x;
p.y += sin(p.x * waveAmp.x + waveShift.y) * waveInt.y +
sin(p.z * waveAmp.z + waveShift.y) * waveInt.y;
p.z += sin(p.y * waveAmp.y + waveShift.z) * waveInt.z +
sin(p.x * waveAmp.x + waveShift.z) * waveInt.z;
p.x += sin(p.y * waveAmp.y + waveShift.x * PI * 2.) * waveInt.x +
sin(p.z * waveAmp.z + waveShift.x * PI * 2.) * waveInt.x;
p.y += sin(p.x * waveAmp.x + waveShift.y * PI * 2.) * waveInt.y +
sin(p.z * waveAmp.z + waveShift.y * PI * 2.) * waveInt.y;
p.z += sin(p.y * waveAmp.y + waveShift.z * PI * 2.) * waveInt.z +
sin(p.x * waveAmp.x + waveShift.z * PI * 2.) * waveInt.z;
return p;
}
@ -331,11 +332,12 @@ float sceneSDF(vec3 p) {
p /= objectScale;
p -= position;
p = wave(p);
if(tileSize != vec3(0.))
p = tilePosition(p);
p = twist(p);
p = wave(p);
vec4 el = vec4(0.);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -2,24 +2,24 @@
"$GMSprite":"",
"%Name":"s_node_rm_primitive",
"bboxMode":0,
"bbox_bottom":61,
"bbox_left":3,
"bbox_right":61,
"bbox_top":3,
"bbox_bottom":62,
"bbox_left":6,
"bbox_right":62,
"bbox_top":5,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"ce9d62bd-3878-41e3-b28e-0325c98d8a73","name":"ce9d62bd-3878-41e3-b28e-0325c98d8a73","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
{"$GMSpriteFrame":"","%Name":"9fcdf9f9-ba78-46c9-b253-0c8ab869e7fd","name":"9fcdf9f9-ba78-46c9-b253-0c8ab869e7fd","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"e4b2e1fb-aa71-423e-b4ac-9a9e83f702fa","blendMode":0,"displayName":"default","isLocked":false,"name":"e4b2e1fb-aa71-423e-b4ac-9a9e83f702fa","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
{"$GMImageLayer":"","%Name":"eae4b9cd-265e-4fa2-9fa6-1e3d16f2efcf","blendMode":0,"displayName":"default","isLocked":false,"name":"eae4b9cd-265e-4fa2-9fa6-1e3d16f2efcf","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":"ce9d62bd-3878-41e3-b28e-0325c98d8a73","path":"sprites/s_node_rm_primitive/s_node_rm_primitive.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"df2b1365-2924-4580-83f6-e78b42c66e83","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"9fcdf9f9-ba78-46c9-b253-0c8ab869e7fd","path":"sprites/s_node_rm_primitive/s_node_rm_primitive.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"32fef19e-0a12-4c33-a385-a86daf2a08de","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,