NodeCreator.hx 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336
  1. package arm;
  2. import armory.object.Object;
  3. import armory.system.Cycles;
  4. import zui.*;
  5. import zui.Nodes;
  6. import iron.data.SceneFormat;
  7. import iron.data.MaterialData;
  8. @:access(arm.UINodes)
  9. class NodeCreator {
  10. public static function createImageTexture(uinodes:UINodes) {
  11. var getNodeX = uinodes.getNodeX;
  12. var getNodeY = uinodes.getNodeY;
  13. var nodes = UINodes.nodes;
  14. var canvas = UINodes.canvas;
  15. var node_id = nodes.getNodeId(canvas.nodes);
  16. var n:TNode = {
  17. id: node_id,
  18. name: "Image Texture",
  19. type: "TEX_IMAGE",
  20. x: getNodeX(),
  21. y: getNodeY(),
  22. color: 0xff4982a0,
  23. inputs: [
  24. {
  25. id: nodes.getSocketId(canvas.nodes),
  26. node_id: node_id,
  27. name: "Vector",
  28. type: "VECTOR",
  29. color: 0xff6363c7,
  30. default_value: [0.0, 0.0, 0.0]
  31. }
  32. ],
  33. outputs: [
  34. {
  35. id: nodes.getSocketId(canvas.nodes),
  36. node_id: node_id,
  37. name: "Color",
  38. type: "RGBA",
  39. color: 0xffc7c729,
  40. default_value: ""
  41. },
  42. {
  43. id: nodes.getSocketId(canvas.nodes),
  44. node_id: node_id,
  45. name: "Alpha",
  46. type: "VALUE",
  47. color: 0xffa1a1a1,
  48. default_value: 1.0
  49. }
  50. ],
  51. buttons: [
  52. {
  53. name: "default_value",
  54. type: "ENUM",
  55. default_value: 0,
  56. output: 0
  57. }
  58. ]
  59. };
  60. canvas.nodes.push(n);
  61. nodes.nodeDrag = n;
  62. nodes.nodeSelected = n;
  63. }
  64. public static var numNodes = [2, 1, 5, 5, 8];
  65. public static function draw(uinodes:UINodes, cat:Int) {
  66. var ui = uinodes.ui;
  67. var getNodeX = uinodes.getNodeX;
  68. var getNodeY = uinodes.getNodeY;
  69. var nodes = UINodes.nodes;
  70. var canvas = UINodes.canvas;
  71. if (cat == 0) { // Input
  72. if (ui.button("RGB")) {
  73. var node_id = nodes.getNodeId(canvas.nodes);
  74. var n:TNode = {
  75. id: node_id,
  76. name: "RGB",
  77. type: "RGB",
  78. x: getNodeX(),
  79. y: getNodeY(),
  80. color: 0xffb34f5a,
  81. inputs: [],
  82. outputs: [
  83. {
  84. id: nodes.getSocketId(canvas.nodes),
  85. node_id: node_id,
  86. name: "Color",
  87. type: "RGBA",
  88. color: 0xffc7c729,
  89. default_value: [0.5, 0.5, 0.5, 1.0]
  90. }
  91. ],
  92. buttons: [
  93. {
  94. name: "default_value",
  95. type: "RGBA",
  96. output: 0
  97. }
  98. ]
  99. };
  100. canvas.nodes.push(n);
  101. nodes.nodeDrag = n;
  102. nodes.nodeSelected = n;
  103. }
  104. if (ui.button("Value")) {
  105. var node_id = nodes.getNodeId(canvas.nodes);
  106. var n:TNode = {
  107. id: node_id,
  108. name: "Value",
  109. type: "VALUE",
  110. x: getNodeX(),
  111. y: getNodeY(),
  112. color: 0xffb34f5a,
  113. inputs: [],
  114. outputs: [
  115. {
  116. id: nodes.getSocketId(canvas.nodes),
  117. node_id: node_id,
  118. name: "Value",
  119. type: "VALUE",
  120. color: 0xffa1a1a1,
  121. default_value: 0.5
  122. }
  123. ],
  124. buttons: [
  125. {
  126. name: "default_value",
  127. type: "VALUE",
  128. output: 0,
  129. min: 0.0,
  130. max: 10.0
  131. }
  132. ]
  133. };
  134. canvas.nodes.push(n);
  135. nodes.nodeDrag = n;
  136. nodes.nodeSelected = n;
  137. }
  138. // if (ui.button("Camera Data")) {
  139. // var node_id = nodes.getNodeId(canvas.nodes);
  140. // var n:TNode = {
  141. // id: node_id,
  142. // name: "Camera Data",
  143. // type: "CAMERA",
  144. // x: getNodeX(),
  145. // y: getNodeY(),
  146. // color: 0xff4982a0,
  147. // inputs: [],
  148. // outputs: [
  149. // {
  150. // id: nodes.getSocketId(canvas.nodes),
  151. // node_id: node_id,
  152. // name: "View Vector",
  153. // type: "VECTOR",
  154. // color: 0xff6363c7,
  155. // default_value: [0.0, 0.0, 0.0]
  156. // },
  157. // {
  158. // id: nodes.getSocketId(canvas.nodes),
  159. // node_id: node_id,
  160. // name: "View Z Depth",
  161. // type: "VALUE",
  162. // color: 0xffa1a1a1,
  163. // default_value: 0.0
  164. // },
  165. // {
  166. // id: nodes.getSocketId(canvas.nodes),
  167. // node_id: node_id,
  168. // name: "View Distance",
  169. // type: "VALUE",
  170. // color: 0xffa1a1a1,
  171. // default_value: 0.0
  172. // }
  173. // ],
  174. // buttons: []
  175. // };
  176. // canvas.nodes.push(n);
  177. // nodes.nodeDrag = n;
  178. // nodes.nodeSelected = n;
  179. // }
  180. // if (ui.button("Geometry")) {
  181. // var node_id = nodes.getNodeId(canvas.nodes);
  182. // var n:TNode = {
  183. // id: node_id,
  184. // name: "Geometry",
  185. // type: "NEW_GEOMETRY",
  186. // x: getNodeX(),
  187. // y: getNodeY(),
  188. // color: 0xff4982a0,
  189. // inputs: [],
  190. // outputs: [
  191. // {
  192. // id: nodes.getSocketId(canvas.nodes),
  193. // node_id: node_id,
  194. // name: "Position",
  195. // type: "VECTOR",
  196. // color: 0xff6363c7,
  197. // default_value: [0.0, 0.0, 0.0]
  198. // },
  199. // {
  200. // id: nodes.getSocketId(canvas.nodes),
  201. // node_id: node_id,
  202. // name: "Normal",
  203. // type: "VECTOR",
  204. // color: 0xff6363c7,
  205. // default_value: [0.0, 0.0, 0.0]
  206. // }
  207. // ],
  208. // buttons: []
  209. // };
  210. // canvas.nodes.push(n);
  211. // nodes.nodeDrag = n;
  212. // nodes.nodeSelected = n;
  213. // }
  214. // if (ui.button("Fresnel")) {
  215. // var node_id = nodes.getNodeId(canvas.nodes);
  216. // var n:TNode = {
  217. // id: node_id,
  218. // name: "Fresnel",
  219. // type: "FRESNEL",
  220. // x: getNodeX(),
  221. // y: getNodeY(),
  222. // color: 0xff4982a0,
  223. // inputs: [
  224. // {
  225. // id: nodes.getSocketId(canvas.nodes),
  226. // node_id: node_id,
  227. // name: "IOR",
  228. // type: "VALUE",
  229. // color: 0xffa1a1a1,
  230. // default_value: 1.450,
  231. // min: 0.0,
  232. // max: 2.0
  233. // }
  234. // ],
  235. // outputs: [
  236. // {
  237. // id: nodes.getSocketId(canvas.nodes),
  238. // node_id: node_id,
  239. // name: "Fac",
  240. // type: "VALUE",
  241. // color: 0xffa1a1a1,
  242. // default_value: 0.0
  243. // }
  244. // ],
  245. // buttons: []
  246. // };
  247. // canvas.nodes.push(n);
  248. // nodes.nodeDrag = n;
  249. // nodes.nodeSelected = n;
  250. // }
  251. // if (ui.button("Layer Weight")) {
  252. // var node_id = nodes.getNodeId(canvas.nodes);
  253. // var n:TNode = {
  254. // id: node_id,
  255. // name: "Layer Weight",
  256. // type: "LAYER_WEIGHT",
  257. // x: getNodeX(),
  258. // y: getNodeY(),
  259. // color: 0xff4982a0,
  260. // inputs: [
  261. // {
  262. // id: nodes.getSocketId(canvas.nodes),
  263. // node_id: node_id,
  264. // name: "Blend",
  265. // type: "VALUE",
  266. // color: 0xffa1a1a1,
  267. // default_value: 0.5
  268. // }
  269. // ],
  270. // outputs: [
  271. // {
  272. // id: nodes.getSocketId(canvas.nodes),
  273. // node_id: node_id,
  274. // name: "Fresnel",
  275. // type: "VALUE",
  276. // color: 0xffa1a1a1,
  277. // default_value: 0.0
  278. // },
  279. // {
  280. // id: nodes.getSocketId(canvas.nodes),
  281. // node_id: node_id,
  282. // name: "Facing",
  283. // type: "VALUE",
  284. // color: 0xffa1a1a1,
  285. // default_value: 0.0
  286. // }
  287. // ],
  288. // buttons: []
  289. // };
  290. // canvas.nodes.push(n);
  291. // nodes.nodeDrag = n;
  292. // nodes.nodeSelected = n;
  293. // }
  294. }
  295. if (cat == 1) { // Output
  296. if (ui.button("Material Output")) {
  297. var node_id = nodes.getNodeId(canvas.nodes);
  298. var n:TNode = {
  299. id: node_id,
  300. name: "Material Output",
  301. type: "OUTPUT_MATERIAL_PBR",
  302. x: getNodeX(),
  303. y: getNodeY(),
  304. color: 0xffb34f5a,
  305. inputs: [
  306. {
  307. id: nodes.getSocketId(canvas.nodes),
  308. node_id: node_id,
  309. name: "Base Color",
  310. type: "RGBA",
  311. color: 0xffc7c729,
  312. default_value: [0.8, 0.8, 0.8, 1.0]
  313. },
  314. {
  315. id: nodes.getSocketId(canvas.nodes),
  316. node_id: node_id,
  317. name: "Opacity",
  318. type: "VALUE",
  319. color: 0xffa1a1a1,
  320. default_value: 1.0
  321. },
  322. {
  323. id: nodes.getSocketId(canvas.nodes),
  324. node_id: node_id,
  325. name: "Occlusion",
  326. type: "VALUE",
  327. color: 0xffa1a1a1,
  328. default_value: 1.0
  329. },
  330. {
  331. id: nodes.getSocketId(canvas.nodes),
  332. node_id: node_id,
  333. name: "Roughness",
  334. type: "VALUE",
  335. color: 0xffa1a1a1,
  336. default_value: 0.1
  337. },
  338. {
  339. id: nodes.getSocketId(canvas.nodes),
  340. node_id: node_id,
  341. name: "Metallic",
  342. type: "VALUE",
  343. color: 0xffa1a1a1,
  344. default_value: 0.0
  345. },
  346. {
  347. id: nodes.getSocketId(canvas.nodes),
  348. node_id: node_id,
  349. name: "Normal Map",
  350. type: "VECTOR",
  351. color: 0xff63c763,
  352. default_value: [0.5, 0.5, 1.0]
  353. },
  354. {
  355. id: nodes.getSocketId(canvas.nodes),
  356. node_id: node_id,
  357. name: "Emission",
  358. type: "VALUE",
  359. color: 0xffa1a1a1,
  360. default_value: 0.0
  361. },
  362. {
  363. id: nodes.getSocketId(canvas.nodes),
  364. node_id: node_id,
  365. name: "Height",
  366. type: "VALUE",
  367. color: 0xffa1a1a1,
  368. default_value: 0.0
  369. },
  370. {
  371. id: nodes.getSocketId(canvas.nodes),
  372. node_id: node_id,
  373. name: "Subsurface",
  374. type: "VALUE",
  375. color: 0xffa1a1a1,
  376. default_value: 0.0
  377. }
  378. ],
  379. outputs: [],
  380. buttons: []
  381. };
  382. canvas.nodes.push(n);
  383. nodes.nodeDrag = n;
  384. nodes.nodeSelected = n;
  385. }
  386. }
  387. if (cat == 2) { // Texture
  388. if (ui.button("Image")) {
  389. createImageTexture(uinodes);
  390. }
  391. if (ui.button("Checker")) {
  392. var node_id = nodes.getNodeId(canvas.nodes);
  393. var n:TNode = {
  394. id: node_id,
  395. name: "Checker Texture",
  396. type: "TEX_CHECKER",
  397. x: getNodeX(),
  398. y: getNodeY(),
  399. color: 0xff4982a0,
  400. inputs: [
  401. {
  402. id: nodes.getSocketId(canvas.nodes),
  403. node_id: node_id,
  404. name: "Vector",
  405. type: "VECTOR",
  406. color: 0xff6363c7,
  407. default_value: [0.0, 0.0, 0.0]
  408. },
  409. {
  410. id: nodes.getSocketId(canvas.nodes),
  411. node_id: node_id,
  412. name: "Color 1",
  413. type: "RGB",
  414. color: 0xffc7c729,
  415. default_value: [0.8, 0.8, 0.8]
  416. },
  417. {
  418. id: nodes.getSocketId(canvas.nodes),
  419. node_id: node_id,
  420. name: "Color 2",
  421. type: "RGB",
  422. color: 0xffc7c729,
  423. default_value: [0.2, 0.2, 0.2]
  424. },
  425. {
  426. id: nodes.getSocketId(canvas.nodes),
  427. node_id: node_id,
  428. name: "Scale",
  429. type: "VALUE",
  430. color: 0xffa1a1a1,
  431. default_value: 1.0,
  432. min: 0.0,
  433. max: 10.0
  434. }
  435. ],
  436. outputs: [
  437. {
  438. id: nodes.getSocketId(canvas.nodes),
  439. node_id: node_id,
  440. name: "Color",
  441. type: "RGBA",
  442. color: 0xffc7c729,
  443. default_value: [0.8, 0.8, 0.8]
  444. },
  445. {
  446. id: nodes.getSocketId(canvas.nodes),
  447. node_id: node_id,
  448. name: "Fac",
  449. type: "VALUE",
  450. color: 0xffa1a1a1,
  451. default_value: 1.0
  452. }
  453. ],
  454. buttons: []
  455. };
  456. canvas.nodes.push(n);
  457. nodes.nodeDrag = n;
  458. nodes.nodeSelected = n;
  459. }
  460. if (ui.button("Gradient")) {
  461. var node_id = nodes.getNodeId(canvas.nodes);
  462. var n:TNode = {
  463. id: node_id,
  464. name: "Gradient Texture",
  465. type: "TEX_GRADIENT",
  466. x: getNodeX(),
  467. y: getNodeY(),
  468. color: 0xff4982a0,
  469. inputs: [
  470. {
  471. id: nodes.getSocketId(canvas.nodes),
  472. node_id: node_id,
  473. name: "Vector",
  474. type: "VECTOR",
  475. color: 0xff6363c7,
  476. default_value: [0.0, 0.0, 0.0]
  477. }
  478. ],
  479. outputs: [
  480. {
  481. id: nodes.getSocketId(canvas.nodes),
  482. node_id: node_id,
  483. name: "Color",
  484. type: "RGBA",
  485. color: 0xffc7c729,
  486. default_value: [0.8, 0.8, 0.8]
  487. },
  488. {
  489. id: nodes.getSocketId(canvas.nodes),
  490. node_id: node_id,
  491. name: "Fac",
  492. type: "VALUE",
  493. color: 0xffa1a1a1,
  494. default_value: 1.0
  495. }
  496. ],
  497. buttons: [
  498. {
  499. name: "gradient_type",
  500. type: "ENUM",
  501. // data: ["Linear", "Quadratic", "Easing", "Diagonal", "Radial", "Quadratic Sphere", "Spherical"],
  502. data: ["Linear", "Diagonal", "Radial", "Spherical"],
  503. default_value: 0,
  504. output: 0
  505. }
  506. ]
  507. };
  508. canvas.nodes.push(n);
  509. nodes.nodeDrag = n;
  510. nodes.nodeSelected = n;
  511. }
  512. if (ui.button("Noise")) {
  513. var node_id = nodes.getNodeId(canvas.nodes);
  514. var n:TNode = {
  515. id: node_id,
  516. name: "Noise Texture",
  517. type: "TEX_NOISE",
  518. x: getNodeX(),
  519. y: getNodeY(),
  520. color: 0xff4982a0,
  521. inputs: [
  522. {
  523. id: nodes.getSocketId(canvas.nodes),
  524. node_id: node_id,
  525. name: "Vector",
  526. type: "VECTOR",
  527. color: 0xff6363c7,
  528. default_value: [0.0, 0.0, 0.0]
  529. },
  530. {
  531. id: nodes.getSocketId(canvas.nodes),
  532. node_id: node_id,
  533. name: "Scale",
  534. type: "VALUE",
  535. color: 0xffa1a1a1,
  536. default_value: 1.0,
  537. min: 0.0,
  538. max: 10.0
  539. }
  540. ],
  541. outputs: [
  542. {
  543. id: nodes.getSocketId(canvas.nodes),
  544. node_id: node_id,
  545. name: "Color",
  546. type: "RGBA",
  547. color: 0xffc7c729,
  548. default_value: [0.8, 0.8, 0.8]
  549. },
  550. {
  551. id: nodes.getSocketId(canvas.nodes),
  552. node_id: node_id,
  553. name: "Fac",
  554. type: "VALUE",
  555. color: 0xffa1a1a1,
  556. default_value: 1.0
  557. }
  558. ],
  559. buttons: []
  560. };
  561. canvas.nodes.push(n);
  562. nodes.nodeDrag = n;
  563. nodes.nodeSelected = n;
  564. }
  565. if (ui.button("Voronoi")) {
  566. var node_id = nodes.getNodeId(canvas.nodes);
  567. var n:TNode = {
  568. id: node_id,
  569. name: "Voronoi Texture",
  570. type: "TEX_VORONOI",
  571. x: getNodeX(),
  572. y: getNodeY(),
  573. color: 0xff4982a0,
  574. inputs: [
  575. {
  576. id: nodes.getSocketId(canvas.nodes),
  577. node_id: node_id,
  578. name: "Vector",
  579. type: "VECTOR",
  580. color: 0xff6363c7,
  581. default_value: [0.0, 0.0, 0.0]
  582. },
  583. {
  584. id: nodes.getSocketId(canvas.nodes),
  585. node_id: node_id,
  586. name: "Scale",
  587. type: "VALUE",
  588. color: 0xffa1a1a1,
  589. default_value: 1.0,
  590. min: 0.0,
  591. max: 10.0
  592. }
  593. ],
  594. outputs: [
  595. {
  596. id: nodes.getSocketId(canvas.nodes),
  597. node_id: node_id,
  598. name: "Color",
  599. type: "RGBA",
  600. color: 0xffc7c729,
  601. default_value: [0.8, 0.8, 0.8]
  602. },
  603. {
  604. id: nodes.getSocketId(canvas.nodes),
  605. node_id: node_id,
  606. name: "Fac",
  607. type: "VALUE",
  608. color: 0xffa1a1a1,
  609. default_value: 1.0
  610. }
  611. ],
  612. buttons: [
  613. {
  614. name: "coloring",
  615. type: "ENUM",
  616. data: ["Intensity", "Cells"],
  617. default_value: 0,
  618. output: 0
  619. }
  620. ]
  621. };
  622. canvas.nodes.push(n);
  623. nodes.nodeDrag = n;
  624. nodes.nodeSelected = n;
  625. }
  626. }
  627. if (cat == 3) { // Color
  628. if (ui.button("BrightContrast")) {
  629. var node_id = nodes.getNodeId(canvas.nodes);
  630. var n:TNode = {
  631. id: node_id,
  632. name: "BrightContrast",
  633. type: "BRIGHTCONTRAST",
  634. x: getNodeX(),
  635. y: getNodeY(),
  636. color: 0xff4982a0,
  637. inputs: [
  638. {
  639. id: nodes.getSocketId(canvas.nodes),
  640. node_id: node_id,
  641. name: "Color",
  642. type: "RGBA",
  643. color: 0xffc7c729,
  644. default_value: [0.8, 0.8, 0.8]
  645. },
  646. {
  647. id: nodes.getSocketId(canvas.nodes),
  648. node_id: node_id,
  649. name: "Bright",
  650. type: "VALUE",
  651. color: 0xffa1a1a1,
  652. default_value: 0.0
  653. },
  654. {
  655. id: nodes.getSocketId(canvas.nodes),
  656. node_id: node_id,
  657. name: "Contrast",
  658. type: "VALUE",
  659. color: 0xffa1a1a1,
  660. default_value: 0.0
  661. }
  662. ],
  663. outputs: [
  664. {
  665. id: nodes.getSocketId(canvas.nodes),
  666. node_id: node_id,
  667. name: "Color",
  668. type: "RGBA",
  669. color: 0xffc7c729,
  670. default_value: [0.8, 0.8, 0.8]
  671. }
  672. ],
  673. buttons: []
  674. };
  675. canvas.nodes.push(n);
  676. nodes.nodeDrag = n;
  677. nodes.nodeSelected = n;
  678. }
  679. if (ui.button("Gamma")) {
  680. var node_id = nodes.getNodeId(canvas.nodes);
  681. var n:TNode = {
  682. id: node_id,
  683. name: "Gamma",
  684. type: "GAMMA",
  685. x: getNodeX(),
  686. y: getNodeY(),
  687. color: 0xff4982a0,
  688. inputs: [
  689. {
  690. id: nodes.getSocketId(canvas.nodes),
  691. node_id: node_id,
  692. name: "Color",
  693. type: "RGBA",
  694. color: 0xffc7c729,
  695. default_value: [0.8, 0.8, 0.8]
  696. },
  697. {
  698. id: nodes.getSocketId(canvas.nodes),
  699. node_id: node_id,
  700. name: "Gamma",
  701. type: "VALUE",
  702. color: 0xffa1a1a1,
  703. default_value: 1.0
  704. }
  705. ],
  706. outputs: [
  707. {
  708. id: nodes.getSocketId(canvas.nodes),
  709. node_id: node_id,
  710. name: "Color",
  711. type: "RGBA",
  712. color: 0xffc7c729,
  713. default_value: [0.8, 0.8, 0.8]
  714. }
  715. ],
  716. buttons: []
  717. };
  718. canvas.nodes.push(n);
  719. nodes.nodeDrag = n;
  720. nodes.nodeSelected = n;
  721. }
  722. if (ui.button("HueSatVal")) {
  723. var node_id = nodes.getNodeId(canvas.nodes);
  724. var n:TNode = {
  725. id: node_id,
  726. name: "HueSatVal",
  727. type: "HUE_SAT",
  728. x: getNodeX(),
  729. y: getNodeY(),
  730. color: 0xff4982a0,
  731. inputs: [
  732. {
  733. id: nodes.getSocketId(canvas.nodes),
  734. node_id: node_id,
  735. name: "Hue",
  736. type: "VALUE",
  737. color: 0xffa1a1a1,
  738. default_value: 0.5
  739. },
  740. {
  741. id: nodes.getSocketId(canvas.nodes),
  742. node_id: node_id,
  743. name: "Sat",
  744. type: "VALUE",
  745. color: 0xffa1a1a1,
  746. default_value: 1.0
  747. },
  748. {
  749. id: nodes.getSocketId(canvas.nodes),
  750. node_id: node_id,
  751. name: "Val",
  752. type: "VALUE",
  753. color: 0xffa1a1a1,
  754. default_value: 1.0
  755. }
  756. ],
  757. outputs: [
  758. {
  759. id: nodes.getSocketId(canvas.nodes),
  760. node_id: node_id,
  761. name: "Color",
  762. type: "RGBA",
  763. color: 0xffc7c729,
  764. default_value: [0.8, 0.8, 0.8]
  765. }
  766. ],
  767. buttons: []
  768. };
  769. canvas.nodes.push(n);
  770. nodes.nodeDrag = n;
  771. nodes.nodeSelected = n;
  772. }
  773. if (ui.button("Invert")) {
  774. var node_id = nodes.getNodeId(canvas.nodes);
  775. var n:TNode = {
  776. id: node_id,
  777. name: "Invert",
  778. type: "INVERT",
  779. x: getNodeX(),
  780. y: getNodeY(),
  781. color: 0xff4982a0,
  782. inputs: [
  783. {
  784. id: nodes.getSocketId(canvas.nodes),
  785. node_id: node_id,
  786. name: "Fac",
  787. type: "VALUE",
  788. color: 0xffa1a1a1,
  789. default_value: 0.5
  790. },
  791. {
  792. id: nodes.getSocketId(canvas.nodes),
  793. node_id: node_id,
  794. name: "Color",
  795. type: "RGBA",
  796. color: 0xffc7c729,
  797. default_value: [0.8, 0.8, 0.8]
  798. }
  799. ],
  800. outputs: [
  801. {
  802. id: nodes.getSocketId(canvas.nodes),
  803. node_id: node_id,
  804. name: "Color",
  805. type: "RGBA",
  806. color: 0xffc7c729,
  807. default_value: [0.8, 0.8, 0.8]
  808. }
  809. ],
  810. buttons: []
  811. };
  812. canvas.nodes.push(n);
  813. nodes.nodeDrag = n;
  814. nodes.nodeSelected = n;
  815. }
  816. if (ui.button("MixRGB")) {
  817. var node_id = nodes.getNodeId(canvas.nodes);
  818. var n:TNode = {
  819. id: node_id,
  820. name: "MixRGB",
  821. type: "MIX_RGB",
  822. x: getNodeX(),
  823. y: getNodeY(),
  824. color: 0xff4982a0,
  825. inputs: [
  826. {
  827. id: nodes.getSocketId(canvas.nodes),
  828. node_id: node_id,
  829. name: "Fac",
  830. type: "VALUE",
  831. color: 0xffa1a1a1,
  832. default_value: 0.5
  833. },
  834. {
  835. id: nodes.getSocketId(canvas.nodes),
  836. node_id: node_id,
  837. name: "Color1",
  838. type: "RGBA",
  839. color: 0xffc7c729,
  840. default_value: [0.5, 0.5, 0.5]
  841. },
  842. {
  843. id: nodes.getSocketId(canvas.nodes),
  844. node_id: node_id,
  845. name: "Color2",
  846. type: "RGBA",
  847. color: 0xffc7c729,
  848. default_value: [0.5, 0.5, 0.5]
  849. }
  850. ],
  851. outputs: [
  852. {
  853. id: nodes.getSocketId(canvas.nodes),
  854. node_id: node_id,
  855. name: "Color",
  856. type: "RGBA",
  857. color: 0xffc7c729,
  858. default_value: [0.8, 0.8, 0.8]
  859. }
  860. ],
  861. buttons: [
  862. {
  863. name: "blend_type",
  864. type: "ENUM",
  865. data: ["Mix", "Add", "Multiply", "Subtract", "Screen", "Divide", "Difference", "Darken", "Lighten", "Soft Light"],
  866. default_value: 0,
  867. output: 0
  868. },
  869. {
  870. name: "use_clamp",
  871. type: "BOOL",
  872. default_value: "false",
  873. output: 0
  874. }
  875. ]
  876. };
  877. canvas.nodes.push(n);
  878. nodes.nodeDrag = n;
  879. nodes.nodeSelected = n;
  880. }
  881. }
  882. if (cat == 4) { // Converter
  883. if (ui.button("Combine RGB")) {
  884. var node_id = nodes.getNodeId(canvas.nodes);
  885. var n:TNode = {
  886. id: node_id,
  887. name: "Combine RGB",
  888. type: "COMBRGB",
  889. x: getNodeX(),
  890. y: getNodeY(),
  891. color: 0xff4982a0,
  892. inputs: [
  893. {
  894. id: nodes.getSocketId(canvas.nodes),
  895. node_id: node_id,
  896. name: "R",
  897. type: "VALUE",
  898. color: 0xffa1a1a1,
  899. default_value: 0.0
  900. },
  901. {
  902. id: nodes.getSocketId(canvas.nodes),
  903. node_id: node_id,
  904. name: "G",
  905. type: "VALUE",
  906. color: 0xffa1a1a1,
  907. default_value: 0.0
  908. },
  909. {
  910. id: nodes.getSocketId(canvas.nodes),
  911. node_id: node_id,
  912. name: "B",
  913. type: "VALUE",
  914. color: 0xffa1a1a1,
  915. default_value: 0.0
  916. }
  917. ],
  918. outputs: [
  919. {
  920. id: nodes.getSocketId(canvas.nodes),
  921. node_id: node_id,
  922. name: "Color",
  923. type: "RGBA",
  924. color: 0xffc7c729,
  925. default_value: [0.8, 0.8, 0.8]
  926. }
  927. ],
  928. buttons: []
  929. };
  930. canvas.nodes.push(n);
  931. nodes.nodeDrag = n;
  932. nodes.nodeSelected = n;
  933. }
  934. if (ui.button("Combine XYZ")) {
  935. var node_id = nodes.getNodeId(canvas.nodes);
  936. var n:TNode = {
  937. id: node_id,
  938. name: "Combine XYZ",
  939. type: "COMBXYZ",
  940. x: getNodeX(),
  941. y: getNodeY(),
  942. color: 0xff4982a0,
  943. inputs: [
  944. {
  945. id: nodes.getSocketId(canvas.nodes),
  946. node_id: node_id,
  947. name: "X",
  948. type: "VALUE",
  949. color: 0xffa1a1a1,
  950. default_value: 0.0
  951. },
  952. {
  953. id: nodes.getSocketId(canvas.nodes),
  954. node_id: node_id,
  955. name: "Y",
  956. type: "VALUE",
  957. color: 0xffa1a1a1,
  958. default_value: 0.0
  959. },
  960. {
  961. id: nodes.getSocketId(canvas.nodes),
  962. node_id: node_id,
  963. name: "Z",
  964. type: "VALUE",
  965. color: 0xffa1a1a1,
  966. default_value: 0.0
  967. }
  968. ],
  969. outputs: [
  970. {
  971. id: nodes.getSocketId(canvas.nodes),
  972. node_id: node_id,
  973. name: "Vector",
  974. type: "VECTOR",
  975. color: 0xff6363c7,
  976. default_value: [0.0, 0.0, 0.0]
  977. }
  978. ],
  979. buttons: []
  980. };
  981. canvas.nodes.push(n);
  982. nodes.nodeDrag = n;
  983. nodes.nodeSelected = n;
  984. }
  985. // if (ui.button("Wavelength")) {
  986. // var node_id = nodes.getNodeId(canvas.nodes);
  987. // var n:TNode = {
  988. // id: node_id,
  989. // name: "Wavelength",
  990. // type: "WAVELENGTH",
  991. // x: getNodeX(),
  992. // y: getNodeY(),
  993. // color: 0xff4982a0,
  994. // inputs: [
  995. // {
  996. // id: nodes.getSocketId(canvas.nodes),
  997. // node_id: node_id,
  998. // name: "Wavelength",
  999. // type: "VALUE",
  1000. // color: 0xffa1a1a1,
  1001. // default_value: 500.0,
  1002. // min: 450.0,
  1003. // max: 600.0
  1004. // }
  1005. // ],
  1006. // outputs: [
  1007. // {
  1008. // id: nodes.getSocketId(canvas.nodes),
  1009. // node_id: node_id,
  1010. // name: "Color",
  1011. // type: "RGBA",
  1012. // color: 0xffc7c729,
  1013. // default_value: [0.8, 0.8, 0.8]
  1014. // }
  1015. // ],
  1016. // buttons: []
  1017. // };
  1018. // canvas.nodes.push(n);
  1019. // nodes.nodeDrag = n;
  1020. // nodes.nodeSelected = n;
  1021. // }
  1022. if (ui.button("Mapping")) {
  1023. var node_id = nodes.getNodeId(canvas.nodes);
  1024. var n:TNode = {
  1025. id: node_id,
  1026. name: "Mapping",
  1027. type: "MAPPING",
  1028. x: getNodeX(),
  1029. y: getNodeY(),
  1030. color: 0xff4982a0,
  1031. inputs: [
  1032. {
  1033. id: nodes.getSocketId(canvas.nodes),
  1034. node_id: node_id,
  1035. name: "Vector",
  1036. type: "VECTOR",
  1037. color: 0xff6363c7,
  1038. default_value: [0.0, 0.0, 0.0]
  1039. },
  1040. {
  1041. id: nodes.getSocketId(canvas.nodes),
  1042. node_id: node_id,
  1043. name: "Translation",
  1044. type: "VECTOR",
  1045. color: 0xff6363c7,
  1046. default_value: [0.0, 0.0, 0.0]
  1047. },
  1048. {
  1049. id: nodes.getSocketId(canvas.nodes),
  1050. node_id: node_id,
  1051. name: "Scale",
  1052. type: "VECTOR",
  1053. color: 0xff6363c7,
  1054. default_value: [1.0, 1.0, 1.0]
  1055. }
  1056. ],
  1057. outputs: [
  1058. {
  1059. id: nodes.getSocketId(canvas.nodes),
  1060. node_id: node_id,
  1061. name: "Vector",
  1062. type: "VECTOR",
  1063. color: 0xff6363c7,
  1064. default_value: [0.0, 0.0, 0.0]
  1065. }
  1066. ],
  1067. buttons: []
  1068. };
  1069. canvas.nodes.push(n);
  1070. nodes.nodeDrag = n;
  1071. nodes.nodeSelected = n;
  1072. }
  1073. if (ui.button("Vector Math")) {
  1074. var node_id = nodes.getNodeId(canvas.nodes);
  1075. var n:TNode = {
  1076. id: node_id,
  1077. name: "Vector Math",
  1078. type: "VECT_MATH",
  1079. x: getNodeX(),
  1080. y: getNodeY(),
  1081. color: 0xff4982a0,
  1082. inputs: [
  1083. {
  1084. id: nodes.getSocketId(canvas.nodes),
  1085. node_id: node_id,
  1086. name: "Vector",
  1087. type: "VECTOR",
  1088. color: 0xff6363c7,
  1089. default_value: [0.0, 0.0, 0.0]
  1090. },
  1091. {
  1092. id: nodes.getSocketId(canvas.nodes),
  1093. node_id: node_id,
  1094. name: "Vector",
  1095. type: "VECTOR",
  1096. color: 0xff6363c7,
  1097. default_value: [0.0, 0.0, 0.0]
  1098. }
  1099. ],
  1100. outputs: [
  1101. {
  1102. id: nodes.getSocketId(canvas.nodes),
  1103. node_id: node_id,
  1104. name: "Vector",
  1105. type: "VECTOR",
  1106. color: 0xff6363c7,
  1107. default_value: [0.0, 0.0, 0.0]
  1108. },
  1109. {
  1110. id: nodes.getSocketId(canvas.nodes),
  1111. node_id: node_id,
  1112. name: "Value",
  1113. type: "VALUE",
  1114. color: 0xffa1a1a1,
  1115. default_value: 0.0
  1116. }
  1117. ],
  1118. buttons: [
  1119. {
  1120. name: "operation",
  1121. type: "ENUM",
  1122. data: ["Add", "Subtract", "Average", "Dot Product", "Cross Product", "Normalize"],
  1123. default_value: 0,
  1124. output: 0
  1125. }
  1126. ]
  1127. };
  1128. canvas.nodes.push(n);
  1129. nodes.nodeDrag = n;
  1130. nodes.nodeSelected = n;
  1131. }
  1132. if (ui.button("Math")) {
  1133. var node_id = nodes.getNodeId(canvas.nodes);
  1134. var n:TNode = {
  1135. id: node_id,
  1136. name: "Math",
  1137. type: "MATH",
  1138. x: getNodeX(),
  1139. y: getNodeY(),
  1140. color: 0xff4982a0,
  1141. inputs: [
  1142. {
  1143. id: nodes.getSocketId(canvas.nodes),
  1144. node_id: node_id,
  1145. name: "Value",
  1146. type: "VALUE",
  1147. color: 0xffa1a1a1,
  1148. default_value: 0.5
  1149. },
  1150. {
  1151. id: nodes.getSocketId(canvas.nodes),
  1152. node_id: node_id,
  1153. name: "Value",
  1154. type: "VALUE",
  1155. color: 0xffa1a1a1,
  1156. default_value: 0.5
  1157. }
  1158. ],
  1159. outputs: [
  1160. {
  1161. id: nodes.getSocketId(canvas.nodes),
  1162. node_id: node_id,
  1163. name: "Value",
  1164. type: "VALUE",
  1165. color: 0xffa1a1a1,
  1166. default_value: 0.0
  1167. }
  1168. ],
  1169. buttons: [
  1170. {
  1171. name: "operation",
  1172. type: "ENUM",
  1173. data: ["Add", "Subtract", "Multiply", "Divide", "Sine", "Cosine", "Tangent", "Arcsine", "Arccosine", "Arctangent", "Power", "Logarithm", "Minimum", "Maximum", "Round", "Less Than", "Greater Than", "Module", "Absolute"],
  1174. default_value: 0,
  1175. output: 0
  1176. },
  1177. {
  1178. name: "use_clamp",
  1179. type: "BOOL",
  1180. default_value: "false",
  1181. output: 0
  1182. }
  1183. ]
  1184. };
  1185. canvas.nodes.push(n);
  1186. nodes.nodeDrag = n;
  1187. nodes.nodeSelected = n;
  1188. }
  1189. if (ui.button("RGB to BW")) {
  1190. var node_id = nodes.getNodeId(canvas.nodes);
  1191. var n:TNode = {
  1192. id: node_id,
  1193. name: "RGB to BW",
  1194. type: "RGBTOBW",
  1195. x: getNodeX(),
  1196. y: getNodeY(),
  1197. color: 0xff4982a0,
  1198. inputs: [
  1199. {
  1200. id: nodes.getSocketId(canvas.nodes),
  1201. node_id: node_id,
  1202. name: "Color",
  1203. type: "RGBA",
  1204. color: 0xffc7c729,
  1205. default_value: ""
  1206. }
  1207. ],
  1208. outputs: [
  1209. {
  1210. id: nodes.getSocketId(canvas.nodes),
  1211. node_id: node_id,
  1212. name: "Val",
  1213. type: "VALUE",
  1214. color: 0xffa1a1a1,
  1215. default_value: 0.0
  1216. }
  1217. ],
  1218. buttons: []
  1219. };
  1220. canvas.nodes.push(n);
  1221. nodes.nodeDrag = n;
  1222. nodes.nodeSelected = n;
  1223. }
  1224. if (ui.button("Separate RGB")) {
  1225. var node_id = nodes.getNodeId(canvas.nodes);
  1226. var n:TNode = {
  1227. id: node_id,
  1228. name: "Separate RGB",
  1229. type: "SEPRGB",
  1230. x: getNodeX(),
  1231. y: getNodeY(),
  1232. color: 0xff4982a0,
  1233. inputs: [
  1234. {
  1235. id: nodes.getSocketId(canvas.nodes),
  1236. node_id: node_id,
  1237. name: "Color",
  1238. type: "RGBA",
  1239. color: 0xffc7c729,
  1240. default_value: [0.8, 0.8, 0.8]
  1241. }
  1242. ],
  1243. outputs: [
  1244. {
  1245. id: nodes.getSocketId(canvas.nodes),
  1246. node_id: node_id,
  1247. name: "R",
  1248. type: "VALUE",
  1249. color: 0xffa1a1a1,
  1250. default_value: 0.0
  1251. },
  1252. {
  1253. id: nodes.getSocketId(canvas.nodes),
  1254. node_id: node_id,
  1255. name: "G",
  1256. type: "VALUE",
  1257. color: 0xffa1a1a1,
  1258. default_value: 0.0
  1259. },
  1260. {
  1261. id: nodes.getSocketId(canvas.nodes),
  1262. node_id: node_id,
  1263. name: "B",
  1264. type: "VALUE",
  1265. color: 0xffa1a1a1,
  1266. default_value: 0.0
  1267. }
  1268. ],
  1269. buttons: []
  1270. };
  1271. canvas.nodes.push(n);
  1272. nodes.nodeDrag = n;
  1273. nodes.nodeSelected = n;
  1274. }
  1275. if (ui.button("Separate XYZ")) {
  1276. var node_id = nodes.getNodeId(canvas.nodes);
  1277. var n:TNode = {
  1278. id: node_id,
  1279. name: "Separate XYZ",
  1280. type: "SEPXYZ",
  1281. x: getNodeX(),
  1282. y: getNodeY(),
  1283. color: 0xff4982a0,
  1284. inputs: [
  1285. {
  1286. id: nodes.getSocketId(canvas.nodes),
  1287. node_id: node_id,
  1288. name: "Vector",
  1289. type: "VECTOR",
  1290. color: 0xff6363c7,
  1291. default_value: [0.0, 0.0, 0.0]
  1292. }
  1293. ],
  1294. outputs: [
  1295. {
  1296. id: nodes.getSocketId(canvas.nodes),
  1297. node_id: node_id,
  1298. name: "X",
  1299. type: "VALUE",
  1300. color: 0xffa1a1a1,
  1301. default_value: 0.0
  1302. },
  1303. {
  1304. id: nodes.getSocketId(canvas.nodes),
  1305. node_id: node_id,
  1306. name: "Y",
  1307. type: "VALUE",
  1308. color: 0xffa1a1a1,
  1309. default_value: 0.0
  1310. },
  1311. {
  1312. id: nodes.getSocketId(canvas.nodes),
  1313. node_id: node_id,
  1314. name: "Z",
  1315. type: "VALUE",
  1316. color: 0xffa1a1a1,
  1317. default_value: 0.0
  1318. }
  1319. ],
  1320. buttons: []
  1321. };
  1322. canvas.nodes.push(n);
  1323. nodes.nodeDrag = n;
  1324. nodes.nodeSelected = n;
  1325. }
  1326. }
  1327. }
  1328. }