Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Limitazioni del rendering 3D

Introduzione

Poiché danno priorità alle prestazioni, i motori di rendering in tempo reale hanno numerose limitazioni. Il renderer di Godot non fa eccezione. Per lavorare efficacemente con tali limitazioni, è necessario comprenderle.

Limiti di dimensioni delle texture

Su desktop e laptop, le texture con risoluzioni superiori a 8192×8192 potrebbero non essere supportate sui dispositivi più vecchi. È possibile verificare le limitazioni della GPU di interesse su GPUinfo.org.

Mobile GPUs are typically limited to 4096×4096 textures. Also, some mobile GPUs don't support repeating non-power-of-two-sized textures. Therefore, if you want your texture to display correctly on all platforms, you should avoid using textures larger than 4096×4096 and use a power of two size if the texture needs to repeat.

Per limitare le dimensioni di una specifica texture che potrebbe essere troppo grande da renderizzare, è possibile impostare l'opzione di importazione Process > Size Limit su un valore maggiore di 0. Facendo così, le dimensioni della texture saranno ridotte durante l'importazione (mantenendo le proporzioni) senza influire sul file sorgente.

Color banding

When using the Forward+ or Mobile rendering methods, Godot's 3D engine renders internally in HDR. However, the rendering output will typically be written to a lower precision buffer. This can result in visible banding, especially when using untextured materials. For performance reasons, color precision is also lower when using the Mobile rendering method compared to Forward+.

When using the Compatibility rendering method, internal HDR rendering is not used and the color precision is the lowest of all rendering methods. This also applies to 2D rendering, where banding may be visible when using smooth gradient textures.

Esistono due modi principali per alleviare il banding:

  • If using the Forward+ or Forward Mobile rendering methods, enable Use Debanding in Project Settings > Rendering > Anti Aliasing. This applies a fullscreen debanding shader as a post-processing effect and is very cheap.

  • Alternatively, bake some noise into your textures. This is mainly effective in 2D, e.g. for vignetting effects. In 3D, you can also use a custom debanding shader to be applied on your materials. This technique works even if your project is rendered with low color precision, which means it will work when using the Mobile and Compatibility rendering methods.

Color banding comparison (contrast increased for more visibility)

Color banding comparison (contrast increased for more visibility)

Vedi anche

See Banding in Games: A Noisy Rant (PDF) for more details about banding and ways to combat it.

Depth buffer precision

To sort objects in 3D space, rendering engines rely on a depth buffer (also called Z-buffer). This buffer has a finite precision: 32-bit on desktop platforms, 24-bit on mobile platforms (for performance reasons). If two different objects end up on the same buffer value, then Z-fighting will occur. This will materialize as textures flickering back and forth as the camera moves or rotates.

To make the depth buffer more precise over the rendered area, you should increase the Camera node's Near property. However, be careful: if you set it too high, players will be able to see through nearby geometry. You should also decrease the Camera node's Far property to the lowest permissible value for your use case, though keep in mind it won't impact precision as much as the Near property.

If you only need high precision when the player can see far away, you could change it dynamically based on the game conditions. For instance, if the player enters an airplane, the Near property can be temporarily increased to avoid Z-fighting in the distance. It can then be decreased once the player leaves the airplane.

Depending on the scene and viewing conditions, you may also be able to move the Z-fighting objects further apart without the difference being visible to the player.

Confronto di Z-fighting (prima e dopo aver ritoccato la scena scostando il Label3D lontano dal pavimento)

Confronto di Z-fighting (prima e dopo aver ritoccato la scena scostando il Label3D lontano dal pavimento)

Transparency sorting

In Godot, i materiali trasparenti sono disegnati dopo quelli opachi. Gli oggetti trasparenti sono ordinati in avanti prima di essere disegnati in base alla posizione del Node3D, non alla posizione dei vertici nello spazio globale. Per questo motivo, è possibile che gli oggetti sovrapposti siano ordinati incorrettamente. Per correggerli, modifica la proprietà Render Priority del materiale o Sorting Offset del nodo. La priorità di rendering forza materiali specifici a comparire davanti o dietro altri materiali trasparenti, mentre l'offset di ordinamento sposta l'oggetto avanti o indietro per l'ordinamento. Anche così, non sempre queste impostazioni potrebbero bastare.

Transparent objects are not rendered to the normal-roughness buffer, as they are drawn after opaque geometry. As a result, features that rely on the normal-roughness buffer will not affect transparent materials.

Some rendering engines feature order-independent transparency techniques to alleviate this, but this is costly on the GPU. Godot currently doesn't provide this feature. There are still several ways to avoid this problem:

  • Only make materials transparent if you actually need it. If a material only has a small transparent part, consider splitting it into a separate material. This will allow the opaque part to cast shadows and will also improve performance.

  • If your texture mostly has fully opaque and fully transparent areas, you can use alpha testing instead of alpha blending. This transparency mode is faster to render and doesn't suffer from transparency issues. Enable Transparency > Transparency to Alpha Scissor in StandardMaterial3D, and adjust Transparency > Alpha Scissor Threshold accordingly if needed. Note that MSAA will not antialias the texture's edges unless alpha antialiasing is enabled in the material's properties. However, FXAA, TAA and supersampling will be able to antialias the texture's edges regardless of whether alpha antialiasing is enabled on the material.

  • If you need to render semi-transparent areas of the texture, alpha scissor isn't suitable. Instead, setting the StandardMaterial3D's Transparency > Transparency property to Depth Pre-Pass can sometimes work (at a performance cost). You can also try the Alpha Hash mode.

  • If you want a material to fade with distance, use the StandardMaterial3D distance fade mode Pixel Dither or Object Dither instead of Pixel Alpha. This will make the material opaque, which also speeds up rendering.

Transparency sorting comparison (alpha-blended materials on the left, alpha scissor materials on the right)

Transparency sorting comparison (alpha-blended materials on the left, alpha scissor materials on the right)