shader_graph.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*************************************************************************/
  2. /* shader_graph.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef SHADER_GRAPH_H
  30. #define SHADER_GRAPH_H
  31. #include "map.h"
  32. #if 0
  33. class Shader : public Resource {
  34. OBJ_TYPE( Shader, Resource );
  35. RES_BASE_EXTENSION("sgp");
  36. RID shader;
  37. Map<int,Point2> positions;
  38. uint64_t version;
  39. protected:
  40. bool _set(const StringName& p_name, const Variant& p_value);
  41. bool _get(const StringName& p_name,Variant &r_ret) const;
  42. void _get_property_list( List<PropertyInfo> *p_list) const;
  43. static void _bind_methods();
  44. Array _get_connections_helper() const;
  45. public:
  46. enum NodeType {
  47. NODE_IN, ///< param 0: name
  48. NODE_OUT, ///< param 0: name
  49. NODE_CONSTANT, ///< param 0: value
  50. NODE_PARAMETER, ///< param 0: name
  51. NODE_ADD,
  52. NODE_SUB,
  53. NODE_MUL,
  54. NODE_DIV,
  55. NODE_MOD,
  56. NODE_SIN,
  57. NODE_COS,
  58. NODE_TAN,
  59. NODE_ARCSIN,
  60. NODE_ARCCOS,
  61. NODE_ARCTAN,
  62. NODE_POW,
  63. NODE_LOG,
  64. NODE_MAX,
  65. NODE_MIN,
  66. NODE_COMPARE,
  67. NODE_TEXTURE, ///< param 0: texture
  68. NODE_TIME, ///< param 0: interval length
  69. NODE_NOISE,
  70. NODE_PASS,
  71. NODE_VEC_IN, ///< param 0: name
  72. NODE_VEC_OUT, ///< param 0: name
  73. NODE_VEC_CONSTANT, ///< param 0: value
  74. NODE_VEC_PARAMETER, ///< param 0: name
  75. NODE_VEC_ADD,
  76. NODE_VEC_SUB,
  77. NODE_VEC_MUL,
  78. NODE_VEC_DIV,
  79. NODE_VEC_MOD,
  80. NODE_VEC_CROSS,
  81. NODE_VEC_DOT,
  82. NODE_VEC_POW,
  83. NODE_VEC_NORMALIZE,
  84. NODE_VEC_INTERPOLATE,
  85. NODE_VEC_SCREEN_TO_UV,
  86. NODE_VEC_TRANSFORM3,
  87. NODE_VEC_TRANSFORM4,
  88. NODE_VEC_COMPARE,
  89. NODE_VEC_TEXTURE_2D,
  90. NODE_VEC_TEXTURE_CUBE,
  91. NODE_VEC_NOISE,
  92. NODE_VEC_0,
  93. NODE_VEC_1,
  94. NODE_VEC_2,
  95. NODE_VEC_BUILD,
  96. NODE_VEC_PASS,
  97. NODE_COLOR_CONSTANT,
  98. NODE_COLOR_PARAMETER,
  99. NODE_TEXTURE_PARAMETER,
  100. NODE_TEXTURE_2D_PARAMETER,
  101. NODE_TEXTURE_CUBE_PARAMETER,
  102. NODE_TRANSFORM_CONSTANT,
  103. NODE_TRANSFORM_PARAMETER,
  104. NODE_LABEL,
  105. NODE_TYPE_MAX
  106. };
  107. void node_add(NodeType p_type,int p_id);
  108. void node_remove(int p_id);
  109. void node_set_param( int p_id, const Variant& p_value);
  110. void node_set_pos(int p_id,const Point2& p_pos);
  111. Point2 node_get_pos(int p_id) const;
  112. void get_node_list(List<int> *p_node_list) const;
  113. NodeType node_get_type(int p_id) const;
  114. Variant node_get_param(int p_id) const;
  115. void connect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot);
  116. void disconnect(int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot);
  117. struct Connection {
  118. int src_id;
  119. int src_slot;
  120. int dst_id;
  121. int dst_slot;
  122. };
  123. void get_connections(List<Connection> *p_connections) const;
  124. void clear();
  125. virtual RID get_rid() const { return shader; }
  126. uint64_t get_version() const { return version; }
  127. Shader();
  128. ~Shader();
  129. };
  130. enum ShaderType {
  131. SHADER_VERTEX,
  132. SHADER_FRAGMENT,
  133. SHADER_POST_PROCESS
  134. };
  135. //helper functions
  136. static void shader_get_default_input_nodes(ShaderType p_type,List<PropertyInfo> *p_inputs);
  137. static void shader_get_default_output_nodes(ShaderType p_type,List<PropertyInfo> *p_outputs);
  138. static PropertyInfo shader_node_get_type_info(ShaderNodeType p_type);
  139. static int shader_get_input_count(ShaderNodeType p_type);
  140. static int shader_get_output_count(ShaderNodeType p_type);
  141. static String shader_get_input_name(ShaderNodeType p_type,int p_input);
  142. static String shader_get_output_name(ShaderNodeType p_type,int p_output);
  143. static bool shader_is_input_vector(ShaderNodeType p_type,int p_input);
  144. static bool shader_is_output_vector(ShaderNodeType p_type,int p_input);
  145. VARIANT_ENUM_CAST( Shader::NodeType );
  146. #endif
  147. #endif // SHADER_GRAPH_H