Comments from sdf3d_capsule.mmg.

This commit is contained in:
Relintai 2021-10-11 14:14:05 +02:00
parent 1a65e35471
commit 8fff2bc0e9
3 changed files with 23 additions and 208 deletions

View File

@ -31,6 +31,25 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
#Inputs: #Inputs:
#radius, vector3, min: 0, max: 1, default:0.5, step:0.01 #radius, vector3, min: 0, max: 1, default:0.5, step:0.01
#----------------------
#sdf3d_capsule.mmg
#Generates a capsule as a signed distance function
#Outputs:
#Common
#vec3 $(name_uv)_p = $uv;
#$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
#Output (sdf3d) - Shows the capsule
#length($(name_uv)_p)-$r*$profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))
#Inputs:
#axis, enum, default: 1, values: x, y, z
#length, float, min: 0, max: 1, default:0.25, step:0.01
#radius, float, min: 0, max: 1, default:0.2, step:0.01
#profile, curve, default: (ls, rs, x, z) 0, 0, 0, 1, 0, 0, 1, 1
static func raymarch(uv : Vector2) -> Color: static func raymarch(uv : Vector2) -> Color:
var d : Vector2 = sdf3d_raymarch(uv); var d : Vector2 = sdf3d_raymarch(uv);
@ -84,6 +103,10 @@ static func sdf3d_cylinder_z(p : Vector3, r : float, l : float) -> Vector2:
return Vector2(f, 0.0); return Vector2(f, 0.0);
#vec3 $(name_uv)_p = $uv;
#$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
#return length($(name_uv)_p)-$r*$profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))
static func sdf3d_capsule_y(p : Vector3, r : float, l : float) -> Vector2: static func sdf3d_capsule_y(p : Vector3, r : float, l : float) -> Vector2:
var v : Vector3 = p; var v : Vector3 = p;
v.y -= clamp(v.y, -l, l); v.y -= clamp(v.y, -l, l);

View File

@ -1,119 +0,0 @@
{
"name": "sdf3d_capsule",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"axis": 1,
"l": 0.3,
"profile": {
"points": [
{
"ls": 0,
"rs": 0,
"x": 0,
"y": 1
},
{
"ls": 0,
"rs": 0,
"x": 1,
"y": 1
}
],
"type": "Curve"
},
"r": 0.2
},
"shader_model": {
"code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);\n",
"global": "",
"inputs": [
],
"instance": "",
"longdesc": "Generates a capsule as a signed distance functioni",
"name": "Capsule",
"outputs": [
{
"longdesc": "Shows the capsule",
"sdf3d": "length($(name_uv)_p)-$r*$profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))",
"shortdesc": "Output",
"type": "sdf3d"
}
],
"parameters": [
{
"default": 1,
"label": "Axis",
"longdesc": "The axis of the capsule",
"name": "axis",
"shortdesc": "Axis",
"type": "enum",
"values": [
{
"name": "X",
"value": "x"
},
{
"name": "Y",
"value": "y"
},
{
"name": "Z",
"value": "z"
}
]
},
{
"control": "Rect1.y",
"default": 0.25,
"label": "Length",
"longdesc": "The length of the capsule",
"max": 1,
"min": 0,
"name": "l",
"shortdesc": "Length",
"step": 0.01,
"type": "float"
},
{
"control": "Rect1.x",
"default": 0.2,
"label": "Radius",
"longdesc": "The radius of the capsule",
"max": 1,
"min": 0,
"name": "r",
"shortdesc": "Radius",
"step": 0.01,
"type": "float"
},
{
"default": {
"points": [
{
"ls": 0,
"rs": 0,
"x": 0,
"y": 1
},
{
"ls": 0,
"rs": 0,
"x": 1,
"y": 1
}
],
"type": "Curve"
},
"label": "Profile",
"name": "profile",
"type": "curve"
}
],
"shortdesc": "capsule"
},
"type": "shader"
}

View File

@ -1,89 +0,0 @@
{
"name": "sdf3d_capsule2",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"axis": 1,
"l": 0.3,
"r": 0.2
},
"seed": 0,
"seed_locked": false,
"shader_model": {
"code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);\n",
"global": "",
"inputs": [
{
"default": "1.0",
"label": "3:",
"longdesc": "An input gradient (generated, for example by a Tonality node) that defines a profile for the shape",
"name": "profile",
"shortdesc": "Profile",
"type": "f"
}
],
"instance": "",
"longdesc": "Generates a capsule as a signed distance functioni",
"name": "Capsule",
"outputs": [
{
"longdesc": "Shows the capsule",
"sdf3d": "length($(name_uv)_p)-$r*$profile(vec2(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0), 0.5))",
"shortdesc": "Output",
"type": "sdf3d"
}
],
"parameters": [
{
"default": 1,
"label": "Axis",
"longdesc": "The axis of the capsule",
"name": "axis",
"shortdesc": "Axis",
"type": "enum",
"values": [
{
"name": "X",
"value": "x"
},
{
"name": "Y",
"value": "y"
},
{
"name": "Z",
"value": "z"
}
]
},
{
"control": "Rect1.y",
"default": 0.25,
"label": "Length",
"longdesc": "The length of the capsule",
"max": 1,
"min": 0,
"name": "l",
"shortdesc": "Length",
"step": 0.01,
"type": "float"
},
{
"control": "Rect1.x",
"default": 0.2,
"label": "Radius",
"longdesc": "The radius of the capsule",
"max": 1,
"min": 0,
"name": "r",
"shortdesc": "Radius",
"step": 0.01,
"type": "float"
}
],
"shortdesc": "capsule"
},
"type": "shader"
}