class_texturearray.rst 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/TextureArray.xml.
  6. .. _class_TextureArray:
  7. TextureArray
  8. ============
  9. **Inherits:** :ref:`TextureLayered<class_TextureLayered>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. Array of textures stored in a single primitive.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **TextureArray**\ s store an array of :ref:`Image<class_Image>`\ s in a single :ref:`Texture<class_Texture>` primitive. Each layer of the texture array has its own mipmap chain. This makes it is a good alternative to texture atlases. See also :ref:`Texture3D<class_Texture3D>`.
  15. \ **TextureArray**\ s must be displayed using shaders. After importing your file as a **TextureArray** and setting the appropriate Horizontal and Vertical Slices, display it by setting it as a uniform to a shader, for example (2D):
  16. ::
  17. shader_type canvas_item;
  18. uniform sampler2DArray tex;
  19. uniform int index;
  20. void fragment() {
  21. COLOR = texture(tex, vec3(UV.x, UV.y, float(index)));
  22. }
  23. Set the integer uniform "index" to show a particular part of the texture as defined by the Horizontal and Vertical Slices in the importer.
  24. \ **Note:** When sampling an albedo texture from a texture array in 3D, the sRGB -> linear conversion hint (``hint_albedo``) should be used to prevent colors from looking washed out:
  25. ::
  26. shader_type spatial;
  27. uniform sampler2DArray tex : hint_albedo;
  28. uniform int index;
  29. void fragment() {
  30. ALBEDO = texture(tex, vec3(UV.x, UV.y, float(index)));
  31. }
  32. \ **Note:** **TextureArray**\ s can only be sampled in shaders in the GLES3 backend. In GLES2, their data can be accessed via scripting, but there is no way to render them in a hardware-accelerated manner.
  33. .. rst-class:: classref-reftable-group
  34. Methods
  35. -------
  36. .. table::
  37. :widths: auto
  38. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`create<class_TextureArray_method_create>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`int<class_int>` depth, :ref:`Format<enum_Image_Format>` format, :ref:`int<class_int>` flags=7 **)** |
  40. +------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. .. rst-class:: classref-section-separator
  42. ----
  43. .. rst-class:: classref-descriptions-group
  44. Method Descriptions
  45. -------------------
  46. .. _class_TextureArray_method_create:
  47. .. rst-class:: classref-method
  48. void **create** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`int<class_int>` depth, :ref:`Format<enum_Image_Format>` format, :ref:`int<class_int>` flags=7 **)**
  49. Creates the TextureArray with specified ``width``, ``height``, and ``depth``. See :ref:`Format<enum_Image_Format>` for ``format`` options. See :ref:`Flags<enum_TextureLayered_Flags>` enumerator for ``flags`` options.
  50. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  51. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  52. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  53. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`