visual_shader_nodes.h 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. /*************************************************************************/
  2. /* visual_shader_nodes.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef VISUAL_SHADER_NODES_H
  31. #define VISUAL_SHADER_NODES_H
  32. #include "scene/resources/visual_shader.h"
  33. ///////////////////////////////////////
  34. /// CONSTANTS
  35. ///////////////////////////////////////
  36. class VisualShaderNodeScalarConstant : public VisualShaderNode {
  37. GDCLASS(VisualShaderNodeScalarConstant, VisualShaderNode);
  38. float constant;
  39. protected:
  40. static void _bind_methods();
  41. public:
  42. virtual String get_caption() const;
  43. virtual int get_input_port_count() const;
  44. virtual PortType get_input_port_type(int p_port) const;
  45. virtual String get_input_port_name(int p_port) const;
  46. virtual int get_output_port_count() const;
  47. virtual PortType get_output_port_type(int p_port) const;
  48. virtual String get_output_port_name(int p_port) const;
  49. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  50. void set_constant(float p_value);
  51. float get_constant() const;
  52. virtual Vector<StringName> get_editable_properties() const;
  53. VisualShaderNodeScalarConstant();
  54. };
  55. ///////////////////////////////////////
  56. class VisualShaderNodeBooleanConstant : public VisualShaderNode {
  57. GDCLASS(VisualShaderNodeBooleanConstant, VisualShaderNode);
  58. bool constant;
  59. protected:
  60. static void _bind_methods();
  61. public:
  62. virtual String get_caption() const;
  63. virtual int get_input_port_count() const;
  64. virtual PortType get_input_port_type(int p_port) const;
  65. virtual String get_input_port_name(int p_port) const;
  66. virtual int get_output_port_count() const;
  67. virtual PortType get_output_port_type(int p_port) const;
  68. virtual String get_output_port_name(int p_port) const;
  69. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  70. void set_constant(bool p_value);
  71. bool get_constant() const;
  72. virtual Vector<StringName> get_editable_properties() const;
  73. VisualShaderNodeBooleanConstant();
  74. };
  75. ///////////////////////////////////////
  76. class VisualShaderNodeColorConstant : public VisualShaderNode {
  77. GDCLASS(VisualShaderNodeColorConstant, VisualShaderNode);
  78. Color constant;
  79. protected:
  80. static void _bind_methods();
  81. public:
  82. virtual String get_caption() const;
  83. virtual int get_input_port_count() const;
  84. virtual PortType get_input_port_type(int p_port) const;
  85. virtual String get_input_port_name(int p_port) const;
  86. virtual int get_output_port_count() const;
  87. virtual PortType get_output_port_type(int p_port) const;
  88. virtual String get_output_port_name(int p_port) const;
  89. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  90. void set_constant(Color p_value);
  91. Color get_constant() const;
  92. virtual Vector<StringName> get_editable_properties() const;
  93. VisualShaderNodeColorConstant();
  94. };
  95. ///////////////////////////////////////
  96. class VisualShaderNodeVec3Constant : public VisualShaderNode {
  97. GDCLASS(VisualShaderNodeVec3Constant, VisualShaderNode);
  98. Vector3 constant;
  99. protected:
  100. static void _bind_methods();
  101. public:
  102. virtual String get_caption() const;
  103. virtual int get_input_port_count() const;
  104. virtual PortType get_input_port_type(int p_port) const;
  105. virtual String get_input_port_name(int p_port) const;
  106. virtual int get_output_port_count() const;
  107. virtual PortType get_output_port_type(int p_port) const;
  108. virtual String get_output_port_name(int p_port) const;
  109. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  110. void set_constant(Vector3 p_value);
  111. Vector3 get_constant() const;
  112. virtual Vector<StringName> get_editable_properties() const;
  113. VisualShaderNodeVec3Constant();
  114. };
  115. ///////////////////////////////////////
  116. class VisualShaderNodeTransformConstant : public VisualShaderNode {
  117. GDCLASS(VisualShaderNodeTransformConstant, VisualShaderNode);
  118. Transform constant;
  119. protected:
  120. static void _bind_methods();
  121. public:
  122. virtual String get_caption() const;
  123. virtual int get_input_port_count() const;
  124. virtual PortType get_input_port_type(int p_port) const;
  125. virtual String get_input_port_name(int p_port) const;
  126. virtual int get_output_port_count() const;
  127. virtual PortType get_output_port_type(int p_port) const;
  128. virtual String get_output_port_name(int p_port) const;
  129. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  130. void set_constant(Transform p_value);
  131. Transform get_constant() const;
  132. virtual Vector<StringName> get_editable_properties() const;
  133. VisualShaderNodeTransformConstant();
  134. };
  135. ///////////////////////////////////////
  136. /// TEXTURES
  137. ///////////////////////////////////////
  138. class VisualShaderNodeTexture : public VisualShaderNode {
  139. GDCLASS(VisualShaderNodeTexture, VisualShaderNode);
  140. Ref<Texture> texture;
  141. public:
  142. enum Source {
  143. SOURCE_TEXTURE,
  144. SOURCE_SCREEN,
  145. SOURCE_2D_TEXTURE,
  146. SOURCE_2D_NORMAL,
  147. SOURCE_DEPTH,
  148. SOURCE_PORT,
  149. };
  150. enum TextureType {
  151. TYPE_DATA,
  152. TYPE_COLOR,
  153. TYPE_NORMALMAP
  154. };
  155. private:
  156. Source source;
  157. TextureType texture_type;
  158. protected:
  159. static void _bind_methods();
  160. public:
  161. virtual String get_caption() const;
  162. virtual int get_input_port_count() const;
  163. virtual PortType get_input_port_type(int p_port) const;
  164. virtual String get_input_port_name(int p_port) const;
  165. virtual int get_output_port_count() const;
  166. virtual PortType get_output_port_type(int p_port) const;
  167. virtual String get_output_port_name(int p_port) const;
  168. virtual String get_input_port_default_hint(int p_port) const;
  169. virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const;
  170. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  171. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  172. void set_source(Source p_source);
  173. Source get_source() const;
  174. void set_texture(Ref<Texture> p_value);
  175. Ref<Texture> get_texture() const;
  176. void set_texture_type(TextureType p_type);
  177. TextureType get_texture_type() const;
  178. virtual Vector<StringName> get_editable_properties() const;
  179. virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const;
  180. VisualShaderNodeTexture();
  181. };
  182. VARIANT_ENUM_CAST(VisualShaderNodeTexture::TextureType)
  183. VARIANT_ENUM_CAST(VisualShaderNodeTexture::Source)
  184. ///////////////////////////////////////
  185. class VisualShaderNodeCubeMap : public VisualShaderNode {
  186. GDCLASS(VisualShaderNodeCubeMap, VisualShaderNode);
  187. Ref<CubeMap> cube_map;
  188. public:
  189. enum Source {
  190. SOURCE_TEXTURE,
  191. SOURCE_PORT
  192. };
  193. enum TextureType {
  194. TYPE_DATA,
  195. TYPE_COLOR,
  196. TYPE_NORMALMAP
  197. };
  198. private:
  199. Source source;
  200. TextureType texture_type;
  201. protected:
  202. static void _bind_methods();
  203. public:
  204. virtual String get_caption() const;
  205. virtual int get_input_port_count() const;
  206. virtual PortType get_input_port_type(int p_port) const;
  207. virtual String get_input_port_name(int p_port) const;
  208. virtual String get_input_port_default_hint(int p_port) const;
  209. virtual int get_output_port_count() const;
  210. virtual PortType get_output_port_type(int p_port) const;
  211. virtual String get_output_port_name(int p_port) const;
  212. virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const;
  213. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  214. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  215. void set_source(Source p_source);
  216. Source get_source() const;
  217. void set_cube_map(Ref<CubeMap> p_value);
  218. Ref<CubeMap> get_cube_map() const;
  219. void set_texture_type(TextureType p_type);
  220. TextureType get_texture_type() const;
  221. virtual Vector<StringName> get_editable_properties() const;
  222. VisualShaderNodeCubeMap();
  223. };
  224. VARIANT_ENUM_CAST(VisualShaderNodeCubeMap::TextureType)
  225. VARIANT_ENUM_CAST(VisualShaderNodeCubeMap::Source)
  226. ///////////////////////////////////////
  227. /// OPS
  228. ///////////////////////////////////////
  229. class VisualShaderNodeScalarOp : public VisualShaderNode {
  230. GDCLASS(VisualShaderNodeScalarOp, VisualShaderNode);
  231. public:
  232. enum Operator {
  233. OP_ADD,
  234. OP_SUB,
  235. OP_MUL,
  236. OP_DIV,
  237. OP_MOD,
  238. OP_POW,
  239. OP_MAX,
  240. OP_MIN,
  241. OP_ATAN2,
  242. OP_STEP
  243. };
  244. protected:
  245. Operator op;
  246. static void _bind_methods();
  247. public:
  248. virtual String get_caption() const;
  249. virtual int get_input_port_count() const;
  250. virtual PortType get_input_port_type(int p_port) const;
  251. virtual String get_input_port_name(int p_port) const;
  252. virtual int get_output_port_count() const;
  253. virtual PortType get_output_port_type(int p_port) const;
  254. virtual String get_output_port_name(int p_port) const;
  255. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  256. void set_operator(Operator p_op);
  257. Operator get_operator() const;
  258. virtual Vector<StringName> get_editable_properties() const;
  259. VisualShaderNodeScalarOp();
  260. };
  261. VARIANT_ENUM_CAST(VisualShaderNodeScalarOp::Operator)
  262. class VisualShaderNodeVectorOp : public VisualShaderNode {
  263. GDCLASS(VisualShaderNodeVectorOp, VisualShaderNode);
  264. public:
  265. enum Operator {
  266. OP_ADD,
  267. OP_SUB,
  268. OP_MUL,
  269. OP_DIV,
  270. OP_MOD,
  271. OP_POW,
  272. OP_MAX,
  273. OP_MIN,
  274. OP_CROSS,
  275. OP_ATAN2,
  276. OP_REFLECT,
  277. OP_STEP
  278. };
  279. protected:
  280. Operator op;
  281. static void _bind_methods();
  282. public:
  283. virtual String get_caption() const;
  284. virtual int get_input_port_count() const;
  285. virtual PortType get_input_port_type(int p_port) const;
  286. virtual String get_input_port_name(int p_port) const;
  287. virtual int get_output_port_count() const;
  288. virtual PortType get_output_port_type(int p_port) const;
  289. virtual String get_output_port_name(int p_port) const;
  290. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  291. void set_operator(Operator p_op);
  292. Operator get_operator() const;
  293. virtual Vector<StringName> get_editable_properties() const;
  294. VisualShaderNodeVectorOp();
  295. };
  296. VARIANT_ENUM_CAST(VisualShaderNodeVectorOp::Operator)
  297. ///////////////////////////////////////
  298. class VisualShaderNodeColorOp : public VisualShaderNode {
  299. GDCLASS(VisualShaderNodeColorOp, VisualShaderNode);
  300. public:
  301. enum Operator {
  302. OP_SCREEN,
  303. OP_DIFFERENCE,
  304. OP_DARKEN,
  305. OP_LIGHTEN,
  306. OP_OVERLAY,
  307. OP_DODGE,
  308. OP_BURN,
  309. OP_SOFT_LIGHT,
  310. OP_HARD_LIGHT
  311. };
  312. protected:
  313. Operator op;
  314. static void _bind_methods();
  315. public:
  316. virtual String get_caption() const;
  317. virtual int get_input_port_count() const;
  318. virtual PortType get_input_port_type(int p_port) const;
  319. virtual String get_input_port_name(int p_port) const;
  320. virtual int get_output_port_count() const;
  321. virtual PortType get_output_port_type(int p_port) const;
  322. virtual String get_output_port_name(int p_port) const;
  323. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  324. void set_operator(Operator p_op);
  325. Operator get_operator() const;
  326. virtual Vector<StringName> get_editable_properties() const;
  327. VisualShaderNodeColorOp();
  328. };
  329. VARIANT_ENUM_CAST(VisualShaderNodeColorOp::Operator)
  330. ///////////////////////////////////////
  331. /// TRANSFORM-TRANSFORM MULTIPLICATION
  332. ///////////////////////////////////////
  333. class VisualShaderNodeTransformMult : public VisualShaderNode {
  334. GDCLASS(VisualShaderNodeTransformMult, VisualShaderNode);
  335. public:
  336. enum Operator {
  337. OP_AxB,
  338. OP_BxA,
  339. OP_AxB_COMP,
  340. OP_BxA_COMP
  341. };
  342. protected:
  343. Operator op;
  344. static void _bind_methods();
  345. public:
  346. virtual String get_caption() const;
  347. virtual int get_input_port_count() const;
  348. virtual PortType get_input_port_type(int p_port) const;
  349. virtual String get_input_port_name(int p_port) const;
  350. virtual int get_output_port_count() const;
  351. virtual PortType get_output_port_type(int p_port) const;
  352. virtual String get_output_port_name(int p_port) const;
  353. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  354. void set_operator(Operator p_op);
  355. Operator get_operator() const;
  356. virtual Vector<StringName> get_editable_properties() const;
  357. VisualShaderNodeTransformMult();
  358. };
  359. VARIANT_ENUM_CAST(VisualShaderNodeTransformMult::Operator)
  360. ///////////////////////////////////////
  361. /// TRANSFORM-VECTOR MULTIPLICATION
  362. ///////////////////////////////////////
  363. class VisualShaderNodeTransformVecMult : public VisualShaderNode {
  364. GDCLASS(VisualShaderNodeTransformVecMult, VisualShaderNode);
  365. public:
  366. enum Operator {
  367. OP_AxB,
  368. OP_BxA,
  369. OP_3x3_AxB,
  370. OP_3x3_BxA,
  371. };
  372. protected:
  373. Operator op;
  374. static void _bind_methods();
  375. public:
  376. virtual String get_caption() const;
  377. virtual int get_input_port_count() const;
  378. virtual PortType get_input_port_type(int p_port) const;
  379. virtual String get_input_port_name(int p_port) const;
  380. virtual int get_output_port_count() const;
  381. virtual PortType get_output_port_type(int p_port) const;
  382. virtual String get_output_port_name(int p_port) const;
  383. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  384. void set_operator(Operator p_op);
  385. Operator get_operator() const;
  386. virtual Vector<StringName> get_editable_properties() const;
  387. VisualShaderNodeTransformVecMult();
  388. };
  389. VARIANT_ENUM_CAST(VisualShaderNodeTransformVecMult::Operator)
  390. ///////////////////////////////////////
  391. /// SCALAR FUNC
  392. ///////////////////////////////////////
  393. class VisualShaderNodeScalarFunc : public VisualShaderNode {
  394. GDCLASS(VisualShaderNodeScalarFunc, VisualShaderNode);
  395. public:
  396. enum Function {
  397. FUNC_SIN,
  398. FUNC_COS,
  399. FUNC_TAN,
  400. FUNC_ASIN,
  401. FUNC_ACOS,
  402. FUNC_ATAN,
  403. FUNC_SINH,
  404. FUNC_COSH,
  405. FUNC_TANH,
  406. FUNC_LOG,
  407. FUNC_EXP,
  408. FUNC_SQRT,
  409. FUNC_ABS,
  410. FUNC_SIGN,
  411. FUNC_FLOOR,
  412. FUNC_ROUND,
  413. FUNC_CEIL,
  414. FUNC_FRAC,
  415. FUNC_SATURATE,
  416. FUNC_NEGATE,
  417. FUNC_ACOSH,
  418. FUNC_ASINH,
  419. FUNC_ATANH,
  420. FUNC_DEGREES,
  421. FUNC_EXP2,
  422. FUNC_INVERSE_SQRT,
  423. FUNC_LOG2,
  424. FUNC_RADIANS,
  425. FUNC_RECIPROCAL,
  426. FUNC_ROUNDEVEN,
  427. FUNC_TRUNC,
  428. FUNC_ONEMINUS
  429. };
  430. protected:
  431. Function func;
  432. static void _bind_methods();
  433. public:
  434. virtual String get_caption() const;
  435. virtual int get_input_port_count() const;
  436. virtual PortType get_input_port_type(int p_port) const;
  437. virtual String get_input_port_name(int p_port) const;
  438. virtual int get_output_port_count() const;
  439. virtual PortType get_output_port_type(int p_port) const;
  440. virtual String get_output_port_name(int p_port) const;
  441. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  442. void set_function(Function p_func);
  443. Function get_function() const;
  444. virtual Vector<StringName> get_editable_properties() const;
  445. VisualShaderNodeScalarFunc();
  446. };
  447. VARIANT_ENUM_CAST(VisualShaderNodeScalarFunc::Function)
  448. ///////////////////////////////////////
  449. /// VECTOR FUNC
  450. ///////////////////////////////////////
  451. class VisualShaderNodeVectorFunc : public VisualShaderNode {
  452. GDCLASS(VisualShaderNodeVectorFunc, VisualShaderNode);
  453. public:
  454. enum Function {
  455. FUNC_NORMALIZE,
  456. FUNC_SATURATE,
  457. FUNC_NEGATE,
  458. FUNC_RECIPROCAL,
  459. FUNC_RGB2HSV,
  460. FUNC_HSV2RGB,
  461. FUNC_ABS,
  462. FUNC_ACOS,
  463. FUNC_ACOSH,
  464. FUNC_ASIN,
  465. FUNC_ASINH,
  466. FUNC_ATAN,
  467. FUNC_ATANH,
  468. FUNC_CEIL,
  469. FUNC_COS,
  470. FUNC_COSH,
  471. FUNC_DEGREES,
  472. FUNC_EXP,
  473. FUNC_EXP2,
  474. FUNC_FLOOR,
  475. FUNC_FRAC,
  476. FUNC_INVERSE_SQRT,
  477. FUNC_LOG,
  478. FUNC_LOG2,
  479. FUNC_RADIANS,
  480. FUNC_ROUND,
  481. FUNC_ROUNDEVEN,
  482. FUNC_SIGN,
  483. FUNC_SIN,
  484. FUNC_SINH,
  485. FUNC_SQRT,
  486. FUNC_TAN,
  487. FUNC_TANH,
  488. FUNC_TRUNC,
  489. FUNC_ONEMINUS
  490. };
  491. protected:
  492. Function func;
  493. static void _bind_methods();
  494. public:
  495. virtual String get_caption() const;
  496. virtual int get_input_port_count() const;
  497. virtual PortType get_input_port_type(int p_port) const;
  498. virtual String get_input_port_name(int p_port) const;
  499. virtual int get_output_port_count() const;
  500. virtual PortType get_output_port_type(int p_port) const;
  501. virtual String get_output_port_name(int p_port) const;
  502. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  503. void set_function(Function p_func);
  504. Function get_function() const;
  505. virtual Vector<StringName> get_editable_properties() const;
  506. VisualShaderNodeVectorFunc();
  507. };
  508. VARIANT_ENUM_CAST(VisualShaderNodeVectorFunc::Function)
  509. ///////////////////////////////////////
  510. /// COLOR FUNC
  511. ///////////////////////////////////////
  512. class VisualShaderNodeColorFunc : public VisualShaderNode {
  513. GDCLASS(VisualShaderNodeColorFunc, VisualShaderNode);
  514. public:
  515. enum Function {
  516. FUNC_GRAYSCALE,
  517. FUNC_SEPIA
  518. };
  519. protected:
  520. Function func;
  521. static void _bind_methods();
  522. public:
  523. virtual String get_caption() const;
  524. virtual int get_input_port_count() const;
  525. virtual PortType get_input_port_type(int p_port) const;
  526. virtual String get_input_port_name(int p_port) const;
  527. virtual int get_output_port_count() const;
  528. virtual PortType get_output_port_type(int p_port) const;
  529. virtual String get_output_port_name(int p_port) const;
  530. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  531. void set_function(Function p_func);
  532. Function get_function() const;
  533. virtual Vector<StringName> get_editable_properties() const;
  534. VisualShaderNodeColorFunc();
  535. };
  536. VARIANT_ENUM_CAST(VisualShaderNodeColorFunc::Function)
  537. ///////////////////////////////////////
  538. /// TRANSFORM FUNC
  539. ///////////////////////////////////////
  540. class VisualShaderNodeTransformFunc : public VisualShaderNode {
  541. GDCLASS(VisualShaderNodeTransformFunc, VisualShaderNode);
  542. public:
  543. enum Function {
  544. FUNC_INVERSE,
  545. FUNC_TRANSPOSE
  546. };
  547. protected:
  548. Function func;
  549. static void _bind_methods();
  550. public:
  551. virtual String get_caption() const;
  552. virtual int get_input_port_count() const;
  553. virtual PortType get_input_port_type(int p_port) const;
  554. virtual String get_input_port_name(int p_port) const;
  555. virtual int get_output_port_count() const;
  556. virtual PortType get_output_port_type(int p_port) const;
  557. virtual String get_output_port_name(int p_port) const;
  558. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  559. void set_function(Function p_func);
  560. Function get_function() const;
  561. virtual Vector<StringName> get_editable_properties() const;
  562. VisualShaderNodeTransformFunc();
  563. };
  564. VARIANT_ENUM_CAST(VisualShaderNodeTransformFunc::Function)
  565. ///////////////////////////////////////
  566. /// DOT
  567. ///////////////////////////////////////
  568. class VisualShaderNodeDotProduct : public VisualShaderNode {
  569. GDCLASS(VisualShaderNodeDotProduct, VisualShaderNode);
  570. public:
  571. virtual String get_caption() const;
  572. virtual int get_input_port_count() const;
  573. virtual PortType get_input_port_type(int p_port) const;
  574. virtual String get_input_port_name(int p_port) const;
  575. virtual int get_output_port_count() const;
  576. virtual PortType get_output_port_type(int p_port) const;
  577. virtual String get_output_port_name(int p_port) const;
  578. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  579. VisualShaderNodeDotProduct();
  580. };
  581. ///////////////////////////////////////
  582. /// LENGTH
  583. ///////////////////////////////////////
  584. class VisualShaderNodeVectorLen : public VisualShaderNode {
  585. GDCLASS(VisualShaderNodeVectorLen, VisualShaderNode);
  586. public:
  587. virtual String get_caption() const;
  588. virtual int get_input_port_count() const;
  589. virtual PortType get_input_port_type(int p_port) const;
  590. virtual String get_input_port_name(int p_port) const;
  591. virtual int get_output_port_count() const;
  592. virtual PortType get_output_port_type(int p_port) const;
  593. virtual String get_output_port_name(int p_port) const;
  594. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  595. VisualShaderNodeVectorLen();
  596. };
  597. ///////////////////////////////////////
  598. /// DETERMINANT
  599. ///////////////////////////////////////
  600. class VisualShaderNodeDeterminant : public VisualShaderNode {
  601. GDCLASS(VisualShaderNodeDeterminant, VisualShaderNode);
  602. public:
  603. virtual String get_caption() const;
  604. virtual int get_input_port_count() const;
  605. virtual PortType get_input_port_type(int p_port) const;
  606. virtual String get_input_port_name(int p_port) const;
  607. virtual int get_output_port_count() const;
  608. virtual PortType get_output_port_type(int p_port) const;
  609. virtual String get_output_port_name(int p_port) const;
  610. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  611. VisualShaderNodeDeterminant();
  612. };
  613. ///////////////////////////////////////
  614. /// CLAMP
  615. ///////////////////////////////////////
  616. class VisualShaderNodeScalarClamp : public VisualShaderNode {
  617. GDCLASS(VisualShaderNodeScalarClamp, VisualShaderNode);
  618. public:
  619. virtual String get_caption() const;
  620. virtual int get_input_port_count() const;
  621. virtual PortType get_input_port_type(int p_port) const;
  622. virtual String get_input_port_name(int p_port) const;
  623. virtual int get_output_port_count() const;
  624. virtual PortType get_output_port_type(int p_port) const;
  625. virtual String get_output_port_name(int p_port) const;
  626. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  627. VisualShaderNodeScalarClamp();
  628. };
  629. ///////////////////////////////////////
  630. class VisualShaderNodeVectorClamp : public VisualShaderNode {
  631. GDCLASS(VisualShaderNodeVectorClamp, VisualShaderNode);
  632. public:
  633. virtual String get_caption() const;
  634. virtual int get_input_port_count() const;
  635. virtual PortType get_input_port_type(int p_port) const;
  636. virtual String get_input_port_name(int p_port) const;
  637. virtual int get_output_port_count() const;
  638. virtual PortType get_output_port_type(int p_port) const;
  639. virtual String get_output_port_name(int p_port) const;
  640. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  641. VisualShaderNodeVectorClamp();
  642. };
  643. ///////////////////////////////////////
  644. /// DERIVATIVE FUNCTIONS
  645. ///////////////////////////////////////
  646. class VisualShaderNodeScalarDerivativeFunc : public VisualShaderNode {
  647. GDCLASS(VisualShaderNodeScalarDerivativeFunc, VisualShaderNode);
  648. public:
  649. enum Function {
  650. FUNC_SUM,
  651. FUNC_X,
  652. FUNC_Y
  653. };
  654. protected:
  655. Function func;
  656. static void _bind_methods();
  657. public:
  658. virtual String get_caption() const;
  659. virtual int get_input_port_count() const;
  660. virtual PortType get_input_port_type(int p_port) const;
  661. virtual String get_input_port_name(int p_port) const;
  662. virtual int get_output_port_count() const;
  663. virtual PortType get_output_port_type(int p_port) const;
  664. virtual String get_output_port_name(int p_port) const;
  665. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  666. void set_function(Function p_func);
  667. Function get_function() const;
  668. virtual Vector<StringName> get_editable_properties() const;
  669. VisualShaderNodeScalarDerivativeFunc();
  670. };
  671. VARIANT_ENUM_CAST(VisualShaderNodeScalarDerivativeFunc::Function)
  672. ///////////////////////////////////////
  673. class VisualShaderNodeVectorDerivativeFunc : public VisualShaderNode {
  674. GDCLASS(VisualShaderNodeVectorDerivativeFunc, VisualShaderNode);
  675. public:
  676. enum Function {
  677. FUNC_SUM,
  678. FUNC_X,
  679. FUNC_Y
  680. };
  681. protected:
  682. Function func;
  683. static void _bind_methods();
  684. public:
  685. virtual String get_caption() const;
  686. virtual int get_input_port_count() const;
  687. virtual PortType get_input_port_type(int p_port) const;
  688. virtual String get_input_port_name(int p_port) const;
  689. virtual int get_output_port_count() const;
  690. virtual PortType get_output_port_type(int p_port) const;
  691. virtual String get_output_port_name(int p_port) const;
  692. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  693. void set_function(Function p_func);
  694. Function get_function() const;
  695. virtual Vector<StringName> get_editable_properties() const;
  696. VisualShaderNodeVectorDerivativeFunc();
  697. };
  698. VARIANT_ENUM_CAST(VisualShaderNodeVectorDerivativeFunc::Function)
  699. ///////////////////////////////////////
  700. /// FACEFORWARD
  701. ///////////////////////////////////////
  702. class VisualShaderNodeFaceForward : public VisualShaderNode {
  703. GDCLASS(VisualShaderNodeFaceForward, VisualShaderNode);
  704. public:
  705. virtual String get_caption() const;
  706. virtual int get_input_port_count() const;
  707. virtual PortType get_input_port_type(int p_port) const;
  708. virtual String get_input_port_name(int p_port) const;
  709. virtual int get_output_port_count() const;
  710. virtual PortType get_output_port_type(int p_port) const;
  711. virtual String get_output_port_name(int p_port) const;
  712. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  713. VisualShaderNodeFaceForward();
  714. };
  715. ///////////////////////////////////////
  716. /// OUTER PRODUCT
  717. ///////////////////////////////////////
  718. class VisualShaderNodeOuterProduct : public VisualShaderNode {
  719. GDCLASS(VisualShaderNodeOuterProduct, VisualShaderNode);
  720. public:
  721. virtual String get_caption() const;
  722. virtual int get_input_port_count() const;
  723. virtual PortType get_input_port_type(int p_port) const;
  724. virtual String get_input_port_name(int p_port) const;
  725. virtual int get_output_port_count() const;
  726. virtual PortType get_output_port_type(int p_port) const;
  727. virtual String get_output_port_name(int p_port) const;
  728. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  729. VisualShaderNodeOuterProduct();
  730. };
  731. ///////////////////////////////////////
  732. /// STEP
  733. ///////////////////////////////////////
  734. class VisualShaderNodeVectorScalarStep : public VisualShaderNode {
  735. GDCLASS(VisualShaderNodeVectorScalarStep, VisualShaderNode);
  736. public:
  737. virtual String get_caption() const;
  738. virtual int get_input_port_count() const;
  739. virtual PortType get_input_port_type(int p_port) const;
  740. virtual String get_input_port_name(int p_port) const;
  741. virtual int get_output_port_count() const;
  742. virtual PortType get_output_port_type(int p_port) const;
  743. virtual String get_output_port_name(int p_port) const;
  744. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  745. VisualShaderNodeVectorScalarStep();
  746. };
  747. ///////////////////////////////////////
  748. /// SMOOTHSTEP
  749. ///////////////////////////////////////
  750. class VisualShaderNodeScalarSmoothStep : public VisualShaderNode {
  751. GDCLASS(VisualShaderNodeScalarSmoothStep, VisualShaderNode);
  752. public:
  753. virtual String get_caption() const;
  754. virtual int get_input_port_count() const;
  755. virtual PortType get_input_port_type(int p_port) const;
  756. virtual String get_input_port_name(int p_port) const;
  757. virtual int get_output_port_count() const;
  758. virtual PortType get_output_port_type(int p_port) const;
  759. virtual String get_output_port_name(int p_port) const;
  760. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  761. VisualShaderNodeScalarSmoothStep();
  762. };
  763. ///////////////////////////////////////
  764. class VisualShaderNodeVectorSmoothStep : public VisualShaderNode {
  765. GDCLASS(VisualShaderNodeVectorSmoothStep, VisualShaderNode);
  766. public:
  767. virtual String get_caption() const;
  768. virtual int get_input_port_count() const;
  769. virtual PortType get_input_port_type(int p_port) const;
  770. virtual String get_input_port_name(int p_port) const;
  771. virtual int get_output_port_count() const;
  772. virtual PortType get_output_port_type(int p_port) const;
  773. virtual String get_output_port_name(int p_port) const;
  774. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  775. VisualShaderNodeVectorSmoothStep();
  776. };
  777. ///////////////////////////////////////
  778. class VisualShaderNodeVectorScalarSmoothStep : public VisualShaderNode {
  779. GDCLASS(VisualShaderNodeVectorScalarSmoothStep, VisualShaderNode);
  780. public:
  781. virtual String get_caption() const;
  782. virtual int get_input_port_count() const;
  783. virtual PortType get_input_port_type(int p_port) const;
  784. virtual String get_input_port_name(int p_port) const;
  785. virtual int get_output_port_count() const;
  786. virtual PortType get_output_port_type(int p_port) const;
  787. virtual String get_output_port_name(int p_port) const;
  788. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  789. VisualShaderNodeVectorScalarSmoothStep();
  790. };
  791. ///////////////////////////////////////
  792. /// DISTANCE
  793. ///////////////////////////////////////
  794. class VisualShaderNodeVectorDistance : public VisualShaderNode {
  795. GDCLASS(VisualShaderNodeVectorDistance, VisualShaderNode);
  796. public:
  797. virtual String get_caption() const;
  798. virtual int get_input_port_count() const;
  799. virtual PortType get_input_port_type(int p_port) const;
  800. virtual String get_input_port_name(int p_port) const;
  801. virtual int get_output_port_count() const;
  802. virtual PortType get_output_port_type(int p_port) const;
  803. virtual String get_output_port_name(int p_port) const;
  804. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  805. VisualShaderNodeVectorDistance();
  806. };
  807. ///////////////////////////////////////
  808. /// REFRACT
  809. ///////////////////////////////////////
  810. class VisualShaderNodeVectorRefract : public VisualShaderNode {
  811. GDCLASS(VisualShaderNodeVectorRefract, VisualShaderNode);
  812. public:
  813. virtual String get_caption() const;
  814. virtual int get_input_port_count() const;
  815. virtual PortType get_input_port_type(int p_port) const;
  816. virtual String get_input_port_name(int p_port) const;
  817. virtual int get_output_port_count() const;
  818. virtual PortType get_output_port_type(int p_port) const;
  819. virtual String get_output_port_name(int p_port) const;
  820. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  821. VisualShaderNodeVectorRefract();
  822. };
  823. ///////////////////////////////////////
  824. /// MIX
  825. ///////////////////////////////////////
  826. class VisualShaderNodeScalarInterp : public VisualShaderNode {
  827. GDCLASS(VisualShaderNodeScalarInterp, VisualShaderNode);
  828. public:
  829. virtual String get_caption() const;
  830. virtual int get_input_port_count() const;
  831. virtual PortType get_input_port_type(int p_port) const;
  832. virtual String get_input_port_name(int p_port) const;
  833. virtual int get_output_port_count() const;
  834. virtual PortType get_output_port_type(int p_port) const;
  835. virtual String get_output_port_name(int p_port) const;
  836. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  837. VisualShaderNodeScalarInterp();
  838. };
  839. ///////////////////////////////////////
  840. class VisualShaderNodeVectorInterp : public VisualShaderNode {
  841. GDCLASS(VisualShaderNodeVectorInterp, VisualShaderNode);
  842. public:
  843. virtual String get_caption() const;
  844. virtual int get_input_port_count() const;
  845. virtual PortType get_input_port_type(int p_port) const;
  846. virtual String get_input_port_name(int p_port) const;
  847. virtual int get_output_port_count() const;
  848. virtual PortType get_output_port_type(int p_port) const;
  849. virtual String get_output_port_name(int p_port) const;
  850. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  851. VisualShaderNodeVectorInterp();
  852. };
  853. ///////////////////////////////////////
  854. class VisualShaderNodeVectorScalarMix : public VisualShaderNode {
  855. GDCLASS(VisualShaderNodeVectorScalarMix, VisualShaderNode);
  856. public:
  857. virtual String get_caption() const;
  858. virtual int get_input_port_count() const;
  859. virtual PortType get_input_port_type(int p_port) const;
  860. virtual String get_input_port_name(int p_port) const;
  861. virtual int get_output_port_count() const;
  862. virtual PortType get_output_port_type(int p_port) const;
  863. virtual String get_output_port_name(int p_port) const;
  864. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  865. VisualShaderNodeVectorScalarMix();
  866. };
  867. ///////////////////////////////////////
  868. /// COMPOSE
  869. ///////////////////////////////////////
  870. class VisualShaderNodeVectorCompose : public VisualShaderNode {
  871. GDCLASS(VisualShaderNodeVectorCompose, VisualShaderNode);
  872. public:
  873. virtual String get_caption() const;
  874. virtual int get_input_port_count() const;
  875. virtual PortType get_input_port_type(int p_port) const;
  876. virtual String get_input_port_name(int p_port) const;
  877. virtual int get_output_port_count() const;
  878. virtual PortType get_output_port_type(int p_port) const;
  879. virtual String get_output_port_name(int p_port) const;
  880. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  881. VisualShaderNodeVectorCompose();
  882. };
  883. ///////////////////////////////////////
  884. class VisualShaderNodeTransformCompose : public VisualShaderNode {
  885. GDCLASS(VisualShaderNodeTransformCompose, VisualShaderNode);
  886. public:
  887. virtual String get_caption() const;
  888. virtual int get_input_port_count() const;
  889. virtual PortType get_input_port_type(int p_port) const;
  890. virtual String get_input_port_name(int p_port) const;
  891. virtual int get_output_port_count() const;
  892. virtual PortType get_output_port_type(int p_port) const;
  893. virtual String get_output_port_name(int p_port) const;
  894. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  895. VisualShaderNodeTransformCompose();
  896. };
  897. ///////////////////////////////////////
  898. /// DECOMPOSE
  899. ///////////////////////////////////////
  900. class VisualShaderNodeVectorDecompose : public VisualShaderNode {
  901. GDCLASS(VisualShaderNodeVectorDecompose, VisualShaderNode);
  902. public:
  903. virtual String get_caption() const;
  904. virtual int get_input_port_count() const;
  905. virtual PortType get_input_port_type(int p_port) const;
  906. virtual String get_input_port_name(int p_port) const;
  907. virtual int get_output_port_count() const;
  908. virtual PortType get_output_port_type(int p_port) const;
  909. virtual String get_output_port_name(int p_port) const;
  910. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  911. VisualShaderNodeVectorDecompose();
  912. };
  913. ///////////////////////////////////////
  914. class VisualShaderNodeTransformDecompose : public VisualShaderNode {
  915. GDCLASS(VisualShaderNodeTransformDecompose, VisualShaderNode);
  916. public:
  917. virtual String get_caption() const;
  918. virtual int get_input_port_count() const;
  919. virtual PortType get_input_port_type(int p_port) const;
  920. virtual String get_input_port_name(int p_port) const;
  921. virtual int get_output_port_count() const;
  922. virtual PortType get_output_port_type(int p_port) const;
  923. virtual String get_output_port_name(int p_port) const;
  924. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  925. VisualShaderNodeTransformDecompose();
  926. };
  927. ///////////////////////////////////////
  928. /// UNIFORMS
  929. ///////////////////////////////////////
  930. class VisualShaderNodeScalarUniform : public VisualShaderNodeUniform {
  931. GDCLASS(VisualShaderNodeScalarUniform, VisualShaderNodeUniform);
  932. public:
  933. virtual String get_caption() const;
  934. virtual int get_input_port_count() const;
  935. virtual PortType get_input_port_type(int p_port) const;
  936. virtual String get_input_port_name(int p_port) const;
  937. virtual int get_output_port_count() const;
  938. virtual PortType get_output_port_type(int p_port) const;
  939. virtual String get_output_port_name(int p_port) const;
  940. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  941. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  942. VisualShaderNodeScalarUniform();
  943. };
  944. ///////////////////////////////////////
  945. class VisualShaderNodeBooleanUniform : public VisualShaderNodeUniform {
  946. GDCLASS(VisualShaderNodeBooleanUniform, VisualShaderNodeUniform);
  947. public:
  948. virtual String get_caption() const;
  949. virtual int get_input_port_count() const;
  950. virtual PortType get_input_port_type(int p_port) const;
  951. virtual String get_input_port_name(int p_port) const;
  952. virtual int get_output_port_count() const;
  953. virtual PortType get_output_port_type(int p_port) const;
  954. virtual String get_output_port_name(int p_port) const;
  955. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  956. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  957. VisualShaderNodeBooleanUniform();
  958. };
  959. ///////////////////////////////////////
  960. class VisualShaderNodeColorUniform : public VisualShaderNodeUniform {
  961. GDCLASS(VisualShaderNodeColorUniform, VisualShaderNodeUniform);
  962. public:
  963. virtual String get_caption() const;
  964. virtual int get_input_port_count() const;
  965. virtual PortType get_input_port_type(int p_port) const;
  966. virtual String get_input_port_name(int p_port) const;
  967. virtual int get_output_port_count() const;
  968. virtual PortType get_output_port_type(int p_port) const;
  969. virtual String get_output_port_name(int p_port) const;
  970. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  971. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  972. VisualShaderNodeColorUniform();
  973. };
  974. ///////////////////////////////////////
  975. class VisualShaderNodeVec3Uniform : public VisualShaderNodeUniform {
  976. GDCLASS(VisualShaderNodeVec3Uniform, VisualShaderNodeUniform);
  977. public:
  978. virtual String get_caption() const;
  979. virtual int get_input_port_count() const;
  980. virtual PortType get_input_port_type(int p_port) const;
  981. virtual String get_input_port_name(int p_port) const;
  982. virtual int get_output_port_count() const;
  983. virtual PortType get_output_port_type(int p_port) const;
  984. virtual String get_output_port_name(int p_port) const;
  985. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  986. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  987. VisualShaderNodeVec3Uniform();
  988. };
  989. ///////////////////////////////////////
  990. class VisualShaderNodeTransformUniform : public VisualShaderNodeUniform {
  991. GDCLASS(VisualShaderNodeTransformUniform, VisualShaderNodeUniform);
  992. public:
  993. virtual String get_caption() const;
  994. virtual int get_input_port_count() const;
  995. virtual PortType get_input_port_type(int p_port) const;
  996. virtual String get_input_port_name(int p_port) const;
  997. virtual int get_output_port_count() const;
  998. virtual PortType get_output_port_type(int p_port) const;
  999. virtual String get_output_port_name(int p_port) const;
  1000. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  1001. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  1002. VisualShaderNodeTransformUniform();
  1003. };
  1004. ///////////////////////////////////////
  1005. class VisualShaderNodeTextureUniform : public VisualShaderNodeUniform {
  1006. GDCLASS(VisualShaderNodeTextureUniform, VisualShaderNodeUniform);
  1007. public:
  1008. enum TextureType {
  1009. TYPE_DATA,
  1010. TYPE_COLOR,
  1011. TYPE_NORMALMAP,
  1012. TYPE_ANISO,
  1013. };
  1014. enum ColorDefault {
  1015. COLOR_DEFAULT_WHITE,
  1016. COLOR_DEFAULT_BLACK
  1017. };
  1018. protected:
  1019. TextureType texture_type;
  1020. ColorDefault color_default;
  1021. protected:
  1022. static void _bind_methods();
  1023. public:
  1024. virtual String get_caption() const;
  1025. virtual int get_input_port_count() const;
  1026. virtual PortType get_input_port_type(int p_port) const;
  1027. virtual String get_input_port_name(int p_port) const;
  1028. virtual String get_input_port_default_hint(int p_port) const;
  1029. virtual int get_output_port_count() const;
  1030. virtual PortType get_output_port_type(int p_port) const;
  1031. virtual String get_output_port_name(int p_port) const;
  1032. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  1033. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  1034. Vector<StringName> get_editable_properties() const;
  1035. void set_texture_type(TextureType p_type);
  1036. TextureType get_texture_type() const;
  1037. void set_color_default(ColorDefault p_default);
  1038. ColorDefault get_color_default() const;
  1039. VisualShaderNodeTextureUniform();
  1040. };
  1041. VARIANT_ENUM_CAST(VisualShaderNodeTextureUniform::TextureType)
  1042. VARIANT_ENUM_CAST(VisualShaderNodeTextureUniform::ColorDefault)
  1043. ///////////////////////////////////////
  1044. class VisualShaderNodeTextureUniformTriplanar : public VisualShaderNodeTextureUniform {
  1045. GDCLASS(VisualShaderNodeTextureUniformTriplanar, VisualShaderNodeTextureUniform);
  1046. public:
  1047. virtual String get_caption() const;
  1048. virtual int get_input_port_count() const;
  1049. virtual PortType get_input_port_type(int p_port) const;
  1050. virtual String get_input_port_name(int p_port) const;
  1051. virtual String get_input_port_default_hint(int p_port) const;
  1052. virtual String generate_global_per_node(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  1053. virtual String generate_global_per_func(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  1054. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  1055. VisualShaderNodeTextureUniformTriplanar();
  1056. };
  1057. ///////////////////////////////////////
  1058. class VisualShaderNodeCubeMapUniform : public VisualShaderNodeTextureUniform {
  1059. GDCLASS(VisualShaderNodeCubeMapUniform, VisualShaderNodeTextureUniform);
  1060. public:
  1061. virtual String get_caption() const;
  1062. virtual int get_input_port_count() const;
  1063. virtual PortType get_input_port_type(int p_port) const;
  1064. virtual String get_input_port_name(int p_port) const;
  1065. virtual int get_output_port_count() const;
  1066. virtual PortType get_output_port_type(int p_port) const;
  1067. virtual String get_output_port_name(int p_port) const;
  1068. virtual String get_input_port_default_hint(int p_port) const;
  1069. virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
  1070. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  1071. VisualShaderNodeCubeMapUniform();
  1072. };
  1073. ///////////////////////////////////////
  1074. /// IF
  1075. ///////////////////////////////////////
  1076. class VisualShaderNodeIf : public VisualShaderNode {
  1077. GDCLASS(VisualShaderNodeIf, VisualShaderNode);
  1078. public:
  1079. virtual String get_caption() const;
  1080. virtual int get_input_port_count() const;
  1081. virtual PortType get_input_port_type(int p_port) const;
  1082. virtual String get_input_port_name(int p_port) const;
  1083. virtual int get_output_port_count() const;
  1084. virtual PortType get_output_port_type(int p_port) const;
  1085. virtual String get_output_port_name(int p_port) const;
  1086. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
  1087. VisualShaderNodeIf();
  1088. };
  1089. ///////////////////////////////////////
  1090. /// SWITCH
  1091. ///////////////////////////////////////
  1092. class VisualShaderNodeSwitch : public VisualShaderNode {
  1093. GDCLASS(VisualShaderNodeSwitch, VisualShaderNode);
  1094. public:
  1095. virtual String get_caption() const;
  1096. virtual int get_input_port_count() const;
  1097. virtual PortType get_input_port_type(int p_port) const;
  1098. virtual String get_input_port_name(int p_port) const;
  1099. virtual int get_output_port_count() const;
  1100. virtual PortType get_output_port_type(int p_port) const;
  1101. virtual String get_output_port_name(int p_port) const;
  1102. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
  1103. VisualShaderNodeSwitch();
  1104. };
  1105. class VisualShaderNodeScalarSwitch : public VisualShaderNodeSwitch {
  1106. GDCLASS(VisualShaderNodeScalarSwitch, VisualShaderNodeSwitch);
  1107. public:
  1108. virtual String get_caption() const;
  1109. virtual PortType get_input_port_type(int p_port) const;
  1110. virtual PortType get_output_port_type(int p_port) const;
  1111. VisualShaderNodeScalarSwitch();
  1112. };
  1113. ///////////////////////////////////////
  1114. /// FRESNEL
  1115. ///////////////////////////////////////
  1116. class VisualShaderNodeFresnel : public VisualShaderNode {
  1117. GDCLASS(VisualShaderNodeFresnel, VisualShaderNode);
  1118. public:
  1119. virtual String get_caption() const;
  1120. virtual int get_input_port_count() const;
  1121. virtual PortType get_input_port_type(int p_port) const;
  1122. virtual String get_input_port_name(int p_port) const;
  1123. virtual int get_output_port_count() const;
  1124. virtual PortType get_output_port_type(int p_port) const;
  1125. virtual String get_output_port_name(int p_port) const;
  1126. virtual String get_input_port_default_hint(int p_port) const;
  1127. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
  1128. VisualShaderNodeFresnel();
  1129. };
  1130. ///////////////////////////////////////
  1131. /// Is
  1132. ///////////////////////////////////////
  1133. class VisualShaderNodeIs : public VisualShaderNode {
  1134. GDCLASS(VisualShaderNodeIs, VisualShaderNode);
  1135. public:
  1136. enum Function {
  1137. FUNC_IS_INF,
  1138. FUNC_IS_NAN,
  1139. };
  1140. protected:
  1141. Function func;
  1142. protected:
  1143. static void _bind_methods();
  1144. public:
  1145. virtual String get_caption() const;
  1146. virtual int get_input_port_count() const;
  1147. virtual PortType get_input_port_type(int p_port) const;
  1148. virtual String get_input_port_name(int p_port) const;
  1149. virtual int get_output_port_count() const;
  1150. virtual PortType get_output_port_type(int p_port) const;
  1151. virtual String get_output_port_name(int p_port) const;
  1152. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  1153. void set_function(Function p_func);
  1154. Function get_function() const;
  1155. virtual Vector<StringName> get_editable_properties() const;
  1156. VisualShaderNodeIs();
  1157. };
  1158. VARIANT_ENUM_CAST(VisualShaderNodeIs::Function)
  1159. ///////////////////////////////////////
  1160. /// Compare
  1161. ///////////////////////////////////////
  1162. class VisualShaderNodeCompare : public VisualShaderNode {
  1163. GDCLASS(VisualShaderNodeCompare, VisualShaderNode);
  1164. public:
  1165. enum ComparisonType {
  1166. CTYPE_SCALAR,
  1167. CTYPE_VECTOR,
  1168. CTYPE_BOOLEAN,
  1169. CTYPE_TRANSFORM
  1170. };
  1171. enum Function {
  1172. FUNC_EQUAL,
  1173. FUNC_NOT_EQUAL,
  1174. FUNC_GREATER_THAN,
  1175. FUNC_GREATER_THAN_EQUAL,
  1176. FUNC_LESS_THAN,
  1177. FUNC_LESS_THAN_EQUAL,
  1178. };
  1179. enum Condition {
  1180. COND_ALL,
  1181. COND_ANY,
  1182. };
  1183. protected:
  1184. ComparisonType ctype;
  1185. Function func;
  1186. Condition condition;
  1187. protected:
  1188. static void _bind_methods();
  1189. public:
  1190. virtual String get_caption() const;
  1191. virtual int get_input_port_count() const;
  1192. virtual PortType get_input_port_type(int p_port) const;
  1193. virtual String get_input_port_name(int p_port) const;
  1194. virtual int get_output_port_count() const;
  1195. virtual PortType get_output_port_type(int p_port) const;
  1196. virtual String get_output_port_name(int p_port) const;
  1197. virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
  1198. void set_comparison_type(ComparisonType p_type);
  1199. ComparisonType get_comparison_type() const;
  1200. void set_function(Function p_func);
  1201. Function get_function() const;
  1202. void set_condition(Condition p_cond);
  1203. Condition get_condition() const;
  1204. virtual Vector<StringName> get_editable_properties() const;
  1205. virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const;
  1206. VisualShaderNodeCompare();
  1207. };
  1208. VARIANT_ENUM_CAST(VisualShaderNodeCompare::ComparisonType)
  1209. VARIANT_ENUM_CAST(VisualShaderNodeCompare::Function)
  1210. VARIANT_ENUM_CAST(VisualShaderNodeCompare::Condition)
  1211. #endif // VISUAL_SHADER_NODES_H