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.

Limitações da renderização 3D

Introdução

Devido a seu foco no desempenho, os motores de renderização em tempo real têm muitas limitações. O renderizador Godot não é exceção. Para trabalhar eficazmente com essas limitações, você precisa compreendê-las.

Limites de tamanho da textura

Em desktops e laptops, texturas maiores que 8192×8192 podem não ser suportadas em dispositivos mais antigos. Você pode verificar as limitações de sua GPU de destino em GPUinfo.org.

As GPUs mobiles são tipicamente limitadas a 4096×4096 texturas. Além disso, algumas GPUs mobiles não suportam a repetição de texturas sem poder de dois tamanhos. Portanto, se você quiser que sua textura seja exibida corretamente em todas as plataformas, você deve evitar usar texturas maiores que 4096×4096 e usar uma potência de dois tamanhos se a textura precisar repetir.

Para limitar o tamanho de uma textura específica que pode ser grande demais para renderizar, você pode definir a opção de importação Process > Size Limit para um valor maior que 0. Isso reduzirá as dimensões da textura na importação (preservando a proporção) sem afetar o arquivo de origem.

Faixas de cores

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.

Existem duas maneiras principais de aliviar as bandas:

  • Se estiver usando os métodos de renderização Avançado+ ou Forward Mobile, ative Use Debanding em Configurações do Projeto > Rendering > Anti Aliasing. Isso aplica um shader de debanding em tela cheia como um efeito de pós-processamento e tem custo muito baixo.

  • 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.

Comparação de faixas de cor (contraste aumentado para maior visibilidade)

Comparação de faixas de cor (contraste aumentado para maior visibilidade)

Ver também

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

Precisão do buffer de profundidade

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.

Para tornar o buffer de profundidade mais preciso sobre a área renderizada, você deve aumentar a propriedade Near do nó da câmera. No entanto, tenha cuidado: se você definir muito alto, os jogadores poderão ver através da geometria próxima. Você também deve diminuir a propriedade Far do nó Câmera para o menor valor permitido para o seu caso de uso, embora tenha em mente que isso não afetará a precisão tanto quanto a propriedade Near.

Se você só precisa de alta precisão quando o jogador pode ver de longe, você pode mudá-lo dinamicamente com base nas condições do jogo. Por exemplo, se o jogador entrar em um avião, a propriedade Perto pode ser temporariamente aumentada para evitar a luta Z na distância. Ela pode então ser diminuída quando o jogador deixa o avião.

Dependendo da cena e das condições de visualização, você também pode ser capaz de mover os objetos na luta em Z mais distantes, sem que a diferença seja visível para o jogador.

Comparação de Z-fighting (antes e depois de ajustar a cena deslocando o Label3D para longe do chão)

Comparação de Z-fighting (antes e depois de ajustar a cena deslocando o Label3D para longe do chão)

Classificação por transparência

In Godot, transparent materials are drawn after opaque materials. Transparent objects are sorted back to front before being drawn based on the Node3D's position, not the vertex position in world space. Due to this, overlapping objects may often be sorted out of order. To fix improperly sorted objects, tweak the material's Render Priority property or the node's Sorting Offset. Render Priority will force specific materials to appear in front of or behind other transparent materials, while Sorting Offset will move the object forward or backward for the purpose of sorting. Even then, these may not always be sufficient.

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.

Alguns mecanismos de renderização apresentam técnicas de transparência independente da ordem para aliviar isso, mas isso é caro para a GPU. Godot atualmente não fornece esse recurso. Ainda existem várias maneiras de evitar esse problema:

  • 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.

Comparação de ordenação de transparência (materiais com mistura alfa à esquerda, materiais com recorte alfa à direita)

Comparação de ordenação de transparência (materiais com mistura alfa à esquerda, materiais com recorte alfa à direita)