Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tex3D node improvements #649

Merged
merged 16 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions addons/material_maker/nodes/sdf3d_color.mmg
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"generic_size": 1,
"name": "sdf3d_color",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"c": 0.5
"c1": 0.5
},
"seed_int": 0,
"shader_model": {
Expand All @@ -16,8 +17,8 @@
"default": "0.0",
"label": "",
"longdesc": "The input 3D object",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf3d"
}
],
Expand All @@ -27,8 +28,8 @@
"outputs": [
{
"longdesc": "The colored 3D object",
"sdf3dc": "vec2($in($uv), $c)",
"shortdesc": "Output",
"sdf3dc": "vec2($in#($uv), $c#)",
"shortdesc": "Output#",
"type": "sdf3dc"
}
],
Expand All @@ -40,7 +41,7 @@
"longdesc": "The color index to be assigned",
"max": 1,
"min": 0,
"name": "c",
"name": "c#",
"shortdesc": "Color",
"step": 0.01,
"type": "float"
Expand Down
39 changes: 25 additions & 14 deletions addons/material_maker/nodes/tex3d_blend.mmg
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
{
"generic_size": 1,
"name": "tex3d_blend",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"amount": 0.5,
"blend_type": 0
"amount1": 0.5,
"blend_type1": 0
},
"seed_int": 0,
"shader_model": {
"code": "",
"code": [
"vec3 $(name_uv)_b = $b($uv);",
"vec3 $(name_uv)_l;",
"vec3 $(name_uv)_a;",
"#for",
"$(name_uv)_l = $l#($uv);",
"$(name_uv)_a = $amount#*$a#($uv);",
"$(name_uv)_b = blend3d_$blend_type#($(name_uv)_l.rgb, $(name_uv)_b.rgb, $amount#*dot($a#($uv), vec3(1.0))/3.0 );",
"#end",
""
],
"global": [
"vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {",
"\treturn opacity*c1 + (1.0-opacity)*c2;",
Expand Down Expand Up @@ -76,26 +87,26 @@
"inputs": [
{
"default": "vec3($uv.x, 1.0, 1.0)",
"label": "Source1",
"label": "Background",
"longdesc": "The foreground input",
"name": "s1",
"name": "b",
"shortdesc": "Foreground",
"type": "tex3d"
},
{
"default": "vec3(1.0, $uv.y, 1.0)",
"label": "Source2",
"label": "Layer#",
"longdesc": "The background input",
"name": "s2",
"name": "l#",
"shortdesc": "Background",
"type": "tex3d"
},
{
"default": "vec3(1.0)",
"label": "Opacity",
"label": "Opacity#",
"longdesc": "The optional opacity mask",
"name": "a",
"shortdesc": "Mask",
"name": "a#",
"shortdesc": "Mask#",
"type": "tex3d"
}
],
Expand All @@ -106,16 +117,16 @@
{
"longdesc": "The 3D texture generated by the blend operation",
"shortdesc": "Output",
"tex3d": "blend3d_$blend_type($s1($uv).rgb, $s2($uv).rgb, $amount*dot($a($uv), vec3(1.0))/3.0)",
"tex3d": "$(name_uv)_b",
"type": "tex3d"
}
],
"parameters": [
{
"default": 0,
"label": "",
"label": "2:",
"longdesc": "The algorithm used to blend the inputs",
"name": "blend_type",
"name": "blend_type#",
"shortdesc": "Blend mode",
"type": "enum",
"values": [
Expand Down Expand Up @@ -172,7 +183,7 @@
"longdesc": "The opacity of the blend operation",
"max": 1,
"min": 0,
"name": "amount",
"name": "amount#",
"shortdesc": "Opacity",
"step": 0,
"type": "float"
Expand Down
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/tex3d_rotate.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "tex3d_rotate",
"node_position": {
"x": 0,
Expand Down Expand Up @@ -41,8 +42,8 @@
"default": "vec3(1.0)",
"label": "",
"longdesc": "The input 3D texture",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "tex3d"
}
],
Expand All @@ -52,8 +53,8 @@
"outputs": [
{
"longdesc": "The rotated 3D texture",
"shortdesc": "Output",
"tex3d": "$in(vec4(tex3d_rotate($uv.xyz, -vec3($ax, $ay, $az)*0.01745329251), $uv.w))",
"shortdesc": "Output#",
"tex3d": "$in#(vec4(tex3d_rotate($uv.xyz, -vec3($ax, $ay, $az)*0.01745329251), $uv.w))",
"type": "tex3d"
}
],
Expand Down
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/tex3d_scale.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "tex3d_scale",
"node_position": {
"x": 0,
Expand All @@ -16,8 +17,8 @@
"default": "vec3(1.0)",
"label": "",
"longdesc": "The input 3D texture",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "tex3d"
}
],
Expand All @@ -27,8 +28,8 @@
"outputs": [
{
"longdesc": "The scaled 3D texture",
"shortdesc": "Output",
"tex3d": "$in(vec4($uv.xyz/max($s, 0.00001), $uv.w))",
"shortdesc": "Output#",
"tex3d": "$in#(vec4($uv.xyz/max($s, 0.00001), $uv.w))",
"type": "tex3d"
}
],
Expand Down
43 changes: 26 additions & 17 deletions addons/material_maker/nodes/tex3d_select.mmg
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
{
"generic_size": 1,
"name": "tex3d_select",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"t": 0.01,
"v": 1
"t1": 0.01,
"v1": 1
},
"seed_int": 0,
"shader_model": {
"code": "float $(name_uv)_d = ($uv.w-$v)/$t;",
"code": [
"vec3 $(name_uv)_b = $b($uv);",
"float $(name_uv)_d = 0.0;",
"",
"#for",
"$(name_uv)_d = ($uv.w-$v#)/$t#;",
"$(name_uv)_b = mix($(name_uv)_b, $i#($uv), clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0));",
"#end"
],
"global": "",
"inputs": [
{
"default": "vec3(0.5)",
"label": "",
"longdesc": "The 3D texture associated to the specified color index",
"name": "in1",
"shortdesc": "Input1",
"longdesc": "The 3D texture(s) associated to other color indices",
"name": "b",
"shortdesc": "Background",
"type": "tex3d"
},
{
"default": "vec3(0.5)",
"label": "",
"longdesc": "The 3D texture(s) associated to other color indices",
"name": "in2",
"shortdesc": "Input2",
"longdesc": "The 3D texture associated to the specified color index",
"name": "i#",
"shortdesc": "Input#",
"type": "tex3d"
}
],
Expand All @@ -37,31 +46,31 @@
{
"longdesc": "The merged 3D texture",
"shortdesc": "Output",
"tex3d": "mix($in1($uv), $in2($uv), clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0))",
"tex3d": "$(name_uv)_b",
"type": "tex3d"
}
],
"parameters": [
{
"control": "None",
"default": 0.5,
"label": "Value",
"default": 1,
"label": "2:Value",
"longdesc": "The value of the selected color index",
"max": 1,
"min": 0,
"name": "v",
"shortdesc": "Value",
"name": "v#",
"shortdesc": "Value#",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 0.1,
"label": "Tolerance",
"default": 0.01,
"label": "2:",
"longdesc": "The tolerance used when comparing color indices",
"max": 1,
"min": 0.01,
"name": "t",
"name": "t#",
"shortdesc": "Tolerance",
"step": 0.001,
"type": "float"
Expand Down
41 changes: 24 additions & 17 deletions addons/material_maker/nodes/tex3d_select_shape.mmg
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
{
"generic_size": 1,
"name": "tex3d_select_shape",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"d": 0
"d1": 0
},
"seed_int": 0,
"shader_model": {
"code": "",
"code": [
"vec3 $(name_uv)_b = $b($uv);",
"",
"#for",
"$(name_uv)_b = mix($i#($uv), $(name_uv)_b, clamp($shape#($uv.xyz)/max($d#, 0.0001), 0.0, 1.0));",
"#end"
],
"global": "",
"inputs": [
{
"default": "vec3(0.5)",
"label": "",
"longdesc": "The 3D texture associated to the specified color index",
"name": "in1",
"shortdesc": "Input1",
"longdesc": "The 3D texture(s) outside the input selection shapes",
"name": "b",
"shortdesc": "Background",
"type": "tex3d"
},
{
"default": "vec3(0.5)",
"label": "",
"longdesc": "The 3D texture(s) associated to other color indices",
"name": "in2",
"shortdesc": "Input2",
"longdesc": "The 3D texture associated to the selection shape",
"name": "i#",
"shortdesc": "Input#",
"type": "tex3d"
},
{
"default": "0.0",
"label": "",
"longdesc": "The shape in which input1 is applied",
"name": "shape",
"shortdesc": "Shape",
"longdesc": "The shape in which Input# is applied",
"name": "shape#",
"shortdesc": "Shape#",
"type": "sdf3d"
}
],
Expand All @@ -44,20 +51,20 @@
{
"longdesc": "The merged 3D texture",
"shortdesc": "Output",
"tex3d": "mix($in1($uv), $in2($uv), clamp($shape($uv.xyz)/max($d, 0.0001), 0.0, 1.0))",
"tex3d": "$(name_uv)_b",
"type": "tex3d"
}
],
"parameters": [
{
"control": "None",
"default": 0.5,
"label": "Smoothness",
"longdesc": "The width of the transition area between both textures",
"default": 0.01,
"label": "3:Smoothness",
"longdesc": "The width of the transition area between textures",
"max": 1,
"min": 0,
"name": "d",
"shortdesc": "Smoothness",
"name": "d#",
"shortdesc": "Smoothness#",
"step": 0.01,
"type": "float"
}
Expand Down
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/tex3d_translate.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "tex3d_translate",
"node_position": {
"x": 0,
Expand All @@ -18,8 +19,8 @@
"default": "vec3(1.0)",
"label": "",
"longdesc": "The input 3D texture",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "tex3d"
}
],
Expand All @@ -29,8 +30,8 @@
"outputs": [
{
"longdesc": "The translated 3D texture",
"shortdesc": "Output",
"tex3d": "$in(vec4($uv.xyz-vec3($x, $y, $z), $uv.w))",
"shortdesc": "Output#",
"tex3d": "$in#(vec4($uv.xyz-vec3($x, $y, $z), $uv.w))",
"type": "tex3d"
}
],
Expand Down
Loading
Loading