COmments from sdf3d_rotate.mmg.

This commit is contained in:
Relintai 2021-10-12 11:27:32 +02:00
parent a5b96ad8f1
commit 2eabdc5536
2 changed files with 41 additions and 78 deletions

View File

@ -92,6 +92,20 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
#Y, int, min: 1, max: 32, default:4, step:1
#R, float, min: 0, max: 1, default:0.5, step:0.01
#----------------------
#sdf3d_rotate.mmg
#Outputs:
#Output (sdf3dc) - The rotated object
#$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))
#Inputs:
#in, vec2, default:vec2(100, 0.0), (sdf3d input)
#rotation, vector3, min: -180, max: 180, default:0, step:1
static func raymarch(uv : Vector2) -> Color:
var d : Vector2 = sdf3d_raymarch(uv);
@ -379,7 +393,33 @@ static func repeat(p : Vector3, r : Vector3, pseed : float, randomness : float)
rv.z = p.z;
return rv;
#vec3 rotate3d(vec3 p, vec3 a) {
# vec3 rv;
# float c;
# float s;
# c = cos(a.x);
# s = sin(a.x);
# rv.x = p.x;
# rv.y = p.y*c+p.z*s;
# rv.z = -p.y*s+p.z*c;
# c = cos(a.y);
# s = sin(a.y);
# p.x = rv.x*c+rv.z*s;
# p.y = rv.y;
# p.z = -rv.x*s+rv.z*c;
# c = cos(a.z);
# s = sin(a.z);
# rv.x = p.x*c+p.y*s;
# rv.y = -p.x*s+p.y*c;
# rv.z = p.z;
# return rv;
#}
static func rotate3d(p : Vector3, a : Vector3) -> Vector3:
#todo
return Vector3()
#todo this needs to be solved
static func sdf3d_input(p : Vector3) -> Vector2:
return sdf3d_sphere(p, 0.5)

View File

@ -1,77 +0,0 @@
{
"name": "sdf3d_rotate",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"ax": 0,
"ay": 0,
"az": 0
},
"shader_model": {
"code": "",
"global": "vec3 rotate3d(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n",
"inputs": [
{
"default": "vec2(100.0, 0.0)",
"label": "",
"longdesc": "The input object as signed distance function",
"name": "in",
"shortdesc": "Input",
"type": "sdf3dc"
}
],
"instance": "",
"longdesc": "Rotates its input 3D object described as a signed distance function.",
"name": "Rotate",
"outputs": [
{
"longdesc": "The rotated object",
"sdf3dc": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))",
"shortdesc": "Output",
"type": "sdf3dc"
}
],
"parameters": [
{
"control": "None",
"default": 0,
"label": "X",
"longdesc": "The rotation around the X axis",
"max": 180,
"min": -180,
"name": "ax",
"shortdesc": "Rotate.x",
"step": 1,
"type": "float"
},
{
"control": "None",
"default": 0,
"label": "Y",
"longdesc": "The rotation around the Y axis",
"max": 180,
"min": -180,
"name": "ay",
"shortdesc": "Rotate.y",
"step": 1,
"type": "float"
},
{
"control": "None",
"default": 0,
"label": "Z",
"longdesc": "The rotation around the Z axis",
"max": 180,
"min": -180,
"name": "az",
"shortdesc": "Rotate.z",
"step": 1,
"type": "float"
}
],
"shortdesc": "Rotate"
},
"type": "shader"
}