picker_node.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. function picker_node_init() {
  2. array_push(nodes_material_input, picker_node_def);
  3. map_set(parser_material_node_vectors, "PICKER", picker_node_vector);
  4. map_set(parser_material_node_values, "PICKER", picker_node_value);
  5. }
  6. function picker_node_vector(node: ui_node_t, socket: ui_node_socket_t): string {
  7. if (socket == node.outputs[0]) { // Base
  8. node_shader_add_constant(parser_material_kong, "picker_base: float3", "_picker_base");
  9. return "constants.picker_base";
  10. }
  11. else { // Normal
  12. node_shader_add_constant(parser_material_kong, "picker_normal: float3", "_picker_normal");
  13. return "constants.picker_normal";
  14. }
  15. }
  16. function picker_node_value(node: ui_node_t, socket: ui_node_socket_t): string {
  17. if (socket == node.outputs[1]) {
  18. node_shader_add_constant(parser_material_kong, "picker_opacity: float", "_picker_opacity");
  19. return "constants.picker_opacity";
  20. }
  21. else if (socket == node.outputs[2]) {
  22. node_shader_add_constant(parser_material_kong, "picker_occlusion: float", "_picker_occlusion");
  23. return "constants.picker_occlusion";
  24. }
  25. else if (socket == node.outputs[3]) {
  26. node_shader_add_constant(parser_material_kong, "picker_roughness: float", "_picker_roughness");
  27. return "constants.picker_roughness";
  28. }
  29. else if (socket == node.outputs[4]) {
  30. node_shader_add_constant(parser_material_kong, "picker_metallic: float", "_picker_metallic");
  31. return "constants.picker_metallic";
  32. }
  33. else if (socket == node.outputs[6]) {
  34. return "0.0";
  35. } // Emission
  36. else if (socket == node.outputs[7]) {
  37. node_shader_add_constant(parser_material_kong, "picker_height: float", "_picker_height");
  38. return "constants.picker_height";
  39. }
  40. else {
  41. return "0.0";
  42. } // Subsurface
  43. }
  44. let picker_node_def: ui_node_t = {
  45. id : 0,
  46. name : _tr("Picker"),
  47. type : "PICKER", // extension
  48. x : 0,
  49. y : 0,
  50. color : 0xff4982a0,
  51. inputs : [],
  52. outputs : [
  53. {
  54. id : 0,
  55. node_id : 0,
  56. name : _tr("Base Color"),
  57. type : "RGBA",
  58. color : 0xffc7c729,
  59. default_value : f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0),
  60. min : 0.0,
  61. max : 1.0,
  62. precision : 100,
  63. display : 0
  64. },
  65. {
  66. id : 0,
  67. node_id : 0,
  68. name : _tr("Opacity"),
  69. type : "VALUE",
  70. color : 0xffa1a1a1,
  71. default_value : f32_array_create_x(1.0),
  72. min : 0.0,
  73. max : 1.0,
  74. precision : 100,
  75. display : 0
  76. },
  77. {
  78. id : 0,
  79. node_id : 0,
  80. name : _tr("Occlusion"),
  81. type : "VALUE",
  82. color : 0xffa1a1a1,
  83. default_value : f32_array_create_x(1.0),
  84. min : 0.0,
  85. max : 1.0,
  86. precision : 100,
  87. display : 0
  88. },
  89. {
  90. id : 0,
  91. node_id : 0,
  92. name : _tr("Roughness"),
  93. type : "VALUE",
  94. color : 0xffa1a1a1,
  95. default_value : f32_array_create_x(1.0),
  96. min : 0.0,
  97. max : 1.0,
  98. precision : 100,
  99. display : 0
  100. },
  101. {
  102. id : 0,
  103. node_id : 0,
  104. name : _tr("Metallic"),
  105. type : "VALUE",
  106. color : 0xffa1a1a1,
  107. default_value : f32_array_create_x(1.0),
  108. min : 0.0,
  109. max : 1.0,
  110. precision : 100,
  111. display : 0
  112. },
  113. {
  114. id : 0,
  115. node_id : 0,
  116. name : _tr("Normal Map"),
  117. type : "VECTOR",
  118. color : -10238109,
  119. default_value : f32_array_create_xyz(0.5, 0.5, 1.0),
  120. min : 0.0,
  121. max : 1.0,
  122. precision : 100,
  123. display : 0
  124. },
  125. {
  126. id : 0,
  127. node_id : 0,
  128. name : _tr("Emission"),
  129. type : "VALUE",
  130. color : 0xffa1a1a1,
  131. default_value : f32_array_create_x(1.0),
  132. min : 0.0,
  133. max : 1.0,
  134. precision : 100,
  135. display : 0
  136. },
  137. {
  138. id : 0,
  139. node_id : 0,
  140. name : _tr("Height"),
  141. type : "VALUE",
  142. color : 0xffa1a1a1,
  143. default_value : f32_array_create_x(1.0),
  144. min : 0.0,
  145. max : 1.0,
  146. precision : 100,
  147. display : 0
  148. },
  149. {
  150. id : 0,
  151. node_id : 0,
  152. name : _tr("Subsurface"),
  153. type : "VALUE",
  154. color : 0xffa1a1a1,
  155. default_value : f32_array_create_x(1.0),
  156. min : 0.0,
  157. max : 1.0,
  158. precision : 100,
  159. display : 0
  160. }
  161. ],
  162. buttons : [],
  163. width : 0,
  164. flags : 0
  165. };