class_canvastexture.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/CanvasTexture.xml.
  6. .. _class_CanvasTexture:
  7. CanvasTexture
  8. =============
  9. **Inherits:** :ref:`Texture2D<class_Texture2D>` **<** :ref:`Texture<class_Texture>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Texture with optional normal and specular maps for use in 2D rendering.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **CanvasTexture** is an alternative to :ref:`ImageTexture<class_ImageTexture>` for 2D rendering. It allows using normal maps and specular maps in any node that inherits from :ref:`CanvasItem<class_CanvasItem>`. **CanvasTexture** also allows overriding the texture's filter and repeat mode independently of the node's properties (or the project settings).
  15. \ **Note:** **CanvasTexture** cannot be used in 3D. It will not display correctly when applied to any :ref:`VisualInstance3D<class_VisualInstance3D>`, such as :ref:`Sprite3D<class_Sprite3D>` or :ref:`Decal<class_Decal>`. For physically-based materials in 3D, use :ref:`BaseMaterial3D<class_BaseMaterial3D>` instead.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`2D Lights and Shadows <../tutorials/2d/2d_lights_and_shadows>`
  20. .. rst-class:: classref-reftable-group
  21. Properties
  22. ----------
  23. .. table::
  24. :widths: auto
  25. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  26. | :ref:`Texture2D<class_Texture2D>` | :ref:`diffuse_texture<class_CanvasTexture_property_diffuse_texture>` | |
  27. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  28. | :ref:`Texture2D<class_Texture2D>` | :ref:`normal_texture<class_CanvasTexture_property_normal_texture>` | |
  29. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | resource_local_to_scene | ``false`` (overrides :ref:`Resource<class_Resource_property_resource_local_to_scene>`) |
  31. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  32. | :ref:`Color<class_Color>` | :ref:`specular_color<class_CanvasTexture_property_specular_color>` | ``Color(1, 1, 1, 1)`` |
  33. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  34. | :ref:`float<class_float>` | :ref:`specular_shininess<class_CanvasTexture_property_specular_shininess>` | ``1.0`` |
  35. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  36. | :ref:`Texture2D<class_Texture2D>` | :ref:`specular_texture<class_CanvasTexture_property_specular_texture>` | |
  37. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  38. | :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` | :ref:`texture_filter<class_CanvasTexture_property_texture_filter>` | ``0`` |
  39. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  40. | :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` | :ref:`texture_repeat<class_CanvasTexture_property_texture_repeat>` | ``0`` |
  41. +-----------------------------------------------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
  42. .. rst-class:: classref-section-separator
  43. ----
  44. .. rst-class:: classref-descriptions-group
  45. Property Descriptions
  46. ---------------------
  47. .. _class_CanvasTexture_property_diffuse_texture:
  48. .. rst-class:: classref-property
  49. :ref:`Texture2D<class_Texture2D>` **diffuse_texture**
  50. .. rst-class:: classref-property-setget
  51. - void **set_diffuse_texture** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  52. - :ref:`Texture2D<class_Texture2D>` **get_diffuse_texture** **(** **)**
  53. The diffuse (color) texture to use. This is the main texture you want to set in most cases.
  54. .. rst-class:: classref-item-separator
  55. ----
  56. .. _class_CanvasTexture_property_normal_texture:
  57. .. rst-class:: classref-property
  58. :ref:`Texture2D<class_Texture2D>` **normal_texture**
  59. .. rst-class:: classref-property-setget
  60. - void **set_normal_texture** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  61. - :ref:`Texture2D<class_Texture2D>` **get_normal_texture** **(** **)**
  62. The normal map texture to use. Only has a visible effect if :ref:`Light2D<class_Light2D>`\ s are affecting this **CanvasTexture**.
  63. \ **Note:** Godot expects the normal map to use X+, Y+, and Z+ coordinates. See `this page <http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates>`__ for a comparison of normal map coordinates expected by popular engines.
  64. .. rst-class:: classref-item-separator
  65. ----
  66. .. _class_CanvasTexture_property_specular_color:
  67. .. rst-class:: classref-property
  68. :ref:`Color<class_Color>` **specular_color** = ``Color(1, 1, 1, 1)``
  69. .. rst-class:: classref-property-setget
  70. - void **set_specular_color** **(** :ref:`Color<class_Color>` value **)**
  71. - :ref:`Color<class_Color>` **get_specular_color** **(** **)**
  72. The multiplier for specular reflection colors. The :ref:`Light2D<class_Light2D>`'s color is also taken into account when determining the reflection color. Only has a visible effect if :ref:`Light2D<class_Light2D>`\ s are affecting this **CanvasTexture**.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_CanvasTexture_property_specular_shininess:
  76. .. rst-class:: classref-property
  77. :ref:`float<class_float>` **specular_shininess** = ``1.0``
  78. .. rst-class:: classref-property-setget
  79. - void **set_specular_shininess** **(** :ref:`float<class_float>` value **)**
  80. - :ref:`float<class_float>` **get_specular_shininess** **(** **)**
  81. The specular exponent for :ref:`Light2D<class_Light2D>` specular reflections. Higher values result in a more glossy/"wet" look, with reflections becoming more localized and less visible overall. The default value of ``1.0`` disables specular reflections entirely. Only has a visible effect if :ref:`Light2D<class_Light2D>`\ s are affecting this **CanvasTexture**.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_CanvasTexture_property_specular_texture:
  85. .. rst-class:: classref-property
  86. :ref:`Texture2D<class_Texture2D>` **specular_texture**
  87. .. rst-class:: classref-property-setget
  88. - void **set_specular_texture** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  89. - :ref:`Texture2D<class_Texture2D>` **get_specular_texture** **(** **)**
  90. The specular map to use for :ref:`Light2D<class_Light2D>` specular reflections. This should be a grayscale or colored texture, with brighter areas resulting in a higher :ref:`specular_shininess<class_CanvasTexture_property_specular_shininess>` value. Using a colored :ref:`specular_texture<class_CanvasTexture_property_specular_texture>` allows controlling specular shininess on a per-channel basis. Only has a visible effect if :ref:`Light2D<class_Light2D>`\ s are affecting this **CanvasTexture**.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_CanvasTexture_property_texture_filter:
  94. .. rst-class:: classref-property
  95. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **texture_filter** = ``0``
  96. .. rst-class:: classref-property-setget
  97. - void **set_texture_filter** **(** :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` value **)**
  98. - :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **get_texture_filter** **(** **)**
  99. The texture filtering mode to use when drawing this **CanvasTexture**.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_CanvasTexture_property_texture_repeat:
  103. .. rst-class:: classref-property
  104. :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **texture_repeat** = ``0``
  105. .. rst-class:: classref-property-setget
  106. - void **set_texture_repeat** **(** :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` value **)**
  107. - :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **get_texture_repeat** **(** **)**
  108. The texture repeat mode to use when drawing this **CanvasTexture**.
  109. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  110. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  111. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  112. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  113. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  114. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  115. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`