visual_shader_sdf_nodes.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. #pragma once
  31. #include "scene/resources/visual_shader.h"
  32. class VisualShaderNodeSDFToScreenUV : public VisualShaderNode {
  33. GDCLASS(VisualShaderNodeSDFToScreenUV, VisualShaderNode);
  34. public:
  35. virtual String get_caption() const override;
  36. virtual int get_input_port_count() const override;
  37. virtual PortType get_input_port_type(int p_port) const override;
  38. virtual String get_input_port_name(int p_port) const override;
  39. virtual int get_output_port_count() const override;
  40. virtual PortType get_output_port_type(int p_port) const override;
  41. virtual String get_output_port_name(int p_port) const override;
  42. 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;
  43. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  44. VisualShaderNodeSDFToScreenUV();
  45. };
  46. class VisualShaderNodeScreenUVToSDF : public VisualShaderNode {
  47. GDCLASS(VisualShaderNodeScreenUVToSDF, VisualShaderNode);
  48. public:
  49. virtual String get_caption() const override;
  50. virtual int get_input_port_count() const override;
  51. virtual PortType get_input_port_type(int p_port) const override;
  52. virtual String get_input_port_name(int p_port) const override;
  53. virtual int get_output_port_count() const override;
  54. virtual PortType get_output_port_type(int p_port) const override;
  55. virtual String get_output_port_name(int p_port) const override;
  56. virtual bool is_input_port_default(int p_port, Shader::Mode p_mode) const override;
  57. 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;
  58. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  59. VisualShaderNodeScreenUVToSDF();
  60. };
  61. class VisualShaderNodeTextureSDF : public VisualShaderNode {
  62. GDCLASS(VisualShaderNodeTextureSDF, VisualShaderNode);
  63. public:
  64. virtual String get_caption() const override;
  65. virtual int get_input_port_count() const override;
  66. virtual PortType get_input_port_type(int p_port) const override;
  67. virtual String get_input_port_name(int p_port) const override;
  68. virtual int get_output_port_count() const override;
  69. virtual PortType get_output_port_type(int p_port) const override;
  70. virtual String get_output_port_name(int p_port) const override;
  71. 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;
  72. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  73. VisualShaderNodeTextureSDF();
  74. };
  75. class VisualShaderNodeTextureSDFNormal : public VisualShaderNode {
  76. GDCLASS(VisualShaderNodeTextureSDFNormal, VisualShaderNode);
  77. public:
  78. virtual String get_caption() const override;
  79. virtual int get_input_port_count() const override;
  80. virtual PortType get_input_port_type(int p_port) const override;
  81. virtual String get_input_port_name(int p_port) const override;
  82. virtual int get_output_port_count() const override;
  83. virtual PortType get_output_port_type(int p_port) const override;
  84. virtual String get_output_port_name(int p_port) const override;
  85. 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;
  86. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  87. VisualShaderNodeTextureSDFNormal();
  88. };
  89. class VisualShaderNodeSDFRaymarch : public VisualShaderNode {
  90. GDCLASS(VisualShaderNodeSDFRaymarch, VisualShaderNode);
  91. public:
  92. virtual String get_caption() const override;
  93. virtual int get_input_port_count() const override;
  94. virtual PortType get_input_port_type(int p_port) const override;
  95. virtual String get_input_port_name(int p_port) const override;
  96. virtual int get_output_port_count() const override;
  97. virtual PortType get_output_port_type(int p_port) const override;
  98. virtual String get_output_port_name(int p_port) const override;
  99. 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;
  100. virtual Category get_category() const override { return CATEGORY_TEXTURES; }
  101. VisualShaderNodeSDFRaymarch();
  102. };