gles2_gles3_differences.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 user Low Dynamic Range (LDR) which limits
  36. viewport values to the ``0-1`` range.
  37. StandardMaterial3D features
  38. ---------------------------
  39. In GLES2, the following advanced rendering features in the :ref:`StandardMaterial3D <class_StandardMaterial3D>` are missing:
  40. - Refraction
  41. - Subsurface scattering
  42. - Anisotropy
  43. - Clearcoat
  44. - Depth mapping
  45. When using StandardMaterial3Ds they will not even appear in the editor.
  46. In custom :ref:`ShaderMaterials <class_ShaderMaterial>`, you can set values for these features but they
  47. will be non-functional. For example, you will still be able to set the ``SSS`` built-in (which normally adds
  48. subsurface scattering) in your shader, but nothing will happen.
  49. Environment features
  50. --------------------
  51. In GLES2, the following features in the :ref:`Environment <class_Environment>` are missing:
  52. - Auto exposure
  53. - Tonemapping
  54. - Screen space reflections
  55. - Screen space ambient occlusion
  56. That means that in GLES2 environments you can only set:
  57. - Sky (including procedural sky)
  58. - Ambient light
  59. - Fog
  60. - Depth of field
  61. - Glow (also known as bloom)
  62. - Adjustment
  63. See :ref:`doc_environment_and_post_processing` for more information.
  64. Glow
  65. ----
  66. Many GLES2 devices only have a maximum of eight texture units. On such devices, you
  67. can only use the first six levels of glow; the seventh one won't do anything.
  68. GIProbes
  69. --------
  70. .. FIXME: Removed reference to class_BakedLightmap in master/4.0 version to
  71. silence warning, but the whole page will likely end up rewritten or removed
  72. in 4.0.
  73. :ref:`GIProbes <class_GIProbe>` do not work in GLES2. Instead use Baked Lightmaps.
  74. For a description of how baked lightmaps work see the :ref:`Baked Lightmaps tutorial <doc_baked_lightmaps>`.
  75. Contact shadows
  76. ---------------
  77. The ``shadow_contact`` property of :ref:`Lights <class_Light>` is not supported in GLES2 and so does nothing.
  78. Light performance
  79. -----------------
  80. In GLES2, performance scales poorly with several lights, as each light is processed in a separate render
  81. pass (in opposition to GLES3 which is all done in a single pass). Try to limit scenes to as few lights as
  82. possible in order to achieve greatest performance.
  83. Texture compression
  84. -------------------
  85. On mobile, GLES2 requires ETC texture compression, while GLES3 requires ETC2. ETC2 is enabled by default,
  86. so if exporting to mobile using GLES2 make sure to set the project setting
  87. ``rendering/vram_compression/import_etc`` and then reimport textures.
  88. .. warning::
  89. Since ETC doesn't support transparency, you must reimport textures that contain
  90. an alpha channel to use the Uncompressed, Lossy or Lossless compression mode
  91. (instead of Video RAM). This can be done in the Import dock after selecting
  92. them in the FileSystem dock.
  93. Blend shapes
  94. ------------
  95. Blend shapes are not supported in GLES2.
  96. Shading language
  97. ----------------
  98. GLES3 provides many built-in functions that GLES2 does not. Below is a list of functions
  99. that are not available or are have limited support in GLES2.
  100. For a complete list of built-in GLSL functions see the :ref:`Shading Language doc <doc_shading_language>`.
  101. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  102. | Function | |
  103. +=============================================================================================+==================================================+
  104. | vec_type **modf** ( vec_type x, out vec_type i ) | |
  105. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  106. | vec_int_type **floatBitsToInt** ( vec_type x ) | |
  107. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  108. | vec_uint_type **floatBitsToUint** ( vec_type x ) | |
  109. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  110. | vec_type **intBitsToFloat** ( vec_int_type x ) | |
  111. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  112. | vec_type **uintBitsToFloat** ( vec_uint_type x ) | |
  113. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  114. | ivec2 **textureSize** ( sampler2D_type s, int lod ) | See workaround below |
  115. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  116. | ivec2 **textureSize** ( samplerCube s, int lod ) | See workaround below |
  117. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  118. | vec4_type **texture** ( sampler_type s, vec_type uv [, float bias] ) | **bias** not available in vertex shader |
  119. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  120. | vec4_type **textureProj** ( sampler_type s, vec_type uv [, float bias] ) | |
  121. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  122. | vec4_type **textureLod** ( sampler_type s, vec_type uv, float lod ) | Only available in vertex shader on some hardware |
  123. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  124. | vec4_type **textureProjLod** ( sampler_type s, vec_type uv, float lod ) | |
  125. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  126. | vec4_type **textureGrad** ( sampler_type s, vec_type uv, vec_type dPdx, vec_type dPdy) | |
  127. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  128. | vec_type **dFdx** ( vec_type p ) | |
  129. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  130. | vec_type **dFdy** ( vec_type p ) | |
  131. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  132. | vec_type **fwidth** ( vec_type p ) | |
  133. +---------------------------------------------------------------------------------------------+--------------------------------------------------+
  134. .. 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.
  135. ``textureSize()`` workaround
  136. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  137. GLES2 does not support ``textureSize()``. You can get the size of a texture the old fashioned way by passing in a
  138. uniform with the texture size yourself.
  139. .. code-block:: glsl
  140. // In the shader:
  141. uniform sampler2D textureName;
  142. uniform vec2 textureName_size;
  143. ::
  144. # In GDScript:
  145. material_name.set_shader_param("textureName", my_texture)
  146. material_name.set_shader_param("textureName_size", my_texture_size)
  147. Built in variables and render modes
  148. -----------------------------------
  149. Godot also provides many built-in variables and render modes. Some cannot be supported in GLES2. Below is a list of
  150. built-in variables and render modes that, when written to, will have no effect or could even cause issues when using
  151. the GLES2 backend.
  152. +----------------------------+
  153. | Variable / Render Mode |
  154. +============================+
  155. | ``ensure_correct_normals`` |
  156. +----------------------------+
  157. | ``INSTANCE_ID`` |
  158. +----------------------------+
  159. | ``DEPTH`` |
  160. +----------------------------+
  161. | ``ANISOTROPY`` |
  162. +----------------------------+
  163. | ``ANISOTROPY_FLOW`` |
  164. +----------------------------+
  165. | ``SSS_STRENGTH`` |
  166. +----------------------------+