material-maker/addons/material_maker/nodes/box.mmg

146 lines
3.3 KiB
Plaintext

{
"name": "box",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"cx": 0.5,
"cy": 0.5,
"cz": 0.5,
"rx": 0,
"ry": 0,
"rz": 0,
"sx": 0.25,
"sy": 0.25,
"sz": 0.25
},
"shader_model": {
"code": "",
"global": "float box(vec2 uv, vec3 center, vec3 rad, vec3 rot) {\n\tvec3 ro = vec3(uv, 1.0)-center;\n\tvec3 rd = vec3(0.0000001, 0.0000001, -1.0);\n\tmat3 r = mat3(vec3(1, 0, 0), vec3(0, cos(rot.x), -sin(rot.x)), vec3(0, sin(rot.x), cos(rot.x)));\n\tr *= mat3(vec3(cos(rot.y), 0, -sin(rot.y)), vec3(0, 1, 0), vec3(sin(rot.y), 0, cos(rot.y)));\n\tr *= mat3(vec3(cos(rot.z), -sin(rot.z), 0), vec3(sin(rot.z), cos(rot.z), 0), vec3(0, 0, 1));\n\tro = r * ro;\n\trd = r * rd;\n vec3 m = 1.0/rd;\n vec3 n = m*ro;\n vec3 k = abs(m)*rad;\n vec3 t1 = -n - k;\n vec3 t2 = -n + k;\n\n float tN = max(max(t1.x, t1.y), t1.z);\n float tF = min(min(t2.x, t2.y), t2.z);\n if(tN>tF || tF<0.0) return 1.0;\n return tN;\n}",
"inputs": [
],
"instance": "",
"name": "Box",
"outputs": [
{
"f": "1.0-box($uv, vec3($cx, $cy, $cz), vec3($sx, $sy, $sz), 0.01745329251*vec3($rx, $ry, $rz))",
"longdesc": "A heightmap of the specified box",
"shortdesc": "Output",
"type": "f"
}
],
"parameters": [
{
"control": "None",
"default": 0.5,
"label": "Center X",
"longdesc": "X coordinate of the center of the box",
"max": 1,
"min": 0,
"name": "cx",
"shortdesc": "Center.x",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 0.5,
"label": "Center Y",
"longdesc": "Y coordinate of the center of the box",
"max": 1,
"min": 0,
"name": "cy",
"shortdesc": "Center.y",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 0,
"label": "Center Z",
"longdesc": "Z coordinate of the center of the box",
"max": 0.5,
"min": -0.5,
"name": "cz",
"shortdesc": "Center.z",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 0.5,
"label": "Size X",
"longdesc": "Size along X axis",
"max": 1,
"min": 0,
"name": "sx",
"shortdesc": "Size.x",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 0.5,
"label": "Size Y",
"longdesc": "Size along Y axis",
"max": 1,
"min": 0,
"name": "sy",
"shortdesc": "Size.y",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 0.5,
"label": "Size Z",
"longdesc": "Size along Z axis",
"max": 1,
"min": 0,
"name": "sz",
"shortdesc": "Size.z",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 0,
"label": "Rot X",
"longdesc": "Rotation angle around X axis",
"max": 180,
"min": -180,
"name": "rx",
"shortdesc": "Rot.x",
"step": 0.1,
"type": "float"
},
{
"control": "None",
"default": 0,
"label": "Rot Y",
"longdesc": "Rotation angle around Y axis",
"max": 180,
"min": -180,
"name": "ry",
"shortdesc": "Rot.y",
"step": 0.1,
"type": "float"
},
{
"control": "None",
"default": 0,
"label": "Rot Z",
"longdesc": "Rotation angle around Y axis",
"max": 180,
"min": -180,
"name": "rz",
"shortdesc": "Rot.z",
"step": 0.1,
"type": "float"
}
]
},
"type": "shader"
}