uv_map_node.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. function uv_map_node_init() {
  2. array_push(nodes_material_input, uv_map_node_def);
  3. map_set(parser_material_node_vectors, "UVMAP", uv_map_node_vector);
  4. }
  5. function uv_map_node_vector(node: ui_node_t, socket: ui_node_socket_t): string {
  6. node_shader_context_add_elem(parser_material_kong.context, "tex", "short2norm");
  7. let uv_map: i32 = node.buttons[0].default_value[0];
  8. if (uv_map == 1 && mesh_data_get_vertex_array(context_raw.paint_object.data, "tex1") != null) {
  9. node_shader_context_add_elem(parser_material_kong.context, "tex1", "short2norm");
  10. node_shader_add_out(parser_material_kong, "tex_coord1: float2");
  11. node_shader_write_vert(parser_material_kong, "output.tex_coord1 = input.tex1;");
  12. return "float3(input.tex_coord1.x, input.tex_coord1.y, 0.0)";
  13. }
  14. else {
  15. return "float3(tex_coord.x, tex_coord.y, 0.0)";
  16. }
  17. }
  18. let uv_map_node_def: ui_node_t = {
  19. id : 0,
  20. name : _tr("UV Map"),
  21. type : "UVMAP",
  22. x : 0,
  23. y : 0,
  24. color : 0xffb34f5a,
  25. inputs : [],
  26. outputs : [ {
  27. id : 0,
  28. node_id : 0,
  29. name : _tr("UV"),
  30. type : "VECTOR",
  31. color : 0xff6363c7,
  32. default_value : f32_array_create_xyz(0.0, 0.0, 0.0),
  33. min : 0.0,
  34. max : 1.0,
  35. precision : 100,
  36. display : 0
  37. } ],
  38. buttons : [
  39. {
  40. name : _tr("UV Map"),
  41. type : "ENUM",
  42. output : -1,
  43. default_value : f32_array_create_x(0),
  44. data : u8_array_create_from_string("uv0" + "\n" + "uv1"),
  45. min : 0.0,
  46. max : 1.0,
  47. precision : 100,
  48. height : 0
  49. }
  50. ],
  51. width : 0,
  52. flags : 0
  53. };