class_material.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Material:
  4. Material
  5. ========
  6. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`ShaderMaterial<class_shadermaterial>`, :ref:`FixedMaterial<class_fixedmaterial>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Abstract base :ref:`Resource<class_resource>` for coloring and shading geometry.
  12. Member Functions
  13. ----------------
  14. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`get_blend_mode<class_Material_get_blend_mode>` **(** **)** const |
  16. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`get_depth_draw_mode<class_Material_get_depth_draw_mode>` **(** **)** const |
  18. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`get_flag<class_Material_get_flag>` **(** :ref:`int<class_int>` flag **)** const |
  20. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`float<class_float>` | :ref:`get_line_width<class_Material_get_line_width>` **(** **)** const |
  22. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`set_blend_mode<class_Material_set_blend_mode>` **(** :ref:`int<class_int>` mode **)** |
  24. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`set_depth_draw_mode<class_Material_set_depth_draw_mode>` **(** :ref:`int<class_int>` mode **)** |
  26. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`set_flag<class_Material_set_flag>` **(** :ref:`int<class_int>` flag, :ref:`bool<class_bool>` enable **)** |
  28. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`set_line_width<class_Material_set_line_width>` **(** :ref:`float<class_float>` width **)** |
  30. +----------------------------+-------------------------------------------------------------------------------------------------------------------+
  31. Numeric Constants
  32. -----------------
  33. - **FLAG_VISIBLE** = **0** --- Geometry is visible when this flag is enabled (default).
  34. - **FLAG_DOUBLE_SIDED** = **1** --- Both front facing and back facing triangles are rendered when this flag is enabled.
  35. - **FLAG_INVERT_FACES** = **2** --- Front facing and back facing order is swapped when this flag is enabled.
  36. - **FLAG_UNSHADED** = **3** --- Shading (lighting) is disabled when this flag is enabled.
  37. - **FLAG_ONTOP** = **4**
  38. - **FLAG_LIGHTMAP_ON_UV2** = **5**
  39. - **FLAG_COLOR_ARRAY_SRGB** = **6**
  40. - **FLAG_MAX** = **7** --- Maximum amount of flags.
  41. - **DEPTH_DRAW_ALWAYS** = **0**
  42. - **DEPTH_DRAW_OPAQUE_ONLY** = **1**
  43. - **DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA** = **2**
  44. - **DEPTH_DRAW_NEVER** = **3**
  45. - **BLEND_MODE_MIX** = **0** --- Use the regular alpha blending equation (source and dest colors are faded) (default).
  46. - **BLEND_MODE_ADD** = **1** --- Use additive blending equation, often used for particle effects such as fire or light decals.
  47. - **BLEND_MODE_SUB** = **2** --- Use subtractive blending equation, often used for some smoke effects or types of glass.
  48. - **BLEND_MODE_MUL** = **3**
  49. - **BLEND_MODE_PREMULT_ALPHA** = **4**
  50. Description
  51. -----------
  52. Material is a base :ref:`Resource<class_resource>` used for coloring and shading geometry. All materials inherit from it and almost all :ref:`VisualInstance<class_visualinstance>` derived nodes carry a Material. A few flags and parameters are shared between all material types and are configured here.
  53. Member Function Description
  54. ---------------------------
  55. .. _class_Material_get_blend_mode:
  56. - :ref:`int<class_int>` **get_blend_mode** **(** **)** const
  57. Return blend mode for the material, which can be one of BLEND_MODE_MIX (default), BLEND_MODE_ADD, BLEND_MODE_SUB. Keep in mind that only BLEND_MODE_MIX ensures that the material *may* be opaque, any other blend mode will render with alpha blending enabled in raster-based :ref:`VisualServer<class_visualserver>` implementations.
  58. .. _class_Material_get_depth_draw_mode:
  59. - :ref:`int<class_int>` **get_depth_draw_mode** **(** **)** const
  60. .. _class_Material_get_flag:
  61. - :ref:`bool<class_bool>` **get_flag** **(** :ref:`int<class_int>` flag **)** const
  62. Return a :ref:`Material<class_material>` flag, which toggles on or off a behavior when rendering. See enumeration FLAG\_\* for a list.
  63. .. _class_Material_get_line_width:
  64. - :ref:`float<class_float>` **get_line_width** **(** **)** const
  65. Return the line width for geometry drawn with FLAG_WIREFRAME enabled, or LINE primitives. Note that not all hardware or VisualServer backends support this (like DirectX).
  66. .. _class_Material_set_blend_mode:
  67. - void **set_blend_mode** **(** :ref:`int<class_int>` mode **)**
  68. Set blend mode for the material, which can be one of BLEND_MODE_MIX (default), BLEND_MODE_ADD, BLEND_MODE_SUB. Keep in mind that only BLEND_MODE_MIX ensures that the material *may* be opaque, any other blend mode will render with alpha blending enabled in raster-based :ref:`VisualServer<class_visualserver>` implementations.
  69. .. _class_Material_set_depth_draw_mode:
  70. - void **set_depth_draw_mode** **(** :ref:`int<class_int>` mode **)**
  71. .. _class_Material_set_flag:
  72. - void **set_flag** **(** :ref:`int<class_int>` flag, :ref:`bool<class_bool>` enable **)**
  73. Set a :ref:`Material<class_material>` flag, which toggles on or off a behavior when rendering. See enumeration FLAG\_\* for a list.
  74. .. _class_Material_set_line_width:
  75. - void **set_line_width** **(** :ref:`float<class_float>` width **)**
  76. Set the line width for geometry drawn with FLAG_WIREFRAME enabled, or LINE primitives. Note that not all hardware or VisualServer backends support this (like DirectX).