More tooltips for 3D SDF nodes (#151)

This commit is contained in:
RodZill4 2020-10-09 21:37:42 +02:00
parent 8f2e6197c1
commit a2c97ccf62
8 changed files with 86 additions and 20 deletions

View File

@ -12,32 +12,42 @@
"global": "",
"inputs": [
{
"default": "0.0",
"default": "vec2(100.0, 0.0)",
"function": true,
"label": "",
"longdesc": "The input object, described as 3D signed distance function with color index",
"name": "sdf",
"shortdesc": "Input",
"type": "sdf3dc"
}
],
"instance": "vec2 raymarch_$name(vec2 uv) {\n\tvec3 ro = vec3(uv-vec2(0.5), 1.0);\n\tvec3 rd = vec3(0.0, 0.0, -1.0);\n\tfloat dO = 0.0;\n\tfloat c = 0.0;\n for (int i=0; i < 100; i++) {\n \tvec3 p = ro + rd*dO;\n vec2 dS = $sdf(p);\n dO += dS.x;\n\n if (dO >= 1.0) {\n\t\t\tbreak;\n\t\t} else if (dS.x < 0.0001) {\n\t\t\tc = dS.y;\n\t\t\tbreak;\n\t\t}\n }\n \n return vec2(dO, c);\n}\n\nvec3 normal_$name(vec3 p) {\n\tif (p.z <= 0.0) {\n\t\treturn vec3(0.0, 0.0, 1.0);\n\t}\n\n\tfloat d = $sdf(p).x;\n float e = .001;\n \n vec3 n = d - vec3(\n $sdf(p-vec3(e, 0.0, 0.0)).x,\n $sdf(p-vec3(0.0, e, 0.0)).x,\n $sdf(p-vec3(0.0, 0.0, e)).x);\n \n return vec3(-1.0, -1.0, -1.0)*normalize(n);\n}\n\n",
"name": "Raymarching",
"longdesc": "A node that raymarches a 3D object (described as signed distance function with optional color index) to render a heightmap, a normal map and a color index map.",
"name": "Render",
"outputs": [
{
"f": "1.0-$(name_uv)_d.x",
"longdesc": "The generated height map",
"shortdesc": "HeightMap",
"type": "f"
},
{
"longdesc": "The generated normal map",
"rgb": "vec3(0.5)+0.5*normal_$name(vec3($uv-vec2(0.5), 1.0-$(name_uv)_d.x))",
"shortdesc": "NormalMap",
"type": "rgb"
},
{
"f": "$(name_uv)_d.y",
"longdesc": "The generated color indes map",
"shortdesc": "ColorMap",
"type": "f"
}
],
"parameters": [
]
],
"shortdesc": "Render"
},
"type": "shader"
}

View File

@ -5,7 +5,7 @@
"y": 0
},
"parameters": {
"r": 0.05,
"r": 0.01,
"sx": 0.3,
"sy": 0.25,
"sz": 0.25
@ -17,10 +17,13 @@
],
"instance": "",
"longdesc": "A node that generates a rounded box as a signed distance function",
"name": "Box",
"outputs": [
{
"longdesc": "Shows the rounded box",
"sdf3d": "length(max($(name_uv)_q,0.0))+min(max($(name_uv)_q.x,max($(name_uv)_q.y,$(name_uv)_q.z)),0.0)-$r",
"shortdesc": "Output",
"type": "sdf3d"
}
],
@ -29,9 +32,11 @@
"control": "Rect1.x",
"default": 0.5,
"label": "Size X",
"longdesc": "The size of the box along the X axis",
"max": 1,
"min": 0,
"name": "sx",
"shortdesc": "Size.x",
"step": 0.01,
"type": "float"
},
@ -39,9 +44,11 @@
"control": "Rect1.y",
"default": 0.5,
"label": "Size Y",
"longdesc": "The size of the box along the Y axis",
"max": 1,
"min": 0,
"name": "sy",
"shortdesc": "Size.y",
"step": 0.01,
"type": "float"
},
@ -49,9 +56,11 @@
"control": "None",
"default": 0.5,
"label": "Size Z",
"longdesc": "The size of the box along the Z axis",
"max": 1,
"min": 0,
"name": "sz",
"shortdesc": "Size.z",
"step": 0.01,
"type": "float"
},
@ -59,13 +68,16 @@
"control": "None",
"default": 0.5,
"label": "Radius",
"longdesc": "The radius of the rounded box",
"max": 1,
"min": 0,
"name": "r",
"shortdesc": "Radius",
"step": 0.01,
"type": "float"
}
]
],
"shortdesc": "Box"
},
"type": "shader"
}

View File

@ -16,10 +16,13 @@
],
"instance": "",
"longdesc": "A node that generates a capsule as a signed distance functioni",
"name": "Capsule",
"outputs": [
{
"longdesc": "Shows the capsule",
"sdf3d": "length($(name_uv)_p)-$r",
"shortdesc": "Output",
"type": "sdf3d"
}
],
@ -27,7 +30,9 @@
{
"default": 1,
"label": "Axis",
"longdesc": "The axis of the capsule",
"name": "axis",
"shortdesc": "Axis",
"type": "enum",
"values": [
{
@ -48,9 +53,11 @@
"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"
},
@ -58,13 +65,16 @@
"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"
}

View File

@ -5,15 +5,7 @@
"y": 0
},
"parameters": {
"bevel": 0,
"c": 0.5,
"cx": 0,
"cy": 0,
"h": 0.08,
"k": 0.15,
"op": 0,
"r": 0.15,
"w": 0.28
"c": 0.5
},
"shader_model": {
"code": "",
@ -22,15 +14,20 @@
{
"default": "0.0",
"label": "",
"longdesc": "The input 3D object",
"name": "in",
"shortdesc": "Input",
"type": "sdf3d"
}
],
"instance": "",
"longdesc": "A node that assigns a color index to a 3D object",
"name": "Color",
"outputs": [
{
"longdesc": "The colored 3D object",
"sdf3dc": "vec2($in($uv), $c)",
"shortdesc": "Output",
"type": "sdf3dc"
}
],
@ -39,13 +36,16 @@
"control": "None",
"default": 0,
"label": "",
"longdesc": "The color index to be assigned",
"max": 1,
"min": 0,
"name": "c",
"shortdesc": "Color",
"step": 0.01,
"type": "float"
}
]
],
"shortdesc": "Color"
},
"type": "shader"
}

View File

@ -16,10 +16,13 @@
],
"instance": "",
"longdesc": "A node that generates a cylinder as a signed distance function",
"name": "Cylinder",
"outputs": [
{
"longdesc": "Shows the cylinder",
"sdf3d": "min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0) + length(max($(name_uv)_d,0.0))",
"shortdesc": "Output",
"type": "sdf3d"
}
],
@ -27,7 +30,9 @@
{
"default": 1,
"label": "Axis",
"longdesc": "The axis of the cylinder",
"name": "axis",
"shortdesc": "Axis",
"type": "enum",
"values": [
{
@ -48,9 +53,11 @@
"control": "Rect1.y",
"default": 0.5,
"label": "Length",
"longdesc": "The length of the cylinder",
"max": 1,
"min": 0,
"name": "l",
"shortdesc": "Length",
"step": 0.01,
"type": "float"
},
@ -58,13 +65,16 @@
"control": "Rect1.x",
"default": 0.2,
"label": "Radius",
"longdesc": "The radius of the cylinder",
"max": 1,
"min": 0,
"name": "r",
"shortdesc": "Radius",
"step": 0.01,
"type": "float"
}
]
],
"shortdesc": "Cylinder"
},
"type": "shader"
}

View File

@ -14,10 +14,13 @@
],
"instance": "",
"longdesc": "A node that generates a sphere as a signed distance function",
"name": "Sphere",
"outputs": [
{
"longdesc": "Shows the sphere",
"sdf3d": "length($uv)-$r",
"shortdesc": "Output",
"type": "sdf3d"
}
],
@ -26,13 +29,16 @@
"control": "Radius1.r",
"default": 0.5,
"label": "",
"longdesc": "The radius of the sphere",
"max": 1,
"min": 0,
"name": "r",
"shortdesc": "Radius",
"step": 0.01,
"type": "float"
}
]
],
"shortdesc": "Sphere"
},
"type": "shader"
}

View File

@ -16,10 +16,13 @@
],
"instance": "",
"longdesc": "A node that generates a torus as a signed distance function",
"name": "Torus",
"outputs": [
{
"longdesc": "Shows the torus",
"sdf3d": "length($(name_uv)_q)-$r",
"shortdesc": "Output",
"type": "sdf3d"
}
],
@ -27,7 +30,9 @@
{
"default": 0,
"label": "Axis",
"longdesc": "The axis of the torus",
"name": "axis",
"shortdesc": "Torus",
"type": "enum",
"values": [
{
@ -48,9 +53,11 @@
"control": "Radius1.r",
"default": 0.5,
"label": "R",
"longdesc": "The major radius of the torus",
"max": 1,
"min": 0,
"name": "R",
"shortdesc": "Radius1",
"step": 0.01,
"type": "float"
},
@ -58,13 +65,16 @@
"control": "Radius11.r",
"default": 0.1,
"label": "r",
"longdesc": "The minor radius of the torus",
"max": 0.5,
"min": 0,
"name": "r",
"shortdesc": "Radius2",
"step": 0.01,
"type": "float"
}
]
],
"shortdesc": "Torus"
},
"type": "shader"
}

View File

@ -14,27 +14,35 @@
{
"default": "vec3(1.0)",
"label": "Texture",
"longdesc": "The input 3D texture",
"name": "t",
"shortdesc": "Texture",
"type": "tex3d"
},
{
"default": "vec3(0.0)",
"label": "Inv. UV Map",
"longdesc": "The inverse UV map of the object",
"name": "map",
"shortdesc": "InvUVMap",
"type": "rgb"
}
],
"instance": "",
"longdesc": "This node applies a 3D texture to an object using its inverse UV map.",
"name": "TEX3D Apply",
"outputs": [
{
"longdesc": "The generated texture",
"rgb": "$t(vec4($map($uv), 0.0))",
"shortdesc": "Output",
"type": "rgb"
}
],
"parameters": [
]
],
"shortdesc": "TEX3D Apply"
},
"type": "shader"
}