Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Обмеження 3D відображення

Вступ

Візуалізатор Godot, як і інші графічні рушії, що працюють в реальному часі, має багато обмежень у зв'язку з тим, що він орієнтований на швидкість. Для того, щоб ефективно працювати з цими обмеженнями, необхідно знати про них.

Межі розміру текстури

Більш старі ПК та ноутбуки можуть не підтримувати текстури більші ніж 8192×8192. Ви можете перевірити свій графічний процесор на GPUinfo.org.

Мобільні ГП зазвичай обмежують розмір текстур до 4096×4096. Окрім цього, деякі мобільні ГП не підтримують повторення текстур, розмір яких не є степенем двійки. Тому, якщо ви хочете, щоб ваша текстура правильно відображалась на всіх платформах то вам варто уникати текстур більших ніж 4096×4096 чи таких що мають розмір не степені двійки, якщо текстуру потрібно повторювати.

To limit the size of a specific texture that may be too large to render, you can set the Process > Size Limit import option to a value greater than 0. This will reduce the texture's dimensions on import (preserving aspect ratio) without affecting the source file.

Розшарування кольорів

When using the Forward+ or Forward Mobile rendering methods, Godot's 3D engine renders internally in HDR. However, the rendering output will be tonemapped to a low dynamic range so it can be displayed on the screen. This can result in visible banding, especially when using untextured materials. For performance reasons, color precision is also lower when using the Forward Mobile rendering method compared to Forward+.

When using the Compatibility rendering method, HDR 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.

Побороти розшарування можна двома способами:

  • If using the Forward+ or Forward Mobile rendering methods, enable Use Debanding in the advanced Project Settings. 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)

Дивись також

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

Точність буфера глибини

Візуалізатори використовують буфер глибини (який іноді називають Z-буфер) щоб відсортувати об'єкти в тривимірному просторі. Цей буфер має обмежену точність: 24 біти на комп'ютерах та 16 біт на мобільних пристроях (це питання продуктивности). Якщо два об'єкти мають однакове значення в буфері, то відбудеться конфлікт між ними. Виглядає це як постійне мерехтіння текстур взад-перед коли камера рухається чи обертається.

Щоби буфер точніше працював з областю, що відображається, варто збільшити параметр вузла камери Near (ближня межа). Але будьте обережні: якщо задати надто високе значення, гравець може почати дивитись крізь ближні об'єкти. Також варто зменшити параметр камери Far (дальня межа) наскільки це можливо. Проте пам'ятайте, що він не так сильно впливає на точність як „Near“.

Якщо вам потрібна висока точність лише коли гравець дивиться в далечінь, то ви можете змінювати її на ходу, залежно від ситуації. Для прикладу, якщо гравець сідає в літак, то параметр Near можна збільшити щоб уникнути конфліктів за Z-буфер на відстані. Значення можна зменшити щойно гравець покине літак.

Залежно від сцени та умов, у вас може бути можливість просто розсунути конфліктні об'єкти один від одного без суттєвого впливу на вигляд сцени.

Z-fighting comparison (before and after tweaking the scene by offsetting the Label3D away from the floor)

Z-fighting comparison (before and after tweaking the scene by offsetting the Label3D away from the floor)

Перебір по прозорості

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.

Деякі візуалізатори мають змогу побороти це використовуючи порядко-незалежну прозорість, але вона сильно навантажує відеоприскорювач. На даний момент, Godot не має таких можливостей. Але у вас є декілька шляхів уникнення проблеми:

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

Багатовибіркове згладжування

Дивись також

Antialiasing is explained in detail on the 3D antialiasing page.

Багатовибіркове зглажування (MSAA) бере декілька наборів покривають пікселів на ребрах полігонів коли об'єкти відображаються. Воно не збільшує кількости кольорових пікселів що використані у сцені. Що це значить на практиці:

  • Ребра геометричних фігур будуть гладенькими (такими ж, якими вони були б при перевибірковому згладжуванні).

  • Прозорі матеріяли, що використовують alpha testing (однобітну прозорість) не будуть згладжуватись.

  • Відблиски на блискучих поверхнях не будуть згладжуватись.

Залежно від величини продуктивності, якою ви можете пожертвувати, ви можете обійти вищезгадані обмеження таким чином:

  • To make specular aliasing less noticeable, open the Project Settings and enable Rendering > Quality > Screen Space Filters > Screen Space Roughness Limiter. This filter has a moderate cost on performance, so it should only be enabled if you actually need it.

  • Enable fast approximate antialiasing (FXAA) in addition to (or instead of) MSAA. Since FXAA is a screen-space antialiasing method, it will smooth out anything. As a downside, FXAA also makes the scene appear blurrier, especially at resolutions below 1440p. FXAA also lacks temporal information, which means its impact on specular aliasing is limited.

  • Enable temporal antialiasing (TAA) in addition to (or instead of) MSAA. Since TAA is a screen-space antialiasing method, it will smooth out anything. As a downside, TAA also makes the scene appear blurrier, especially at resolutions below 1440p. TAA provides superior quality compared to FXAA and can effectively combat specular aliasing. However, TAA has a greater performance cost compared to FXAA, and TAA can introduce ghosting artifacts with fast movement.

  • Render the scene at a higher resolution by increasing the Scaling 3D > Scale project setting above 1.0. This technique is called supersample antialiasing (SSAA) and is very slow. Its use is generally only recommended for offline rendering.