Move jitter_stutter and gles2_gles3_differences to rendering section

This commit is contained in:
Nathan Lovato
2021-11-24 10:26:50 -06:00
parent 9cd85fdd02
commit eb0f2c731e
7 changed files with 2 additions and 2 deletions
@@ -0,0 +1,212 @@
.. _doc_gles2_gles3_differences:
Differences between GLES2 and GLES3
===================================
This page documents the differences between GLES2 and GLES3 that are by design and are not the result
of bugs. There may be differences that are unintentional, but they should be reported as bugs.
.. note:: "GLES2" and "GLES3" are the names used in Godot for the two OpenGL-based rendering backends.
In terms of graphics APIs, the GLES2 backend maps to OpenGL 2.1 on desktop, OpenGL ES 2.0 on
mobile and WebGL 1.0 on the web. The GLES3 backend maps to OpenGL 3.3 on desktop, OpenGL ES
3.0 on mobile and WebGL 2.0 on the web.
Particles
---------
GLES2 cannot use the :ref:`Particles <class_Particles>` or :ref:`Particles2D <class_Particles2D>` nodes
as they require advanced GPU features. Instead, use :ref:`CPUParticles <class_CPUParticles>` or
:ref:`CPUParticles2D <class_CPUParticles2D>`, which provides a similar interface to a
:ref:`ParticlesMaterial <class_ParticlesMaterial>`.
.. tip:: Particles and Particles2D can be converted to their CPU equivalent node with the "Convert to
CPUParticles" option in the editor.
``SCREEN_TEXTURE`` mip-maps
---------------------------
In GLES2, ``SCREEN_TEXTURE`` (accessed via a :ref:`ShaderMaterial <class_ShaderMaterial>`) does not have
computed mip-maps. So when accessing at a different LOD, the texture will not appear blurry.
``DEPTH_TEXTURE``
-----------------
While GLES2 supports ``DEPTH_TEXTURE`` in shaders, it may not work on some old hardware (especially mobile).
Color space
-----------
GLES2 and GLES3 are in different color spaces. This means that colors will appear slightly
different between them especially when lighting is used.
If your game is going to use both GLES2 and GLES3, you can use an ``if``
statement check and see if the output is in sRGB, using ``OUTPUT_IS_SRGB``. ``OUTPUT_IS_SRGB`` is
``true`` in GLES2 and ``false`` in GLES3.
HDR
---
GLES2 is not capable of using High Dynamic Range (HDR) rendering features. If HDR is set for your
project, or for a given viewport, Godot will still use Low Dynamic Range (LDR) which limits
viewport values to the ``0-1`` range.
The Viewport **Debanding** property and associated project setting will also have
no effect when HDR is disabled. This means debanding can't be used in GLES2.
SpatialMaterial features
------------------------
In GLES2, the following advanced rendering features in the :ref:`SpatialMaterial <class_SpatialMaterial>` are missing:
- Refraction
- Subsurface scattering
- Anisotropy
- Clearcoat
- Depth mapping
When using SpatialMaterials they will not even appear in the editor.
In custom :ref:`ShaderMaterials <class_ShaderMaterial>`, you can set values for these features but they
will be non-functional. For example, you will still be able to set the ``SSS`` built-in (which normally adds
subsurface scattering) in your shader, but nothing will happen.
Environment features
--------------------
In GLES2, the following features in the :ref:`Environment <class_Environment>` are missing:
- Auto exposure
- Tonemapping
- Screen space reflections
- Screen space ambient occlusion
That means that in GLES2 environments you can only set:
- Sky (including procedural sky)
- Ambient light
- Fog
- Depth of field
- Glow (also known as bloom)
- Adjustment
GIProbes
--------
:ref:`GIProbes <class_GIProbe>` do not work in GLES2. Instead use :ref:`Baked Lightmaps <class_BakedLightmap>`.
For a description of how baked lightmaps work see the :ref:`Baked Lightmaps tutorial <doc_baked_lightmaps>`.
Contact shadows
---------------
The ``shadow_contact`` property of :ref:`Lights <class_Light>` is not supported in GLES2 and so does nothing.
Light performance
-----------------
In GLES2, performance scales poorly with several lights, as each light is processed in a separate render
pass (in opposition to GLES3 which is all done in a single pass). Try to limit scenes to as few lights as
possible in order to achieve greatest performance.
Texture compression
-------------------
On mobile, GLES2 requires ETC texture compression, while GLES3 requires ETC2. ETC2 is enabled by default,
so if exporting to mobile using GLES2 make sure to set the project setting
``rendering/vram_compression/import_etc`` and then reimport textures.
.. warning::
Since ETC doesn't support transparency, you must reimport textures that contain
an alpha channel to use the Uncompressed, Lossy or Lossless compression mode
(instead of Video RAM). This can be done in the Import dock after selecting
them in the FileSystem dock.
Blend shapes
------------
Blend shapes are not supported in GLES2.
Shading language
----------------
GLES3 provides many built-in functions that GLES2 does not. Below is a list of functions
that are not available or are have limited support in GLES2.
For a complete list of built-in GLSL functions see the :ref:`Shading Language doc <doc_shading_language>`.
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| Function | |
+=============================================================================================+==================================================+
| vec_type **modf** ( vec_type x, out vec_type i ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec_int_type **floatBitsToInt** ( vec_type x ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec_uint_type **floatBitsToUint** ( vec_type x ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec_type **intBitsToFloat** ( vec_int_type x ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec_type **uintBitsToFloat** ( vec_uint_type x ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| ivec2 **textureSize** ( sampler2D_type s, int lod ) | See workaround below |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| ivec2 **textureSize** ( samplerCube s, int lod ) | See workaround below |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec4_type **texture** ( sampler_type s, vec_type uv [, float bias] ) | **bias** not available in vertex shader |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec4_type **textureProj** ( sampler_type s, vec_type uv [, float bias] ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec4_type **textureLod** ( sampler_type s, vec_type uv, float lod ) | Only available in vertex shader on some hardware |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec4_type **textureProjLod** ( sampler_type s, vec_type uv, float lod ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec4_type **textureGrad** ( sampler_type s, vec_type uv, vec_type dPdx, vec_type dPdy ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec_type **dFdx** ( vec_type p ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec_type **dFdy** ( vec_type p ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
| vec_type **fwidth** ( vec_type p ) | |
+---------------------------------------------------------------------------------------------+--------------------------------------------------+
.. 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.
``textureSize()`` workaround
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
GLES2 does not support ``textureSize()``. You can get the size of a texture the old fashioned way by passing in a
uniform with the texture size yourself.
.. code-block:: glsl
// In the shader:
uniform sampler2D textureName;
uniform vec2 textureName_size;
::
# In GDScript:
material_name.set_shader_param("textureName", my_texture)
material_name.set_shader_param("textureName_size", my_texture_size)
Built in variables and render modes
-----------------------------------
Godot also provides many built-in variables and render modes. Some cannot be supported in GLES2. Below is a list of
built-in variables and render modes that, when written to, will have no effect or could even cause issues when using
the GLES2 backend.
+----------------------------+
| Variable / Render Mode |
+============================+
| ``ensure_correct_normals`` |
+----------------------------+
| ``INSTANCE_ID`` |
+----------------------------+
| ``DEPTH`` |
+----------------------------+
| ``ANISOTROPY`` |
+----------------------------+
| ``ANISOTROPY_FLOW`` |
+----------------------------+
| ``SSS_STRENGTH`` |
+----------------------------+
Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

+2
View File
@@ -7,3 +7,5 @@ Rendering
viewports
multiple_resolutions
jitter_stutter
gles2_gles3_differences
+108
View File
@@ -0,0 +1,108 @@
.. _doc_jitter_stutter:
Fixing jitter and stutter
=========================
What are jitter and stutter?
----------------------------
*Jitter* and *stutter* are two different alterations to visible motion of objects on screen that may affect a game,
even when running at full speed. These effects are mostly visible in games where the world moves at a constant speed
in a fixed direction, like runners or platformers.
Distinguishing between them
---------------------------
A game running at a normal framerate without exhibiting any effect will appear smooth:
.. image:: img/motion_normal.gif
A game exhibiting *jitter* will shake constantly in a very subtle way:
.. image:: img/motion_jitter.gif
Finally, a game exhibiting *stutter* will appear smooth, but appear to *stop* or *roll back a frame* every few seconds:
.. image:: img/motion_stutter.gif
Jitter
------
There can be many causes of jitter, the most typical one happens when the game *physics frequency* (usually 60 Hz) runs
at a different resolution than the monitor refresh rate. Check whether your monitor refresh rate is different from 60 Hz.
This is generally not a problem, given that most monitors are 60 Hz, and
starting with Godot 3.1, a frame timer was introduced that tries to synchronize with refresh as well as possible.
Sometimes only some objects appear to jitter (character or background). This happens when they are processed in different
time sources (one is processed in the physics step while another is processed in the idle step). Godot 3.1 does some
improvements to this, from allowing kinematic bodies to be animated in the regular _process loop, to further fixes in the
frame timer.
.. note::
You can use physics interpolation to mitigate physics-related jittering.
See `lawnjelly's smoothing-addon <https://github.com/lawnjelly/smoothing-addon>`__
for an add-on that can be dropped into any project to enable physics interpolation.
Stutter
-------
Stutter may happen due to two different reasons. The first, and most obvious one, is the game not being able to keep full
framerate performance. Solving this is game specific and will require optimization.
The second is more complicated, because it is often not associated to the engine or game but the underlying operating system.
Here is some information regarding stutter on different OSs.
Windows
^^^^^^^
Windows is known to cause stutter in windowed games. This mostly depends on the hardware installed, drivers version and
processes running in parallel (e.g. having many browser tabs open may cause stutter in a running game). To avoid this,
starting with 3.1, Godot raises the game priority to "Above Normal". This helps considerably but may not completely eliminate
stutter.
Eliminating this completely requires giving your game full privileges to become "time critical", which is not advised.
Some games may do it, but it is advised to learn to live with this problem, as it is common for Windows games and most users
won't play games windowed (games that are played in a window, e.g. puzzle games, will usually not exhibit this problem anyway).
For fullscreen, Windows gives special priority to the game so stutter is no longer visible and very rare.
This is how most games are played.
Linux (X11)
^^^^^^^^^^^
Stutter may be visible on Desktop Linux, but this is usually associated with different video drivers and compositors.
Nouveau drivers often exhibit this, while AMD or NVidia proprietary don't. Some compositors may also trigger this problem
(e.g. KWin), so it is advised to try using a different one to rule it out as the cause.
There is no workaround for driver or compositor stuttering other than reporting it as an issue to the driver or compositor
developers.
macOS
^^^^^
Generally, macOS is stutter-free, although recently some bugs were reported when running on fullscreen (this is a macOS bug).
If you have a machine exhibiting this behavior, please let us know.
Android
^^^^^^^
Generally, Android is stutter and jitter-free because the running activity gets all the priority. That said, there may be
problematic devices (older Kindle Fire is known to be one). If you see this problem on Android, please let us know.
iOS
^^^
iOS devices are generally stutter-free, but older devices running newer versions of the operating system may exhibit problems.
This is generally unavoidable.
Reporting stutter or jitter problems
------------------------------------
If you are reporting a stutter or jitter problem (opening an issue) not caused by any of the above reasons, please specify very
clearly all the information possible about device, operating system, driver versions, etc. This may help to better troubleshoot it.
Also make sure to use the correct term (jitter or stutter) based on the exhibited behavior. This will help understand your issue much faster.
Provide a project that can be used to reproduce the issue, and if possible a screen capture demonstrating the bug.