visual_shader_sdf_nodes.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /**************************************************************************/
  2. /* visual_shader_sdf_nodes.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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_SDF_NODES_H
  31. #define VISUAL_SHADER_SDF_NODES_H
  32. #include "scene/resources/visual_shader.h"
  33. class VisualShaderNodeSDFToScreenUV : public VisualShaderNode {
  34. GDCLASS(VisualShaderNodeSDFToScreenUV, VisualShaderNode);
  35. public:
  36. virtual String get_caption() const override;
  37. virtual int get_input_port_count() const override;
  38. virtual PortType get_input_port_type(int p_port) const override;
  39. virtual String get_input_port_name(int p_port) const override;
  40. virtual int get_output_port_count() const override;
  41. virtual PortType get_output_port_type(int p_port) const override;
  42. virtual String get_output_port_name(int p_port) const override;
  43. 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 override;
  44. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  45. VisualShaderNodeSDFToScreenUV();
  46. };
  47. class VisualShaderNodeScreenUVToSDF : public VisualShaderNode {
  48. GDCLASS(VisualShaderNodeScreenUVToSDF, VisualShaderNode);
  49. public:
  50. virtual String get_caption() const override;
  51. virtual int get_input_port_count() const override;
  52. virtual PortType get_input_port_type(int p_port) const override;
  53. virtual String get_input_port_name(int p_port) const override;
  54. virtual int get_output_port_count() const override;
  55. virtual PortType get_output_port_type(int p_port) const override;
  56. virtual String get_output_port_name(int p_port) const override;
  57. virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
  58. 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 override;
  59. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  60. VisualShaderNodeScreenUVToSDF();
  61. };
  62. class VisualShaderNodeTextureSDF : public VisualShaderNode {
  63. GDCLASS(VisualShaderNodeTextureSDF, VisualShaderNode);
  64. public:
  65. virtual String get_caption() const override;
  66. virtual int get_input_port_count() const override;
  67. virtual PortType get_input_port_type(int p_port) const override;
  68. virtual String get_input_port_name(int p_port) const override;
  69. virtual int get_output_port_count() const override;
  70. virtual PortType get_output_port_type(int p_port) const override;
  71. virtual String get_output_port_name(int p_port) const override;
  72. 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 override;
  73. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  74. VisualShaderNodeTextureSDF();
  75. };
  76. class VisualShaderNodeTextureSDFNormal : public VisualShaderNode {
  77. GDCLASS(VisualShaderNodeTextureSDFNormal, VisualShaderNode);
  78. public:
  79. virtual String get_caption() const override;
  80. virtual int get_input_port_count() const override;
  81. virtual PortType get_input_port_type(int p_port) const override;
  82. virtual String get_input_port_name(int p_port) const override;
  83. virtual int get_output_port_count() const override;
  84. virtual PortType get_output_port_type(int p_port) const override;
  85. virtual String get_output_port_name(int p_port) const override;
  86. 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 override;
  87. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  88. VisualShaderNodeTextureSDFNormal();
  89. };
  90. class VisualShaderNodeSDFRaymarch : public VisualShaderNode {
  91. GDCLASS(VisualShaderNodeSDFRaymarch, VisualShaderNode);
  92. public:
  93. virtual String get_caption() const override;
  94. virtual int get_input_port_count() const override;
  95. virtual PortType get_input_port_type(int p_port) const override;
  96. virtual String get_input_port_name(int p_port) const override;
  97. virtual int get_output_port_count() const override;
  98. virtual PortType get_output_port_type(int p_port) const override;
  99. virtual String get_output_port_name(int p_port) const override;
  100. 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 override;
  101. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  102. VisualShaderNodeSDFRaymarch();
  103. };
  104. #endif // VISUAL_SHADER_SDF_NODES_H