Shader.xml 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Shader" inherits="Resource" version="3.4">
  3. <brief_description>
  4. A custom shader program.
  5. </brief_description>
  6. <description>
  7. This class allows you to define a custom shader program that can be used by a [ShaderMaterial]. Shaders allow you to write your own custom behavior for rendering objects or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.
  8. </description>
  9. <tutorials>
  10. <link>https://docs.godotengine.org/en/3.3/tutorials/shading/index.html</link>
  11. <link>https://docs.godotengine.org/en/3.3/tutorials/shading/your_first_shader/what_are_shaders.html</link>
  12. </tutorials>
  13. <methods>
  14. <method name="get_default_texture_param" qualifiers="const">
  15. <return type="Texture">
  16. </return>
  17. <argument index="0" name="param" type="String">
  18. </argument>
  19. <description>
  20. Returns the texture that is set as default for the specified parameter.
  21. [b]Note:[/b] [code]param[/code] must match the name of the uniform in the code exactly.
  22. </description>
  23. </method>
  24. <method name="get_mode" qualifiers="const">
  25. <return type="int" enum="Shader.Mode">
  26. </return>
  27. <description>
  28. Returns the shader mode for the shader, either [constant MODE_CANVAS_ITEM], [constant MODE_SPATIAL] or [constant MODE_PARTICLES].
  29. </description>
  30. </method>
  31. <method name="has_param" qualifiers="const">
  32. <return type="bool">
  33. </return>
  34. <argument index="0" name="name" type="String">
  35. </argument>
  36. <description>
  37. Returns [code]true[/code] if the shader has this param defined as a uniform in its code.
  38. [b]Note:[/b] [code]param[/code] must match the name of the uniform in the code exactly.
  39. </description>
  40. </method>
  41. <method name="set_default_texture_param">
  42. <return type="void">
  43. </return>
  44. <argument index="0" name="param" type="String">
  45. </argument>
  46. <argument index="1" name="texture" type="Texture">
  47. </argument>
  48. <description>
  49. Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the [ShaderMaterial].
  50. [b]Note:[/b] [code]param[/code] must match the name of the uniform in the code exactly.
  51. </description>
  52. </method>
  53. </methods>
  54. <members>
  55. <member name="code" type="String" setter="set_code" getter="get_code" default="&quot;&quot;">
  56. Returns the shader's code as the user has written it, not the full generated code used internally.
  57. </member>
  58. <member name="custom_defines" type="String" setter="set_custom_defines" getter="get_custom_defines" default="&quot;&quot;">
  59. Returns the shader's custom defines. Custom defines can be used in Godot to add GLSL preprocessor directives (e.g: extensions) required for the shader logic.
  60. [b]Note:[/b] Custom defines are not validated by the Godot shader parser, so care should be taken when using them.
  61. </member>
  62. </members>
  63. <constants>
  64. <constant name="MODE_SPATIAL" value="0" enum="Mode">
  65. Mode used to draw all 3D objects.
  66. </constant>
  67. <constant name="MODE_CANVAS_ITEM" value="1" enum="Mode">
  68. Mode used to draw all 2D objects.
  69. </constant>
  70. <constant name="MODE_PARTICLES" value="2" enum="Mode">
  71. Mode used to calculate particle information on a per-particle basis. Not used for drawing.
  72. </constant>
  73. </constants>
  74. </class>