gles2_gles3_differences.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. .. _doc_gles2_gles3_differences:
  2. Differences between GLES2 and GLES3
  3. ===================================
  4. This page documents the differences between GLES2 and GLES3 that are by design and are not the result
  5. of bugs. There may be differences that are unintentional, but they should be reported as bugs.
  6. .. note:: "GLES2" and "GLES3" are the names used in Godot for the two OpenGL-based rendering backends.
  7. In terms of graphics APIs, the GLES2 backend maps to OpenGL 2.1 on desktop, OpenGL ES 2.0 on
  8. mobile and WebGL 1.0 on the web. The GLES3 backend maps to OpenGL 3.3 on desktop, OpenGL ES
  9. 3.0 on mobile and WebGL 2.0 on the web.
  10. Particles
  11. ---------
  12. GLES2 cannot use the :ref:`Particles <class_Particles>` or :ref:`Particles2D <class_Particles2D>` nodes
  13. as they require advanced GPU features. Instead, use :ref:`CPUParticles <class_CPUParticles>` or
  14. :ref:`CPUParticles2D <class_CPUParticles2D>`, which provides a similar interface to a
  15. :ref:`ParticlesMaterial <class_ParticlesMaterial>`.
  16. .. tip:: Particles and Particles2D can be converted to their CPU equivalent node with the "Convert to
  17. CPUParticles" option in the editor.
  18. ``SCREEN_TEXTURE`` mip-maps
  19. ---------------------------
  20. In GLES2, ``SCREEN_TEXTURE`` (accessed via a :ref:`ShaderMaterial <class_ShaderMaterial>`) does not have
  21. computed mip-maps. So when accessing at a different LOD, the texture will not appear blurry.
  22. ``DEPTH_TEXTURE``
  23. -----------------
  24. While GLES2 supports ``DEPTH_TEXTURE`` in shaders, it may not work on some old hardware (especially mobile).
  25. Color space
  26. -----------
  27. GLES2 and GLES3 are in different color spaces. This means that colors will appear slightly
  28. different between them especially when lighting is used.
  29. If your game is going to use both GLES2 and GLES3, you can use an ``if``
  30. statement check and see if the output is in sRGB, using ``OUTPUT_IS_SRGB``. ``OUTPUT_IS_SRGB`` is
  31. ``true`` in GLES2 and ``false`` in GLES3.
  32. HDR
  33. ---
  34. GLES2 is not capable of using High Dynamic Range (HDR) rendering features. If HDR is set for your
  35. project, or for a given viewport, Godot will still use Low Dynamic Range (LDR) which limits
  36. viewport values to the ``0-1`` range.
  37. The Viewport **Debanding** property and associated project setting will also have
  38. no effect when HDR is disabled. This means debanding can't be used in GLES2.
  39. SpatialMaterial features
  40. ------------------------
  41. In GLES2, the following advanced rendering features in the :ref:`SpatialMaterial <class_SpatialMaterial>` are missing:
  42. - Refraction
  43. - Subsurface scattering
  44. - Anisotropy
  45. - Clearcoat
  46. - Depth mapping
  47. When using SpatialMaterials they will not even appear in the editor.
  48. In custom :ref:`ShaderMaterials <class_ShaderMaterial>`, you can set values for these features but they
  49. will be non-functional. For example, you will still be able to set the ``SSS`` built-in (which normally adds
  50. subsurface scattering) in your shader, but nothing will happen.
  51. Environment features
  52. --------------------
  53. In GLES2, the following features in the :ref:`Environment <class_Environment>` are missing:
  54. - Auto exposure
  55. - Tonemapping
  56. - Screen space reflections
  57. - Screen space ambient occlusion
  58. That means that in GLES2 environments you can only set:
  59. - Sky (including procedural sky)
  60. - Ambient light
  61. - Fog
  62. - Depth of field
  63. - Glow (also known as bloom)
  64. - Adjustment
  65. GIProbes
  66. --------
  67. :ref:`GIProbes <class_GIProbe>` do not work in GLES2. Instead use :ref:`Baked Lightmaps <class_BakedLightmap>`.
  68. For a description of how baked lightmaps work see the :ref:`Baked Lightmaps tutorial <doc_baked_lightmaps>`.
  69. Contact shadows
  70. ---------------
  71. The ``shadow_contact`` property of :ref:`Lights <class_Light>` is not supported in GLES2 and so does nothing.
  72. Light performance
  73. -----------------
  74. In GLES2, performance scales poorly with several lights, as each light is processed in a separate render
  75. pass (in opposition to GLES3 which is all done in a single pass). Try to limit scenes to as few lights as
  76. possible in order to achieve greatest performance.
  77. Texture compression
  78. -------------------
  79. On mobile, GLES2 requires ETC texture compression, while GLES3 requires ETC2. ETC2 is enabled by default,
  80. so if exporting to mobile using GLES2 make sure to set the project setting
  81. ``rendering/vram_compression/import_etc`` and then reimport textures.
  82. .. warning::
  83. Since ETC doesn't support transparency, you must reimport textures that contain
  84. an alpha channel to use the Uncompressed, Lossy or Lossless compression mode
  85. (instead of Video RAM). This can be done in the Import dock after selecting
  86. them in the FileSystem dock.
  87. Blend shapes
  88. ------------
  89. Blend shapes are not supported in GLES2.
  90. Shading language
  91. ----------------
  92. GLES3 provides many built-in functions that GLES2 does not. Below is a list of functions
  93. that are not available or are have limited support in GLES2.
  94. For a complete list of built-in GLSL functions see the :ref:`Shading Language doc <doc_shading_language>`.
  95. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  96. | Function | |
  97. +=============================================================================================+==================================================+
  98. | vec_type **modf** ( vec_type x, out vec_type i ) | |
  99. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  100. | vec_int_type **floatBitsToInt** ( vec_type x ) | |
  101. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  102. | vec_uint_type **floatBitsToUint** ( vec_type x ) | |
  103. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  104. | vec_type **intBitsToFloat** ( vec_int_type x ) | |
  105. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  106. | vec_type **uintBitsToFloat** ( vec_uint_type x ) | |
  107. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  108. | ivec2 **textureSize** ( sampler2D_type s, int lod ) | See workaround below |
  109. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  110. | ivec2 **textureSize** ( samplerCube s, int lod ) | See workaround below |
  111. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  112. | vec4_type **texture** ( sampler_type s, vec_type uv [, float bias] ) | **bias** not available in vertex shader |
  113. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  114. | vec4_type **textureProj** ( sampler_type s, vec_type uv [, float bias] ) | |
  115. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  116. | vec4_type **textureLod** ( sampler_type s, vec_type uv, float lod ) | Only available in vertex shader on some hardware |
  117. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  118. | vec4_type **textureProjLod** ( sampler_type s, vec_type uv, float lod ) | |
  119. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  120. | vec4_type **textureGrad** ( sampler_type s, vec_type uv, vec_type dPdx, vec_type dPdy ) | |
  121. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  122. | vec_type **dFdx** ( vec_type p ) | |
  123. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  124. | vec_type **dFdy** ( vec_type p ) | |
  125. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  126. | vec_type **fwidth** ( vec_type p ) | |
  127. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  128. .. note:: Functions not in GLES2's GLSL were added with Godots own shader standard library. These functions may perform worse in GLES2 compared to GLES3.
  129. ``textureSize()`` workaround
  130. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  131. GLES2 does not support ``textureSize()``. You can get the size of a texture the old fashioned way by passing in a
  132. uniform with the texture size yourself.
  133. .. code-block:: glsl
  134. // In the shader:
  135. uniform sampler2D textureName;
  136. uniform vec2 textureName_size;
  137. ::
  138. # In GDScript:
  139. material_name.set_shader_param("textureName", my_texture)
  140. material_name.set_shader_param("textureName_size", my_texture_size)
  141. Built in variables and render modes
  142. -----------------------------------
  143. Godot also provides many built-in variables and render modes. Some cannot be supported in GLES2. Below is a list of
  144. built-in variables and render modes that, when written to, will have no effect or could even cause issues when using
  145. the GLES2 backend.
  146. +----------------------------+
  147. | Variable / Render Mode |
  148. +============================+
  149. | ``ensure_correct_normals`` |
  150. +----------------------------+
  151. | ``INSTANCE_ID`` |
  152. +----------------------------+
  153. | ``DEPTH`` |
  154. +----------------------------+
  155. | ``ANISOTROPY`` |
  156. +----------------------------+
  157. | ``ANISOTROPY_FLOW`` |
  158. +----------------------------+
  159. | ``SSS_STRENGTH`` |
  160. +----------------------------+