3d_rendering_limitations.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 several ways to alleviate banding. Here are a few examples:
  27. - Bake some noise into your textures. This is mainly effective in 2D, e.g. for
  28. vignetting effects.
  29. - Implement a debanding shader as a :ref:`screen-reading shader <doc_screen-reading_shaders>`.
  30. Godot currently doesn't provide a built-in debanding shader, but this may be
  31. added in a future release.
  32. .. seealso::
  33. See `Banding in Games: A Noisy Rant <http://loopit.dk/banding_in_games.pdf>`__
  34. for more details about banding and ways to combat it.
  35. Depth buffer precision
  36. ----------------------
  37. To sort objects in 3D space, rendering engines rely on a *depth buffer* (also
  38. called *Z-buffer*). This buffer has a finite precision: 24-bit on desktop
  39. platforms, sometimes 16-bit on mobile platforms (for performance reasons). If
  40. two different objects end up on the same buffer value, then Z-fighting will
  41. occur. This will materialize as textures flickering back and forth as the camera
  42. moves or rotates.
  43. To make the depth buffer more precise over the rendered area, you should
  44. *increase* the Camera node's **Near** property. However, be careful: if you set
  45. it too high, players will be able to see through nearby geometry. You should
  46. also *decrease* the Camera node's **Far** property to the lowest permissible value
  47. for your use case, though keep in mind it won't impact precision as much as the
  48. **Near** property.
  49. If you only need high precision when the player can see far away, you could
  50. change it dynamically based on the game conditions. For instance, if the player
  51. enters an airplane, the **Near** property can be temporarily increased to avoid
  52. Z-fighting in the distance. It can then be decreased once the player leaves the
  53. airplane.
  54. Depending on the scene and viewing conditions, you may also be able to move the
  55. Z-fighting objects further apart without the difference being visible to the
  56. player.
  57. Transparency sorting
  58. --------------------
  59. In Godot, transparent materials are drawn after opaque materials. Transparent
  60. objects are sorted back to front before being drawn based on the Node3D's
  61. position, not the vertex position in world space. Due to this, overlapping
  62. objects may often be sorted out of order. To fix improperly sorted objects, tweak
  63. the material's :ref:`Render Priority <class_Material_property_render_priority>`
  64. property. This will force specific materials to appear in front or behind of
  65. other transparent materials. Even then, this may not always be sufficient.
  66. Some rendering engines feature *order-independent transparency* techniques to
  67. alleviate this, but this is costly on the GPU. Godot currently doesn't provide
  68. this feature. There are still several ways to avoid this problem:
  69. - Only make materials transparent if you actually need it. If a material only
  70. has a small transparent part, consider splitting it into a separate material.
  71. This will allow the opaque part to cast shadows and may also improve
  72. performance.
  73. - If you want a material to fade with distance, use the SpatialMaterial
  74. distance fade mode **Pixel Dither** or **Object Dither** instead of
  75. **PixelAlpha**. This will make the material opaque. This way, it can also
  76. cast shadows.
  77. Multi-sample antialiasing
  78. -------------------------
  79. Multi-sample antialiasing (MSAA) takes multiple *coverage* samples at the edges
  80. of polygons when rendering objects. It does not increase the number of *color*
  81. samples used to render a scene. Here's what this means in practice:
  82. - Edges of meshes will be smoothed out nicely (as well as supersampling would).
  83. - Transparent materials that use *alpha testing* (1-bit transparency) won't be smoothed out.
  84. - Specular aliasing ("sparkles" that appear on reflective surfaces) won't be reduced.
  85. There are several ways to work around this limitation depending on your performance budget:
  86. - To make specular aliasing less noticeable, open the Project Settings and enable
  87. **Rendering > Quality > Screen Space Filters > Screen Space Roughness Limiter**.
  88. This filter has a moderate cost on performance. It should be enabled only if
  89. you actually need it.
  90. - Enable FXAA in addition to (or instead of) MSAA. Since FXAA is a screen-space
  91. antialiasing method, it will smooth out anything. As a downside, it will also
  92. make the scene appear blurrier, especially at resolutions below 1440p.
  93. - Render the scene at a higher resolution, then display it in a ViewportTexture
  94. that matches the window size. Make sure to enable **Filter** on the
  95. ViewportTexture flags. This technique is called *supersampling* and is very
  96. slow. Its use is generally only recommended for offline rendering.