normal_node.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function normal_node_init() {
  2. array_push(nodes_material_utilities, normal_node_def);
  3. map_set(parser_material_node_vectors, "NORMAL", normal_node_vector);
  4. map_set(parser_material_node_values, "NORMAL", normal_node_value);
  5. }
  6. function normal_node_vector(node: ui_node_t, socket: ui_node_socket_t): string {
  7. return parser_material_vec3(node.outputs[0].default_value);
  8. }
  9. function normal_node_value(node: ui_node_t, socket: ui_node_socket_t): string {
  10. let nor: string = parser_material_parse_vector_input(node.inputs[0]);
  11. let norout: string = parser_material_vec3(node.outputs[0].default_value);
  12. return "dot(" + norout + ", " + nor + ")";
  13. }
  14. let normal_node_def: ui_node_t = {
  15. id : 0,
  16. name : _tr("Normal"),
  17. type : "NORMAL",
  18. x : 0,
  19. y : 0,
  20. color : 0xff522c99,
  21. inputs : [ {
  22. id : 0,
  23. node_id : 0,
  24. name : _tr("Normal"),
  25. type : "VECTOR",
  26. color : 0xff6363c7,
  27. default_value : f32_array_create_xyz(0.0, 0.0, 0.0),
  28. min : 0.0,
  29. max : 1.0,
  30. precision : 100,
  31. display : 0
  32. } ],
  33. outputs : [
  34. {
  35. id : 0,
  36. node_id : 0,
  37. name : _tr("Normal"),
  38. type : "VECTOR",
  39. color : 0xff6363c7,
  40. default_value : f32_array_create_xyz(0.0, 0.0, 0.0),
  41. min : 0.0,
  42. max : 1.0,
  43. precision : 100,
  44. display : 0
  45. },
  46. {
  47. id : 0,
  48. node_id : 0,
  49. name : _tr("Dot"),
  50. type : "VALUE",
  51. color : 0xffa1a1a1,
  52. default_value : f32_array_create_x(1.0),
  53. min : 0.0,
  54. max : 1.0,
  55. precision : 100,
  56. display : 0
  57. }
  58. ],
  59. buttons : [ {
  60. name : _tr("Vector"),
  61. type : "VECTOR",
  62. output : 0,
  63. default_value : f32_array_create_xyz(0.0, 0.0, 0.0),
  64. data : null,
  65. min : 0.0,
  66. max : 1.0,
  67. precision : 100,
  68. height : 0
  69. } ],
  70. width : 0,
  71. flags : 0
  72. };