3d_rendering_limitations.rst 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. .. _doc_3d_rendering_limitations:
  2. 3D rendering limitations
  3. ========================
  4. Introduction
  5. ------------
  6. Due to their focus on performance, real-time rendering engines have many
  7. limitations. Godot's renderer is no exception. To work effectively with those
  8. limitations, you need to understand them.
  9. Texture size limits
  10. -------------------
  11. On desktops and laptops, textures larger than 8192×8192 may not be supported on
  12. older devices. You can check your target GPU's limitations on
  13. `GPUinfo.org <https://www.gpuinfo.org/>`__.
  14. Mobile GPUs are typically limited to 4096×4096 textures. Also, some mobile GPUs
  15. don't support repeating non-power-of-two-sized textures. Therefore, if you want
  16. your texture to display correctly on all platforms, you should avoid using
  17. textures larger than 4096×4096 and use a power of two size if the texture needs
  18. to repeat.
  19. To limit the size of a specific texture that may be too large to render, you can
  20. set the **Process > Size Limit** import option to a value greater than ``0``.
  21. This will reduce the texture's dimensions on import (preserving aspect ratio)
  22. without affecting the source file.
  23. .. _doc_3d_rendering_limitations_color_banding:
  24. Color banding
  25. -------------
  26. When using the GLES3 or Vulkan renderers, Godot's 3D engine renders internally
  27. in HDR. However, the rendering output will be tonemapped to a low dynamic range
  28. so it can be displayed on the screen. This can result in visible banding,
  29. especially when using untextured materials. This can also be seen in 2D projects
  30. when using smooth gradient textures.
  31. There are two main ways to alleviate banding:
  32. - Enable **Use Debanding** in the Project Settings. This applies a
  33. fullscreen debanding shader as a post-processing effect and is very cheap.
  34. Fullscreen debanding is only supported when using the GLES3 or Vulkan renderers.
  35. It also requires HDR to be enabled in the Project Settings (which is the default).
  36. - Alternatively, bake some noise into your textures. This is mainly effective in 2D,
  37. e.g. for vignetting effects. In 3D, you can also use a
  38. `custom debanding shader <https://github.com/fractilegames/godot-gles2-debanding-material>`__
  39. to be applied on your *materials*. This technique works even if your project is
  40. rendered in LDR, which means it will work when using the GLES2 renderer.
  41. .. seealso::
  42. See `Banding in Games: A Noisy Rant <http://loopit.dk/banding_in_games.pdf>`__
  43. for more details about banding and ways to combat it.
  44. Depth buffer precision
  45. ----------------------
  46. To sort objects in 3D space, rendering engines rely on a *depth buffer* (also
  47. called *Z-buffer*). This buffer has a finite precision: 24-bit on desktop
  48. platforms, sometimes 16-bit on mobile platforms (for performance reasons). If
  49. two different objects end up on the same buffer value, then Z-fighting will
  50. occur. This will materialize as textures flickering back and forth as the camera
  51. moves or rotates.
  52. To make the depth buffer more precise over the rendered area, you should
  53. *increase* the Camera node's **Near** property. However, be careful: if you set
  54. it too high, players will be able to see through nearby geometry. You should
  55. also *decrease* the Camera node's **Far** property to the lowest permissible value
  56. for your use case, though keep in mind it won't impact precision as much as the
  57. **Near** property.
  58. If you only need high precision when the player can see far away, you could
  59. change it dynamically based on the game conditions. For instance, if the player
  60. enters an airplane, the **Near** property can be temporarily increased to avoid
  61. Z-fighting in the distance. It can then be decreased once the player leaves the
  62. airplane.
  63. Depending on the scene and viewing conditions, you may also be able to move the
  64. Z-fighting objects further apart without the difference being visible to the
  65. player.
  66. .. _doc_3d_rendering_limitations_transparency_sorting:
  67. Transparency sorting
  68. --------------------
  69. In Godot, transparent materials are drawn after opaque materials. Transparent
  70. objects are sorted back to front before being drawn based on the Node3D's
  71. position, not the vertex position in world space. Due to this, overlapping
  72. objects may often be sorted out of order. To fix improperly sorted objects, tweak
  73. the material's :ref:`Render Priority <class_Material_property_render_priority>`
  74. property. This will force specific materials to appear in front or behind of
  75. other transparent materials. Even then, this may not always be sufficient.
  76. Some rendering engines feature *order-independent transparency* techniques to
  77. alleviate this, but this is costly on the GPU. Godot currently doesn't provide
  78. this feature. There are still several ways to avoid this problem:
  79. - Only make materials transparent if you actually need it. If a material only
  80. has a small transparent part, consider splitting it into a separate material.
  81. This will allow the opaque part to cast shadows and will also improve performance.
  82. - If your texture mostly has fully opaque and fully transparent areas, you can
  83. use alpha testing instead of alpha blending. This transparency mode is faster
  84. to render and doesn't suffer from transparency issues. Enable **Transparency >
  85. Transparency** to **Alpha Scissor** in StandardMaterial3D, and adjust
  86. **Transparency > Alpha Scissor Threshold** accordingly if needed. Note that
  87. MSAA will not antialias the texture's edges unless alpha antialiasing is
  88. enabled in the material's properties. However, FXAA, TAA and supersampling
  89. will be able to antialias the texture's edges regardless of whether alpha
  90. antialiasing is enabled on the material.
  91. - If you need to render semi-transparent areas of the texture, alpha scissor
  92. isn't suitable. Instead, setting the StandardMaterial3D's
  93. **Transparency > Transparency** property to **Depth Pre-Pass** can sometimes
  94. work (at a performance cost). You can also try the **Alpha Hash** mode.
  95. - If you want a material to fade with distance, use the StandardMaterial3D
  96. distance fade mode **Pixel Dither** or **Object Dither** instead of
  97. **PixelAlpha**. This will make the material opaque, which also speeds up rendering.
  98. Multi-sample antialiasing
  99. -------------------------
  100. .. seealso::
  101. Antialiasing is explained in detail on the :ref:`doc_3d_antialiasing` page.
  102. Multi-sample antialiasing (MSAA) takes multiple *coverage* samples at the edges
  103. of polygons when rendering objects. It does not increase the number of *color*
  104. samples used to render a scene. Here's what this means in practice:
  105. - Edges of meshes will be smoothed out nicely (as well as supersampling would).
  106. - Transparent materials that use *alpha testing* (1-bit transparency) won't be smoothed out.
  107. - Specular aliasing ("sparkles" that appear on reflective surfaces) won't be reduced.
  108. There are several ways to work around this limitation depending on your performance budget:
  109. - To make specular aliasing less noticeable, open the Project Settings and enable
  110. **Rendering > Quality > Screen Space Filters > Screen Space Roughness Limiter**.
  111. This filter has a moderate cost on performance, so it should only be enabled if
  112. you actually need it.
  113. - Enable fast approximate antialiasing (FXAA) in addition to (or instead of)
  114. MSAA. Since FXAA is a screen-space antialiasing method, it will smooth out
  115. anything. As a downside, FXAA also makes the scene appear blurrier, especially
  116. at resolutions below 1440p. FXAA also lacks temporal information, which means
  117. its impact on specular aliasing is limited.
  118. - Enable temporal antialiasing (TAA) in addition to (or instead of) MSAA. Since
  119. TAA is a screen-space antialiasing method, it will smooth out anything. As a
  120. downside, TAA also makes the scene appear blurrier, especially at resolutions
  121. below 1440p. TAA provides superior quality compared to FXAA and can
  122. effectively combat specular aliasing. However, TAA has a greater performance
  123. cost compared to FXAA, and TAA can introduce ghosting artifacts with fast
  124. movement.
  125. - Render the scene at a higher resolution by increasing the **Scaling 3D >
  126. Scale** project setting above ``1.0``. This technique is called supersample
  127. antialiasing (SSAA) and is very slow. Its use is generally only recommended
  128. for offline rendering.