Skip to content

Commit

Permalink
variadic tex3d select
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchange committed Dec 20, 2023
1 parent f485a0f commit f9d9590
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
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
20 changes: 12 additions & 8 deletions material_maker/doc/node_3d_texture_select.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
Select node
~~~~~~~~~~~

The **Select** node merges two 3D textures by assigning all samples to its first
input except those whose color index match the color parameter.
The **Select** node assigns one or more 3D textures based on
samples whose color index match the color parameter.

.. image:: images/node_3d_texture_select.png
:align: center

Inputs
......

The **Select** node accepts two 3D texture inputs:
The **Select** node accepts two or more 3D texture inputs:

* the default texture, used for all samples that don't match the color parameter
* the selected texture that is assigned to all samples that match
* The default texture, used for all samples that don't match the color parameter.

* Selected texture that is assigned to all samples that match.

This node is variadic, and more inputs with associated color indicies can be added.

Outputs
.......
Expand All @@ -23,7 +26,8 @@ The **Select** node generates a merged 3D texture.
Parameters
..........

The **Select** node does accepts 2 parameters:
The **Select** node accepts 2 parameters:

* A color index that is compared with the color index of each sample

* a color index that is compared with the color index of each sample
* a tolerance value used when comparing the color parameter with the sample's color index
* A tolerance value used when comparing the color parameter with the sample's color index

0 comments on commit f9d9590

Please sign in to comment.