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.

Luci e ombre 3D

Introduzione

Le sorgenti luminose emettono luce che si fonde ai materiali e produce un risultato visibile. La luce può provenire da diversi tipi di sorgenti in una scena:

  • Dal materiale stesso, sotto forma di colore di emissione (sebbene non influisca sugli oggetti vicini, a meno che non sia abilitata l'illuminazione precalcolata o indiretta nello spazio dello schermo).

  • Nodi di luce: DirectionalLight3D, OmniLight3D e SpotLight3D.

  • Luce ambientale in Environment o Sonde di riflessi.

  • Illuminazione globale (LightmapGI, VoxelGI o SDFGI).

Il colore di emissione è una proprietà del materiale. Si può saperne di più nel tutorial Standard Material 3D and ORM Material 3D.

Vedi anche

È possibile confrontare vari tipi di luci in azione attraverso il progetto demo Luci e ombre 3D.

Nodi di luce

Esistono tre tipi di nodi di luce: DirectionalLight3D, OmniLight3D e SpotLight3D. Diamo un'occhiata ai parametri più comuni per le luci:

../../_images/light_params.png

Ogni proprietà ha una funzione specifica:

  • Colore: colore base della luce emessa.

  • Energia: moltiplicatore di energia. Utile per saturare le luci o per lavorare con Illuminazione ad alta gamma dinamica.

  • Energia indiretta: moltiplicatore secondario utilizzato con la luce indiretta (rimbalzi della luce). Funziona con Using Lightmap global illumination, VoxelGI o SDFGI.

  • Energia della nebbia volumetrica: moltiplicatore secondario utilizzato con la nebbia volumetrica. Ha effetto solo quando la nebbia volumetrica è abilitata.

  • Negativa: la luce diventa sottrattiva anziché additiva. A volte è utile compensare manualmente alcuni angoli bui.

  • Speculare: influisce sull'intensità della macchia speculare negli oggetti colpiti da questa luce. A zero, questa luce diventa una luce puramente diffusa.

  • Modo di precalcolo: imposta la modalità di precalcolo per la luce. Consultare Using Lightmap global illumination.

  • Maschera di selezione: Gli oggetti che si trovano negli strati selezionati sottostanti saranno influenzati da questa luce. Si noti che gli oggetti disabilitati tramite questa maschera di culling proietteranno comunque ombre. Se non si desidera che gli oggetti disabilitati proiettino ombre, regolare la proprietà Proietta ombra su GeometryInstance3D al valore desiderato.

Vedi anche

Consultare Unità fisiche di luce e telecamera se si desidera utilizzare unità di misura del mondo reale per configurare l'intensità e la temperatura del colore delle luci.

Limiti al numero di luci

Quando si utilizza il renderer Forward+, Godot utilizza un approccio di clustering per l'illuminazione in tempo reale. È possibile aggiungere tutte le luci che desiderate (purché le prestazioni lo permettano). Tuttavia, esiste ancora un limite predefinito di 512 elementi cluster che possono essere presenti nella vista della telecamera attuale. Un elemento cluster è una luce omnidirezionale, un riflettore, una decalcomania o una sonda di riflessione. È possibile aumentare questo limite regolando Elementi clusterizzati massimi in Impostazioni del progetto > Rendering > Limiti > Costruttore cluster.

Utilizzando il renderer Mobile, c'è un limite di 8 OmniLight + 8 SpotLight per ogni risorsa mesh. C'è anche un limite di 256 OmniLight + 256 SpotLight che si possono renderizzare nella vista della telecamera attuale. Al momento non è possibile cambiare questi limiti.

Utilizzando il renderer Compatibilità, è possibile renderizzare fino a 8 OmniLight + 8 SpotLight per ogni risorsa mesh. È possibile aumentare questo limite nelle Impostazioni del progetto avanzate regolando il Numero massimo di elementi renderizzabili e/o Numero massimo di luci per oggetto in Rendering > Limiti > OpenGL, a scapito delle prestazioni e di tempi più lunghi per compilare gli shader. È possibile anche ridurre il limite per ridurre i tempi di compilazione degli shader e migliorare leggermente le prestazioni.

Con tutti i metodi di rendering, è possibile visualizzare fino a 8 DirectionalLight allo stesso tempo. Tuttavia, ogni DirectionalLight in più con ombre abilitate ridurrà la risoluzione effettiva delle ombre di ogni DirectionalLight. Questo perché l'atlante delle ombre direzionali è condiviso tra tutte le luci.

Se si supera il limite di rendering, le luci cominceranno a comparire e scomparire durante il movimento della telecamera, il che può essere fastidioso. Abilitare Dissolvenza a distanza sui nodi di luce può aiutare a ridurre questo problema, migliorando allo stesso tempo le prestazioni. Anche suddividere le mesh in porzioni più piccole può aiutare, soprattutto per la geometria dei livelli (il che migliora anche l'efficienza del culling).

Se è necessario renderizzare più luci di quante ne sia possibile in un certo renderer, considera di utilizzare lightmap precalcolate con la modalità di precalcolo delle luci impostata su Static. Questo consente alle luci di essere completamente precalcolare, rendendole anche molto più rapide da renderizzare. Si possono anche utilizzare materiali emissivi con qualsiasi tecnica di illuminazione globale al posto dei nodi di luce per emettere luce su un'area più ampia.

Mappatura delle ombre

Le luci possono facoltativamente proiettare ombre. Questo offre loro un maggiore realismo (la luce non raggiunge le aree occluse), ma può comportare un maggiore costo di prestazioni. Esiste un elenco di parametri generici per le ombre, ognuno dei quali ha una funzione specifica:

  • Enabled: Selezionare per abilitare la mappatura delle ombre in questa luce.

  • Opacità: Le aree occluse sono oscurate da questo fattore di opacità. Le ombre sono completamente opache normalmente, ma si può cambiare per renderle traslucide per una determinata luce.

  • Bias: Quando questo parametro è troppo basso, le ombre degli oggetti rischiano di proiettarsi su loro stessi. Quando è troppo alto, le ombre si separano dalla loro origine. Regolare il valore in base alle proprie esigenze.

  • Bias normale: Quando questo parametro è troppo basso, le ombre degli oggetti rischiano di proiettarsi su loro stessi. Quando è troppo alto, le ombre appaiono disallineate rispetto alla loro origine. Regolare il valore in base alle proprie esigenze.

  • Transmittance Bias: When this parameter is too low, self-shadowing occurs on materials that have transmittance enabled. When too high, shadows will not affect materials that have transmittance enabled consistently. Tweak to what works best for you.

  • Reverse Cull Face: Some scenes work better when shadow mapping is rendered with face-culling inverted.

  • Blur: Multiplies the shadow blur radius for this light. This works with both traditional shadow mapping and contact-hardening shadows (lights with Angular Distance or Size greater than 0.0). Higher values result in softer shadows, which will also appear to be more temporally stable for moving objects. The downside of increasing shadow blur is that it will make the grainy pattern used for filtering more noticeable. See also Modalità di filtro delle ombre.

  • Caster Mask: Shadows are only cast by objects in these layers. Note that this mask does not affect which objects shadows are cast onto.

../../_images/lights_and_shadows_blur.webp

Aggiustare il bias delle ombre

Di seguito è riportata un'immagine che mostra cosa succede regolando il bias. I valori predefiniti funzionano nella maggior parte dei casi, ma in generale, dipendono dalle dimensioni e dalla complessità della geometria.

If the Shadow Bias or Shadow Normal Bias is set too low for a given light, the shadow will be "smeared" onto the objects. This will cause the light's intended appearance to darken, and is called shadow acne:

../../_images/lights_and_shadows_acne.webp

On the other hand, if the Shadow Bias or Shadow Normal Bias is set too high for a given light, the shadow may appear to be disconnected from the object. This is called peter-panning:

../../_images/lights_and_shadows_peter_panning.webp

In general, increasing Shadow Normal Bias is preferred over increasing Shadow Bias. Increasing Shadow Normal Bias does not cause as much peter-panning as increasing Shadow Bias, but it can still resolve most shadow acne issues efficiently. The downside of increasing Shadow Normal Bias is that it can make shadows appear thinner for certain objects.

Any sort of bias issues can be fixed by increasing the shadow map resolution, at the cost of decreased performance.

Nota

Tweaking shadow mapping settings is an art – there are no "one size fits all" settings. To achieve the best visuals, you may need to use different shadow bias values on a per-light basis.

Note on Appearance Changes: When enabling shadows on a light, be aware that the light's appearance might change compared to when it's rendered without shadows in the compatibility renderer. Due to limitations with older mobile devices, shadows are implemented using a multi-pass rendering approach so lights with shadows are rendered in sRGB space instead of linear space. This change in rendering space can sometimes drastically alter the light's appearance. To achieve a similar appearance to an unshadowed light, you may need to adjust the light's energy setting.

Luce direzionale

This is the most common type of light and represents a light source very far away (such as the sun). It is also the cheapest light to compute and should be used whenever possible (although it's not the cheapest shadow-map to compute, but more on that later).

Directional light models an infinite number of parallel light rays covering the whole scene. The directional light node is represented by a big arrow which indicates the direction of the light rays. However, the position of the node does not affect the lighting at all and can be anywhere.

../../_images/light_directional.png

Every face whose front-side is hit by the light rays is lit, while the others stay dark. Unlike most other light types, directional lights don't have specific parameters.

The directional light also offers an Angular Distance property, which determines the light's angular size in degrees. Increasing this above 0.0 will make shadows softer at greater distances from the caster, while also affecting the sun's appearance in procedural sky materials. This is called a contact-hardening shadow (also known as PCSS).

Per riferimento, la distanza angolare del Sole visto dalla Terra è di circa 0.5. Questo tipo di ombra è costoso, quindi dare un'occhiata le raccomandazioni in Raccomandazioni per PCSS se si imposta questo valore oltre 0.0 sulle luci con ombre abilitate.

Mappatura delle ombre direzionali

Per calcolare le mappe delle ombre, la scena è renderizzata (solo la profondità) da un punto di vista ortogonale che copre l'intera scena (o fino alla distanza massima). C'è, tuttavia, un problema con questo approccio, perché gli oggetti più vicini alla telecamera ricevono ombre a bassa risoluzione che possono apparire squadrate.

To fix this, a technique named Parallel Split Shadow Maps (PSSM) is used. This splits the view frustum in 2 or 4 areas. Each area gets its own shadow map. This allows small areas close to the viewer to have the same shadow resolution as a huge, far-away area. When shadows are enabled for DirectionalLight3D, the default shadow mode is PSSM with 4 splits. In scenarios where an object is large enough to appear in all four splits, it results in increased draw calls. Specifically, such an object will be rendered five times in total: once for each of the four shadow splits and once for the final scene rendering. This can impact performance, understanding this behavior is important for optimizing your scene and managing performance expectations.

../../_images/lights_and_shadows_pssm_explained.webp

With this, shadows become more detailed:

../../_images/lights_and_shadows_directional_mode.webp

Per controllare PSSM, sono esposti vari parametri:

../../_images/lights_and_shadows_directional_shadow_params.webp

Each split distance is controlled relative to the camera far (or shadow Max Distance if greater than 0.0). 0.0 is the eye position and 1.0 is where the shadow ends at a distance. Splits are in-between. Default values generally work well, but tweaking the first split a bit is common to give more detail to close objects (like a character in a third-person game).

Always make sure to set a shadow Max Distance according to what the scene needs. A lower maximum distance will result in better-looking shadows and better performance, as fewer objects will need to be included in shadow rendering. You can also adjust Fade Start to control how aggressive the shadow fade-out should be at a distance. For scenes where the Max Distance fully covers the scene at any given camera position, you can increase Fade Start to 1.0 to prevent the shadow from fading at a distance. This should not be done in scenes where Max Distance doesn't fully cover the scene, as the shadow will appear to be suddenly cut off at a distance.

Sometimes, the transition between a split and the next can look bad. To fix this, the Blend Splits option can be turned on, which sacrifices detail and performance in exchange for smoother transitions:

../../_images/blend_splits.png

The Shadow > Normal Bias parameter can be used to fix special cases of self-shadowing when objects are perpendicular to the light. The only downside is that it makes the shadow a bit thinner. Consider increasing Shadow > Normal Bias before increasing Shadow > Bias in most situations.

Lastly, Pancake Size is a property that can be adjusted to fix missing shadows when using large objects with unsubdivided meshes. Only change this value if you notice missing shadows that are not related to shadow biasing issues.

Luce omnidirezionale

Omni light is a point source that emits light spherically in all directions up to a given radius.

../../_images/light_omni.png

In real life, light attenuation is an inverse function, which means omni lights don't have a radius. This is a problem because it means computing several omni lights would become demanding.

To solve this, a Range parameter is introduced together with an attenuation function.

../../_images/light_omni_params.png

These two parameters allow tweaking how this works visually in order to find aesthetically pleasing results.

../../_images/light_attenuation.png

A Size parameter is also available in OmniLight3D. Increasing this value will make the light fade out slower and shadows appear blurrier when far away from the caster. This can be used to simulate area lights to an extent. This is called a contact-hardening shadow (also known as PCSS). This kind of shadow is expensive, so check the recommendations in Raccomandazioni per PCSS if setting this value above 0.0 on lights with shadows enabled.

../../_images/lights_and_shadows_pcss.webp

Omni shadow mapping

Omni light shadow mapping is relatively straightforward. The main issue that needs to be considered is the algorithm used to render it.

Omni Shadows can be rendered as either Dual Paraboloid or Cube mapped. Dual Paraboloid renders quickly, but can cause deformations, while Cube is more correct, but slower. The default is Cube, but consider changing it to Dual Paraboloid for lights where it doesn't make much of a visual difference.

../../_images/lights_and_shadows_dual_parabolid_vs_cubemap.webp

If the objects being rendered are mostly irregular and subdivided, Dual Paraboloid is usually enough. In any case, as these shadows are cached in a shadow atlas (more on that at the end), it may not make a difference in performance for most scenes.

Omni lights with shadows enabled can make use of projectors. The projector texture will multiply the light's color by the color at a given point on the texture. As a result, lights will usually appear to be darker once a projector texture is assigned; you can increase Energy to compensate for this.

Le texture di proiettore per le luci omnidirezionali richiedono una mappatura speciale panoramica a 360°, simile alle texture di PanoramaSkyMaterial.

Con la texture di proiettore mostrata di seguito, si ottiene il seguente risultato:

../../_images/lights_and_shadows_omni_projector_example.webp ../../_images/lights_and_shadows_omni_projector.webp

Suggerimento

Se hai acquisito proiettori omnidirezionali sotto forma di immagini cubemap, puoi utilizzare questo strumento di conversione sul web per convertirle in un'unica immagine panoramica.

Spot light

Spot lights are similar to omni lights, except they emit light only into a cone (or "cutoff"). They are useful to simulate flashlights, car lights, reflectors, spots, etc. This type of light is also attenuated towards the opposite direction it points to.

Spot lights share the same Range, Attenuation and Size as OmniLight3D, and add two extra parameters:

  • Angle: l'angolo di apertura della luce.

  • Angle Attenuation: l'attenuazione del cono, che contribuisce a sfumare i bordi del cono.

Spot shadow mapping

Spots feature the same parameters as omni lights for shadow mapping. Rendering spot shadow maps is significantly faster compared to omni lights, as only one shadow texture needs to be rendered (instead of rendering 6 faces, or 2 in dual paraboloid mode).

Spot lights with shadows enabled can make use of projectors. The projector texture will multiply the light's color by the color at a given point on the texture. As a result, lights will usually appear to be darker once a projector texture is assigned; you can increase Energy to compensate for this.

Unlike omni light projectors, a spot light projector texture doesn't need to follow a special format to look correct. It will be mapped in a way similar to a decal.

Con la texture di proiettore mostrata di seguito, si ottiene il seguente risultato:

../../_images/lights_and_shadows_spot_projector_example.webp ../../_images/lights_and_shadows_spot_projector.webp

Nota

Spot lights with wide angles will have lower-quality shadows than spot lights with narrow angles, as the shadow map is spread over a larger surface. At angles wider than 89 degrees, spot light shadows will stop working entirely. If you need shadows for wider lights, use an omni light instead.

Area light

Sometimes, you want lighting to come from a large area instead of a single point. Area lights are useful for simulating soft, diffuse lighting, such as light coming from a window or a lit billboard. This type of light is expensive to render in real-time, so it should be used sparingly, especially when shadows are enabled.

Godot provides the AreaLight3D node for this purpose, which emits light from a rectangular area. The node only emits light and has no other visual representation in the scene. The screenshots below use a Sprite3D node as a child of the area light for visualization purposes.

Area lights can also cast shadows, with variable penumbra simulated using PCSS by default. The size of this penumbra can be controlled with the Light3D Size property. This effect can be quite demanding, so it can be turned off by setting Size to 0.0.

Nota

Shadows cast by an area light may look incorrect if the object casting shadows doesn't have enough subdivisions and it's very close to the area light. This is the same limitation as Dual Paraboloid shadow mode on an omni light.

../../_images/lights_and_shadows_area_example.webp

Nota

Since area lights are difficult to simulate in a real-time rasterized renderer, they come with a number of limitations.

For small light sources, you will likely get better results when using point lights. Shadows from area lights are crude approximations, as they are calculated as if they were point lights, and may appear to be distorted at the edges. To get a better result, make sure the meshes in the light's range are sufficiently subdivided.

Area lights suffer from light leaking on the backside of geometry closely in front of them at grazing angles, so be careful with where you place them.

Lastly, not all material features are fully supported; area lights are practically limited to Lambertian diffuse and GGX specular shading, while anisotropic materials will appear as if isotropic. Vertex shading is also not implemented for area lights.

Area lights emit light in a rectangular area defined by the Area > Size property (not to be confused with the generic Light3D Size property). To get a physically accurate result, you should resize this area to match the size of the real-life light source you are trying to simulate. For example, if you are simulating a 1-meter neon tube that is 10 centimeters wide, set the area size to (1, 0.1) and adjust the energy accordingly.

By default, the light's energy is normalized: the larger the area, the weaker the light. This allows you to change the area size without needing to adjust the energy to compensate, which is useful for animation. You can disable this behavior by unchecking Area > Normalize Energy if you want the energy to be independent of the area size.

The rectangular area can optionally be textured. This can be effectively used to change the light's shape into any 2D shape, or tint it in different colors. The texture's alpha channel is treated as black (no light coming through). The area light's texture will be visible in reflections according to the surface's roughness. This behavior is different from omni/spot projectors, as it does not project the texture directly onto all diffuse lighting.

When using a textures that are transparent or black toward the edges, you might want to leave a gap of a few pixels to make sure the texture is blurred smoothly.

../../_images/lights_and_shadows_area_texture.webp

Nota

Changing the area light's texture at runtime can be expensive, especially if the texture is large.

To reduce the performance impact of switching textures at runtime, make sure each dimension of an area texture is either a multiple of 128 pixels, or a power of two. This removes the need for a scaling pass, which slows down texture changes. The textures don't necessarily have to be square to be optimal. Examples of optimal texture sizes include 32×64, 128×128, and 256×384.

Textured area lights are not supported in the Compatibility renderer.

Atlante delle ombre

Unlike Directional lights, which have their own shadow texture, omni and spot lights are assigned to slots of a shadow atlas. This atlas can be configured in the advanced Project Settings (Rendering > Lights And Shadows > Positional Shadow).

The resolution applies to the whole shadow atlas. This atlas is divided into four quadrants:

../../_images/lights_and_shadows_shadow_quadrants.webp

Each quadrant can be subdivided to allocate any number of shadow maps; the following is the default subdivision:

../../_images/lights_and_shadows_shadow_quadrants2.webp

The shadow atlas allocates space as follows:

  • The biggest shadow map size (when no subdivision is used) represents a light the size of the screen (or bigger).

  • Subdivisions (smaller maps) represent shadows for lights that are further away from view and proportionally smaller.

Every frame, the following procedure is performed for all lights:

  1. Check if the light is on a slot of the right size. If not, re-render it and move it to a larger/smaller slot.

  2. Check if any object affecting the shadow map has changed. If it did, re-render the light.

  3. If neither of the above has happened, nothing is done, and the shadow is left untouched.

If the slots in a quadrant are full, lights are pushed back to smaller slots, depending on size and distance. If all slots in all quadrants are full, some lights will not be able to render shadows even if shadows are enabled on them.

La strategia predefinita di allocazione delle ombre consente di renderizzare un massimo di 88 luci con ombre abilitate nel frustum della telecamera (4 + 4 + 16 + 64):

  1. Il primo e più dettagliato quadrante può memorizzare 4 ombre.

  2. Il secondo quadrante può contenere altre 4 ombre.

  3. Il terzo quadrante può memorizzare 16 ombre, con meno dettagli.

  4. Il quarto e meno dettagliato quadrante può memorizzare 64 ombre, con ancora meno dettagli.

Using a higher number of shadows per quadrant allows supporting a greater amount of total lights with shadows enabled, while also improving performance (as shadows will be rendered at a lower resolution for each light). However, increasing the number of shadows per quadrant comes at the cost of lower shadow quality.

In alcuni casi, potrebbe essere opportuno utilizzare una strategia di allocazione diversa. Ad esempio, in un gioco con visuale dall'alto in cui tutte le luci hanno più o meno le stesse dimensioni, si potrebbe voler impostare tutti i quadranti con la stessa suddivisione in modo che tutte le luci abbiano ombre con un simile livello di qualità.

Equilibrare le prestazioni e la qualità

Il rendering delle ombre è un aspetto cruciale per le prestazioni del rendering 3D. È importante fare le scelte giuste per evitare di creare colli di bottiglia.

Le impostazioni di qualità delle ombre direzionali si possono cambiare in fase di esecuzione richiamando gli appositi metodi del RenderingServer.

Le impostazioni di qualità delle ombre posizionali (omni/spot) si possono cambiare in fase di esecuzione sulla Viewport radice.

Dimensioni della mappa delle ombre

Un'alta risoluzione delle ombre risulta in ombre più nitide, ma a un impatto significativo sulle prestazioni. Va inoltre notato che ombre più nitide non sono sempre più realistiche. Nella maggior parte dei casi, è consigliabile mantenere il valore predefinito di 4096 o ridurlo a 2048 per le GPU di fascia bassa.

Se le ombre posizionali diventano troppo sfocate dopo aver ridotto le dimensioni della mappa delle ombre, è possibile compensare regolando i quadranti dell'atlante delle ombre in modo che contengano meno ombre. Ciò consentirà a ciascuna ombra di essere renderizzata a una risoluzione più alta.

Modalità di filtro delle ombre

Qui è possibile scegliere diverse impostazioni di qualità per la mappa delle ombre. Il valore predefinito Soft Low è un buon compromesso tra prestazioni e qualità per le scene con texture dettagliate, poiché il livello di dettaglio delle texture aiuta a rendere meno evidente l'effetto dithering.

Tuttavia, nei progetti con texture meno dettagliate, il motivo di dithering nelle ombre si potrebbe notare di più. Per nascondere questo motivo, è possibile abilitare Antialiasing temporale (TAA), AMD FidelityFX Super Resolution 2.2 (FSR2), Antialiasing approssimativo rapido (FXAA) oppure aumentare la qualità del filtro delle ombre a Soft Medium o superiore.

L'impostazione Soft Very Low ridurrà automaticamente la sfocatura delle ombre per rendere meno visibili gli artefatti dovuti al basso numero di campioni. Inversamente, le impostazioni Soft High e Soft Ultra aumenteranno automaticamente la sfocatura delle ombre per sfruttare al meglio il maggior numero di campioni.

../../_images/lights_and_shadows_filter_quality.webp

16 bit contro 32 bit

Come predefinito, Godot utilizza texture di profondità a 16 bit per renderizzare le mappe delle ombre. Questo è consigliato nella maggior parte dei casi, in quanto offre prestazioni migliori senza una differenza di qualità percepibile.

Se l'opzione 16 bit è disabilitata, saranno utilizzate texture di profondità a 32 bit. Ciò può ridurre gli artefatti in scene complesse e con luci intense e ombre abilitate. Tuttavia, la differenza è spesso a malapena percettibile, eppure può avere un impatto drastico sulle prestazioni.

Light/shadow distance fade

OmniLight3D e SpotLight3D offrono diverse funzionalità per nascondere le luci distanti. Questo può migliorare significativamente le prestazioni in scene grandi con decine o più luci.

  • Enabled: controlla se la dissolvenza a distanza (una forma di LOD) è abilitata. La luce svanirà gradualmente per Begin + Length, dopodiché sarà scartata e non inviata proprio allo shader. Utilizzare questa opzione per ridurre il numero di luci attive in una scena e quindi migliorare le prestazioni.

  • Begin: la distanza dalla telecamera alla quale la luce inizia a svanire (in unità 3D).

  • Shadow: la distanza dalla telecamera alla quale l'ombra inizia a svanire (in unità 3D). Si può utilizzare per far svanire le ombre più presto rispetto alla luce, migliorando ulteriormente le prestazioni. Disponibile solo se le ombre sono abilitate per la luce.

  • Length: la distanza su cui la luce e l'ombra svaniscono (in unità 3D). La luce diventa gradualmente più trasparente su questa distanza, fino a diventare completamente invisibile. Valori più elevati rendono la dissolvenza più graduale, più adatta quando la telecamera si muove velocemente.

Raccomandazioni per PCSS

Percentage-closer soft shadows (PCSS) provide a more realistic shadow mapping appearance, with the penumbra size varying depending on the distance between the caster and the surface receiving the shadow. This comes at a high performance cost, especially for directional lights.

Per evitare problemi di prestazioni, si consiglia di:

  • Utilizzate solo un po' di luci con ombre PCSS abilitate. L'effetto è generalmente più visibile sulle luci grandi e luminose. Le sorgenti luminose secondarie che sono più deboli di solito non usufruiscono molto dall'uso di ombre PCSS.

  • Fornire un'impostazione che consenta agli utenti di disabilitare le ombre PCSS. Per le luci direzionali, ciò si può fare impostando la proprietà light_angular_distance dei DirectionalLight3D su 0.0 in uno script. Per le luci posizionali, si può fare impostando la proprietà light_size degli OmniLight3D o SpotLight3D su 0.0 in uno script.

Modalità di filtro dei proiettori

Anche il modo in cui sono renderizzati i proiettori ha un impatto sulle prestazioni. L'impostazione avanzata del progetto Rendering > Texture > Proiettori di luce > Filtro consente di controllare come filtrare le texture dei proiettori. Con Nearest/Linear non utilizzano mipmap, il che li rende più veloci da renderizzare. Tuttavia, i proiettori appariranno sgranati se visti da lontano. Con Nearest/Linear Mipmaps appariranno più uniformi da lontano, ma i proiettori appariranno sfocati se visti da angolazioni oblique. Ciò si può risolvere usando Nearest/Linear Mipmaps Anisotropic, che è la modalità di qualità più alta, ma anche la più costosa sulle prestazioni.

Se il proprio progetto ha uno stile pixel art, si consiglia di impostare il filtro su uno dei valori Nearest in modo che i proiettori utilizzino il filtro vicino più ravvicinato. Altrimenti, mantenere Lineare.