mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Comments from sdf3d_boolean.mmg.
This commit is contained in:
parent
d75ee3dac2
commit
4ee9c69d15
@ -142,7 +142,7 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
#X: $axis = length($uv.yz)-$R,$uv.x
|
||||
#Y: $axis = length($uv.zx)-$R,$uv.y
|
||||
#Z: $axis = length($uv.xy)-$R,$uv.z
|
||||
#vec2 $(name_uv)_q = vec2($axis);\n
|
||||
#vec2 $(name_uv)_q = vec2($axis);
|
||||
|
||||
#Output (sdf3dc) - Shows the torus
|
||||
#length($(name_uv)_q)-$r
|
||||
@ -152,6 +152,23 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
#R, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
#r, float, min: 0, max: 1, default:0.1, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_boolean.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Union: $op = sdf3dc_union
|
||||
#Subtraction $op = sdf3dc_sub
|
||||
#Intersection $op = sdf3dc_inter
|
||||
|
||||
#Output (sdf3dc) - The shape generated by the boolean operation
|
||||
#$op($in1($uv), $in2($uv))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 2, values: Union, Subtraction, Intersection
|
||||
#in1, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#in2, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
|
||||
|
||||
static func raymarch(uv : Vector2) -> Color:
|
||||
var d : Vector2 = sdf3d_raymarch(uv);
|
||||
@ -343,12 +360,24 @@ static func sdf3d_normal(p : Vector3) -> Vector3:
|
||||
|
||||
return Vector3(-1.0, -1.0, -1.0) * n.normalized();
|
||||
|
||||
#vec2 sdf3dc_union(vec2 a, vec2 b) {
|
||||
# return vec2(min(a.x, b.x), mix(b.y, a.y, step(a.x, b.x)));
|
||||
#}
|
||||
|
||||
static func sdf3dc_union(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(min(a.x, b.x), lerp(b.y, a.y, Commons.step(a.x, b.x)));
|
||||
|
||||
#vec2 sdf3dc_sub(vec2 a, vec2 b) {
|
||||
# return vec2(max(-a.x, b.x), a.y);
|
||||
#}
|
||||
|
||||
static func sdf3dc_sub(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(max(-a.x, b.x), a.y);
|
||||
|
||||
#vec2 sdf3dc_inter(vec2 a, vec2 b) {
|
||||
# return vec2(max(a.x, b.x), mix(a.y, b.y, step(a.x, b.x)));
|
||||
#}
|
||||
|
||||
static func sdf3dc_inter(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(max(a.x, b.x), lerp(a.y, b.y, Commons.step(a.x, b.x)));
|
||||
|
||||
|
@ -1,70 +0,0 @@
|
||||
{
|
||||
"name": "sdf3d_boolean",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"op": 0
|
||||
},
|
||||
"seed_value": 60292,
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "vec2 sdf3dc_union(vec2 a, vec2 b) {\n\treturn vec2(min(a.x, b.x), mix(b.y, a.y, step(a.x, b.x)));\n}\nvec2 sdf3dc_sub(vec2 a, vec2 b) {\n\treturn vec2(max(-a.x, b.x), a.y);\n}\nvec2 sdf3dc_inter(vec2 a, vec2 b) {\n\treturn vec2(max(a.x, b.x), mix(a.y, b.y, step(a.x, b.x)));\n}\n",
|
||||
"inputs": [
|
||||
{
|
||||
"default": "vec2(100.0, 0.0)",
|
||||
"label": "",
|
||||
"longdesc": "The first shape, defined as a signed distance function",
|
||||
"name": "in1",
|
||||
"shortdesc": "Input1",
|
||||
"type": "sdf3dc"
|
||||
},
|
||||
{
|
||||
"default": "vec2(100.0, 0.0)",
|
||||
"label": "",
|
||||
"longdesc": "The second shape, defined as a signed distance function",
|
||||
"name": "in2",
|
||||
"shortdesc": "Input2",
|
||||
"type": "sdf3dc"
|
||||
}
|
||||
],
|
||||
"instance": "",
|
||||
"longdesc": "Performs a boolean operation (union, intersection or difference) between two shapes",
|
||||
"name": "Boolean",
|
||||
"outputs": [
|
||||
{
|
||||
"longdesc": "The shape generated by the boolean operation",
|
||||
"sdf3dc": "$op($in1($uv), $in2($uv))",
|
||||
"shortdesc": "Output",
|
||||
"type": "sdf3dc"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 2,
|
||||
"label": "",
|
||||
"longdesc": "The operation performed by this node",
|
||||
"name": "op",
|
||||
"shortdesc": "Operation",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
{
|
||||
"name": "Union",
|
||||
"value": "sdf3dc_union"
|
||||
},
|
||||
{
|
||||
"name": "Subtraction",
|
||||
"value": "sdf3dc_sub"
|
||||
},
|
||||
{
|
||||
"name": "Intersection",
|
||||
"value": "sdf3dc_inter"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"shortdesc": "Boolean"
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
Loading…
Reference in New Issue
Block a user