3d_rendering_limitations.rst 7.7 KB

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