Skip to content

Commit 7640c3e

Browse files
authored
Adding legacy knurl (#1439)
* Adding legacy knurl Adding nodedef and nodegraph for Legacy Knurl. This implements a generic knurl that is a superset, usable standalone, of the knurl used as a Metal pattern. The original knurl in RapidRT was not usable standalone. This solution is different and has more features, making it a worthwhile extra procedural to add to the library. A coupe of extra fixes are included - defaults for a couple of size parameters were incorrectly set to 0,0 after changing them to vector2. - A converter node from LookdevX was removed. It was unconnected, so no real change, and it might be recreated if that graph is re-exported. I'll try to keep an eye on it. * Adding diagonal option The diagonal option was in my original version, but was removed when I added separate X and Y scales, as the pattern was distorting and it was not necessary for matching the RRT version. But then I realized this was an important feature of Knurl in manufacturing, and spend some time trying to make it work again. This change adds just a few nodes and the feature is back, even if there is a small approximation in the normals direction when stretched. * Adding unit test for knurl Simple unit test
1 parent ae521c4 commit 7640c3e

3 files changed

Lines changed: 184 additions & 5 deletions

File tree

contrib/adsk/libraries/adsklib/adsklib_legacy_defs.mtlx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<input name="texcoord" type="vector2" defaultgeomprop="UV0" uivisible="false" uiname="Texture Coordinates" />
5252
<input name="color1" type="color3" value="1, 1, 1" uivisible="true" uiname="Color 1" />
5353
<input name="color2" type="color3" value="0, 0, 0" uivisible="true" uiname="Color 2" />
54-
<input name="realworld_scale" type="vector2" value="0,0" uisoftmin="0,0" uisoftmax="1,1" uivisible="true" uiname="Width, Height" unittype="distance" />
54+
<input name="realworld_scale" type="vector2" value="1,1" uisoftmin="0,0" uisoftmax="1,1" uivisible="true" uiname="Width, Height" unittype="distance" />
5555
<input name="soften" type="float" value="0" uivisible="true" uiname="Soften" />
5656
<input name="adjust_soften_y" type="boolean" value="false" uivisible="true" uiname="Adjust Height Softness" />
5757
<input name="realworld_offset" type="vector2" value="0,0" uisoftmin="0,0" uisoftmax="1,1" uivisible="true" uiname="Offset X, Y" unittype="distance"/>
@@ -222,7 +222,7 @@
222222
<input name="rows_mod_enable" type="boolean" value="false" uivisible="true" uiname="Row Modify" />
223223
<input name="num_rows" type="float" value="5.0" uisoftmin="0.0" uisoftmax="100.0" uivisible="true" uiname="Every N Rows" />
224224
<input name="rows_mod_amount" type="float" value="3.0" uisoftmin="0.0" uisoftmax="10" uivisible="true" uiname="Modify Amount" />
225-
<input name="realworld_scale" type="vector2" value="0,0" uisoftmin="0,0" uisoftmax="1,1" uivisible="true" uiname="Width, Height" unittype="distance" />
225+
<input name="realworld_scale" type="vector2" value="1,1" uisoftmin="0,0" uisoftmax="1,1" uivisible="true" uiname="Width, Height" unittype="distance" />
226226
<input name="realworld_offset" type="vector2" value="0,0" uisoftmin="0,0" uisoftmax="1,1" uivisible="true" uiname="Offset X, Y" unittype="distance" />
227227
<input name="rotation_angle" type="float" value="0" uisoftmin="0.0" uisoftmax="360" uivisible="true" uiname="Rotation Angle" unittype="angle" unit="degree" />
228228
<input name="tile_x" type="boolean" value="true" />
@@ -274,6 +274,17 @@
274274
<output name="out" type="color3" />
275275
</nodedef>
276276

277+
<nodedef name="ND_legacy_knurl" node="legacy_knurl" version="0.1" isdefaultversion="true" nodegroup="adsk_legacy">
278+
<input name="texcoord" type="vector2" defaultgeomprop="UV0" uivisible="false" uiname="Texture Coordinates" />
279+
<input name="amount" type="float" value="0.25" uimin="0.0" uimax="1.0" />
280+
<input name="rotation" type="float" value="0" uisoftmin="0.0" uisoftmax="360" />
281+
<input name="realworld_scale" type="vector2" value="1,1" uisoftmin="0,0" uisoftmax="1,1" uivisible="true" uiname="Width, Height" unittype="distance" />
282+
<input name="realworld_offset" type="vector2" value="0,0" uisoftmin="0,0" uisoftmax="1,1" uiname="Offset X, Y" unittype="distance" />
283+
<input name="diagonal" type="boolean" value="false" />
284+
<output name="out_rgb" type="color3" />
285+
<output name="out_vec3" type="vector3" />
286+
</nodedef>
287+
277288
<!--
278289
=============================================
279290
Nodedefs for Autodesk Legacy Material Classes

contrib/adsk/libraries/adsklib/adsklib_legacy_ng.mtlx

Lines changed: 149 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,6 @@
687687
<input name="value2" type="boolean" value="true" />
688688
<input name="value1" type="boolean" interfacename="threshold_smooth" />
689689
</ifequal>
690-
<adsk_converter name="adsk_converter1" type="color3" nodedef="ND_adsk_converter_float_color3" Autodesk-hiddenInternalConverter="true" Autodesk-internalConverter="true">
691-
<input name="in" type="float" nodename="turbulence3d_max8" />
692-
</adsk_converter>
693690
<backdrop name="offset_and_rotation" xpos="5.36043" ypos="3.36278" width="3.49555" height="4.42037" />
694691
<add name="add_noise1" type="float" nodedef="ND_add_float" xpos="14.5288" ypos="10.3503">
695692
<input name="in2" type="float" nodename="mult_phase" />
@@ -3690,6 +3687,155 @@
36903687
</legacy_gradient>
36913688
</nodegraph>
36923689

3690+
<nodegraph name="NG_legacy_knurl" Autodesk-ldx_inputPos="-1747.36 -123.243" Autodesk-ldx_outputPos="2689.42 48.6444" nodedef="ND_legacy_knurl">
3691+
<separate2 name="separate_uv" type="multioutput" nodedef="ND_separate2_vector2" xpos="0.173733" ypos="-1.37102">
3692+
<input name="in" type="vector2" nodename="diag_select1" />
3693+
</separate2>
3694+
<output name="out_rgb" type="color3" nodename="convert_vec_col" />
3695+
<constant name="constant_vecX" type="vector3" nodedef="ND_constant_vector3" xpos="-1.92249" ypos="0.974561">
3696+
<input name="value" type="vector3" value="1, 0, 0" />
3697+
</constant>
3698+
<rotate3d name="rotate_Y1" type="vector3" nodedef="ND_rotate3d_vector3" xpos="0.221146" ypos="0.691367">
3699+
<input name="in" type="vector3" nodename="constant_vecX" />
3700+
<input name="amount" type="float" nodename="amount_to_degrees" />
3701+
<input name="axis" type="vector3" value="0, 1, 0" />
3702+
</rotate3d>
3703+
<rotate3d name="rotate_Y2" type="vector3" nodedef="ND_rotate3d_vector3" xpos="0.18353" ypos="1.88111">
3704+
<input name="in" type="vector3" nodename="constant_vecX" />
3705+
<input name="amount" type="float" ldx_value="90" nodename="invert_180" />
3706+
<input name="axis" type="vector3" value="0, 1, 0" />
3707+
</rotate3d>
3708+
<ifgreater name="ifgreater_half_x" type="vector3" nodedef="ND_ifgreater_vector3" xpos="3.43067" ypos="-1.19766">
3709+
<input name="value2" type="float" value="0.5" />
3710+
<input name="in1" type="vector3" nodename="rotate_Y1" ldx_value="0.2934, 0, 0" />
3711+
<input name="in2" type="vector3" nodename="rotate_Y2" />
3712+
<input name="value1" type="float" nodename="separate_uv" output="outx" />
3713+
</ifgreater>
3714+
<multiply name="amount_to_degrees" type="float" nodedef="ND_multiply_float" xpos="-3.75268" ypos="-0.68535">
3715+
<input name="in1" type="float" nodename="invert_amount" />
3716+
<input name="in2" type="float" value="90" />
3717+
</multiply>
3718+
<invert name="invert_x" type="float" nodedef="ND_invert_float" xpos="3.46505" ypos="2.25166">
3719+
<input name="in" type="float" nodename="separate_uv" output="outx" />
3720+
</invert>
3721+
<ifgreater name="ifgreater_xy" type="float" nodedef="ND_ifgreater_float" xpos="5.42496" ypos="-0.352874">
3722+
<input name="in1" type="float" value="1" />
3723+
<input name="in2" type="float" value="0" />
3724+
<input name="value2" type="float" nodename="separate_uv" output="outy" />
3725+
<input name="value1" type="float" nodename="separate_uv" output="outx" />
3726+
</ifgreater>
3727+
<ifgreater name="ifgreater_yx" type="float" nodedef="ND_ifgreater_float" xpos="5.42107" ypos="1.22741">
3728+
<input name="in1" type="float" value="1" />
3729+
<input name="in2" type="float" value="0" />
3730+
<input name="value2" type="float" nodename="invert_x" />
3731+
<input name="value1" type="float" nodename="separate_uv" output="outy" />
3732+
</ifgreater>
3733+
<ifequal name="select_plane" type="vector3" nodedef="ND_ifequal_vector3" xpos="7.20856" ypos="0.289837">
3734+
<input name="value1" type="float" nodename="ifgreater_xy" />
3735+
<input name="value2" type="float" nodename="ifgreater_yx" />
3736+
<input name="in1" type="vector3" nodename="ifgreater_half_x" ldx_value="0.4052, 0.0935, 0.0935" />
3737+
<input name="in2" type="vector3" nodename="ifgreater_half_y" ldx_value="0, 0, 0" />
3738+
</ifequal>
3739+
<output name="out_vec3" type="vector3" nodename="normalmap1" />
3740+
<invert name="invert_amount" type="float" nodedef="ND_invert_float" xpos="-5.42683" ypos="-1.00327">
3741+
<input name="in" type="float" interfacename="amount" />
3742+
</invert>
3743+
<rotate3d name="rotate_X1" type="vector3" nodedef="ND_rotate3d_vector3" xpos="0.193136" ypos="3.51694">
3744+
<input name="axis" type="vector3" value="1, 0, 0" />
3745+
<input name="amount" type="float" nodename="invert_180" />
3746+
<input name="in" type="vector3" nodename="constant_vecY" />
3747+
</rotate3d>
3748+
<rotate3d name="rotate_X2" type="vector3" nodedef="ND_rotate3d_vector3" xpos="0.222224" ypos="4.92501">
3749+
<input name="in" type="vector3" nodename="constant_vecY" />
3750+
<input name="axis" type="vector3" value="1, 0, 0" />
3751+
<input name="amount" type="float" ldx_value="0" nodename="amount_to_degrees" />
3752+
</rotate3d>
3753+
<constant name="constant_vecY" type="vector3" nodedef="ND_constant_vector3" xpos="-1.76419" ypos="4.90634">
3754+
<input name="value" type="vector3" value="0, -1, 0" />
3755+
</constant>
3756+
<ifgreater name="ifgreater_half_y" type="vector3" nodedef="ND_ifgreater_vector3" xpos="3.4679" ypos="0.693533">
3757+
<input name="value1" type="float" nodename="separate_uv" output="outy" />
3758+
<input name="value2" type="float" value="0.5" />
3759+
<input name="in1" type="vector3" nodename="rotate_X1" ldx_value="0.2934, 0, 0" />
3760+
<input name="in2" type="vector3" nodename="rotate_X2" />
3761+
</ifgreater>
3762+
<divide name="divide_half" type="vector3" nodedef="ND_divide_vector3FA" xpos="10.4983" ypos="0.342258">
3763+
<input name="in2" type="float" value="2" />
3764+
<input name="in1" type="vector3" nodename="rotate_normal" />
3765+
</divide>
3766+
<add name="offset_half" type="vector3" nodedef="ND_add_vector3FA" xpos="11.8534" ypos="0.355958">
3767+
<input name="in2" type="float" value="0.5" />
3768+
<input name="in1" type="vector3" nodename="divide_half" />
3769+
</add>
3770+
<convert name="convert_vec_col" type="color3" nodedef="ND_convert_vector3_color3" xpos="13.3929" ypos="-0.464234">
3771+
<input name="in" type="vector3" nodename="offset_half" />
3772+
</convert>
3773+
<modulo name="uv_modulo" type="vector2" nodedef="ND_modulo_vector2FA" xpos="-1.94274" ypos="-1.53743">
3774+
<input name="in1" type="vector2" nodename="divide1" />
3775+
</modulo>
3776+
<rotate2d name="rotate2d_pattern" type="vector2" nodedef="ND_rotate2d_vector2" xpos="-5.43093" ypos="-3.16315">
3777+
<input name="amount" type="float" nodename="lagacy_rot_direction" ldx_value="0" />
3778+
<input name="in" type="vector2" nodename="offset_uv" />
3779+
</rotate2d>
3780+
<rotate3d name="rotate_normal" type="vector3" nodedef="ND_rotate3d_vector3" xpos="8.83856" ypos="0.319578">
3781+
<input name="axis" type="vector3" value="0, 0, 1" />
3782+
<input name="amount" type="float" nodename="diag_select2" ldx_value="0" />
3783+
<input name="in" type="vector3" nodename="select_plane" />
3784+
</rotate3d>
3785+
<invert name="invert_180" type="float" nodedef="ND_invert_float" xpos="-1.86346" ypos="2.77993">
3786+
<input name="amount" type="float" value="180" />
3787+
<input name="in" type="float" nodename="amount_to_degrees" />
3788+
</invert>
3789+
<invert name="lagacy_rot_direction" type="float" nodedef="ND_invert_float" xpos="-7.20711" ypos="-3.31817">
3790+
<input name="amount" type="float" value="0" />
3791+
<input name="in" type="float" interfacename="rotation" />
3792+
</invert>
3793+
<divide name="divide1" type="vector2" nodedef="ND_divide_vector2" xpos="-3.76994" ypos="-2.2396">
3794+
<input name="in2" type="vector2" interfacename="realworld_scale" />
3795+
<input name="in1" type="vector2" ldx_value="1, 1" nodename="rotate2d_pattern" />
3796+
</divide>
3797+
<subtract name="offset_uv" type="vector2" nodedef="ND_subtract_vector2" xpos="-7.20083" ypos="-2.1922">
3798+
<input name="in1" type="vector2" interfacename="texcoord" />
3799+
<input name="in2" type="vector2" interfacename="realworld_offset" />
3800+
</subtract>
3801+
<normalmap name="normalmap1" type="vector3" nodedef="ND_normalmap" xpos="13.3901" ypos="0.818122">
3802+
<input name="in" type="vector3" nodename="offset_half" />
3803+
</normalmap>
3804+
<rotate2d name="rotate_knurl" type="vector2" nodedef="ND_rotate2d_vector2" xpos="-5.53632" ypos="-5.17471">
3805+
<input name="amount" type="float" value="45" />
3806+
<input name="in" type="vector2" nodename="diag_scale" />
3807+
</rotate2d>
3808+
<modulo name="modulo_knurl" type="vector2" nodedef="ND_modulo_vector2FA" xpos="-2.39462" ypos="-5.16703">
3809+
<input name="in1" type="vector2" nodename="diag_shift" />
3810+
<input name="in2" type="float" value="1" />
3811+
</modulo>
3812+
<ifequal name="diag_select1" type="vector2" nodedef="ND_ifequal_vector2B" xpos="-0.836778" ypos="-5.19393">
3813+
<input name="value2" type="boolean" value="true" />
3814+
<input name="value1" type="boolean" interfacename="diagonal" />
3815+
<input name="in2" type="vector2" nodename="uv_modulo" />
3816+
<input name="in1" type="vector2" nodename="modulo_knurl" />
3817+
</ifequal>
3818+
<multiply name="diag_scale" type="vector2" nodedef="ND_multiply_vector2FA" xpos="-7.156" ypos="-5.18757">
3819+
<input name="in2" type="float" value="1.41421" />
3820+
<input name="in1" type="vector2" nodename="uv_modulo" />
3821+
</multiply>
3822+
<add name="diag_shift" type="vector2" nodedef="ND_add_vector2" xpos="-3.90246" ypos="-5.12966">
3823+
<input name="in1" type="vector2" nodename="rotate_knurl" />
3824+
<input name="in2" type="vector2" value="0.5, 0.5" />
3825+
</add>
3826+
<ifequal name="diag_select2" type="float" nodedef="ND_ifequal_floatB" xpos="-5.46295" ypos="0.625989">
3827+
<input name="value2" type="boolean" value="true" />
3828+
<input name="value1" type="boolean" interfacename="diagonal" />
3829+
<input name="in2" type="float" interfacename="rotation" />
3830+
<input name="in1" type="float" nodename="diag_adjustment" />
3831+
</ifequal>
3832+
<subtract name="diag_adjustment" type="float" nodedef="ND_subtract_float" xpos="-7.42233" ypos="2.30152">
3833+
<input name="in1" type="float" interfacename="rotation" />
3834+
<input name="in2" type="float" value="45" />
3835+
</subtract>
3836+
<backdrop name="this_is_an_approximation" xpos="-7.892" ypos="1.63793" width="2.22739" height="2.05194" uicolor="#C85252" Autodesk-ldx_alpha="0.156863" />
3837+
</nodegraph>
3838+
36933839
<!--
36943840
===============================================
36953841
Nodegraphs for Autodesk Legacy Material Classes
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<materialx version="1.39" colorspace="lin_rec709">
3+
<standard_surface name="SR_legacy_knurl" type="surfaceshader" xpos="10.521739" ypos="-0.620690">
4+
<input name="base" type="float" value="1" />
5+
<input name="base_color" type="color3" value="0.8, 0.8, 0.8" />
6+
<input name="specular_roughness" type="float" value="0.1" />
7+
<input name="subsurface" type="float" value="0.4" />
8+
<input name="subsurface_color" type="color3" value="1, 1, 1" />
9+
<input name="metalness" type="float" value="1" />
10+
<input name="normal" type="vector3" output="out_vec3" nodename="legacy_knurl" />
11+
</standard_surface>
12+
<surfacematerial name="M_legacy_knurl" type="material" xpos="13.043478" ypos="0.000000">
13+
<input name="surfaceshader" type="surfaceshader" nodename="SR_legacy_knurl" />
14+
</surfacematerial>
15+
<legacy_knurl name="legacy_knurl" type="multioutput" xpos="5.536232" ypos="-1.086207">
16+
<output name="out_rgb" type="color3" />
17+
<input name="amount" type="float" value="0.25" />
18+
<input name="realworld_scale" type="vector2" value="0.1, 0.2" />
19+
<input name="diagonal" type="boolean" value="true" />
20+
<input name="rotation" type="float" value="45" />
21+
</legacy_knurl>
22+
</materialx>

0 commit comments

Comments
 (0)