3d_rendering_limitations.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. Transparency sorting
  62. --------------------
  63. In Godot, transparent materials are drawn after opaque materials. Transparent
  64. objects are sorted back to front before being drawn based on the Node3D's
  65. position, not the vertex position in world space. Due to this, overlapping
  66. objects may often be sorted out of order. To fix improperly sorted objects, tweak
  67. the material's :ref:`Render Priority <class_Material_property_render_priority>`
  68. property. This will force specific materials to appear in front or behind of
  69. other transparent materials. Even then, this may not always be sufficient.
  70. Some rendering engines feature *order-independent transparency* techniques to
  71. alleviate this, but this is costly on the GPU. Godot currently doesn't provide
  72. this feature. There are still several ways to avoid this problem:
  73. - Only make materials transparent if you actually need it. If a material only
  74. has a small transparent part, consider splitting it into a separate material.
  75. This will allow the opaque part to cast shadows and may also improve
  76. performance.
  77. - If you want a material to fade with distance, use the SpatialMaterial
  78. distance fade mode **Pixel Dither** or **Object Dither** instead of
  79. **PixelAlpha**. This will make the material opaque. This way, it can also
  80. cast shadows.
  81. Multi-sample antialiasing
  82. -------------------------
  83. Multi-sample antialiasing (MSAA) takes multiple *coverage* samples at the edges
  84. of polygons when rendering objects. It does not increase the number of *color*
  85. samples used to render a scene. Here's what this means in practice:
  86. - Edges of meshes will be smoothed out nicely (as well as supersampling would).
  87. - Transparent materials that use *alpha testing* (1-bit transparency) won't be smoothed out.
  88. - Specular aliasing ("sparkles" that appear on reflective surfaces) won't be reduced.
  89. There are several ways to work around this limitation depending on your performance budget:
  90. - To make specular aliasing less noticeable, open the Project Settings and enable
  91. **Rendering > Quality > Screen Space Filters > Screen Space Roughness Limiter**.
  92. This filter has a moderate cost on performance. It should be enabled only if
  93. you actually need it.
  94. - Enable FXAA in addition to (or instead of) MSAA. Since FXAA is a screen-space
  95. antialiasing method, it will smooth out anything. As a downside, it will also
  96. make the scene appear blurrier, especially at resolutions below 1440p.
  97. - Render the scene at a higher resolution, then display it in a ViewportTexture
  98. that matches the window size. Make sure to enable **Filter** on the
  99. ViewportTexture flags. This technique is called *supersampling* and is very
  100. slow. Its use is generally only recommended for offline rendering.