Version: 5.6
リアルタイムライティング
Baked Indirect モード

混合ライティング 

Mixed (混合) ライトは、Mode プロパティーを Mixed に設定した Light コンポーネント です。

混合 ライトは、ランタイムに Transform や視覚関連プロパティー (カラーや強度など) を変更できますが、厳しい制限内でのみ可能です。混合ライトは静的ゲームオブジェクトと動的ゲームオブジェクトの両方を照らし、常に直接ライティングを提供し、オプションで間接ライティングを提供できます。混合 ライトで照らされた動的ゲームオブジェクトは、常に他の動的ゲームオブジェクトにリアルタイムの影を投げます。

  • シーンの 混合 ライトはすべて、同じ Mixed Lighting Mode を使用します。 Lighting Mode を設定するには、Lighting ウィンドウを開き ( Window > Lighting > Settings )、Scene タブをクリックし、Mixed Lighting のセクションに移動します。
Lighting ウィンドウの Mixed Lighting セクション
Lighting ウィンドウの Mixed Lighting セクション

利用できるモードは以下の通りです。

混合ライトの使用

混合ライトは、ゲームの一部ではなく、静的環境を照らすライト (例えば、空の移動しない太陽) に使用します。混合ライトからの直接光はランタイムに計算されるため、静的メッシュのマテリアルは視覚的な忠実性を保持し、物理ベースシェーディング (PBS) の完全なサポートがあります。

混合ライトの例
混合ライトの例

Distance Shadowmask is the most resource-intensive option, but provides the best results: it yields high-quality shadows within the Shadow Distance (Edit > Project Settings > Quality > Shadows), and baked high-quality shadows beyond. For example, you could create large landscapes with realistic shadows right up to the horizon, as long as the sun does not travel across the sky.

Subtractive モードで取得する結果は、最も質が低くなります。たった 1 つのライトでリアルタイムの影をレンダリングし、その影をベイクした直接光と間接光と合成します。他のモードのいずれも使用できないターゲットプラットフォームの代替ソリューションとしてのみ使用してください (例えば、ローエンドのモバイルデバイスでアプリケーションを実行する必要があるが、メモリの制約によって ShadowmaskDistance Shadowmask を使用できない場合など)。

様々なモードの比較は Unity Lighting Modes Reference Card を参照してください。

すべての混合ライティングモードは、すべてのプラットフォームでサポートされています。ただし、レンダリングの制限があります。

  • Subtractive モードの場合は、フォワードレンダリング を使用します (デファード、またはライトプレパスのサポートはありません)。

  • Shadowmask and Distance Shadowmask modes fall back to forward rendering(RenderTech-ForwardRendering) (no deferred or light prepass support) on platforms which only support four render targets, such as DirectX 9.

フォワードレンダリングとデファードレンダリングの詳細については、レンダリングパス のドキュメントを参照してください。

より高度な使用法

混合 ライトは、ランタイムにトランスフォームや視覚関連プロパティー (色や強度など) を変更できますが、厳しい制限内でのみ可能です。 実際、ベイクされたライト (したがって、事前計算されています) があるため、ランタイムにパラメーターを変更すると、リアルタイムと事前計算されたライトを合成するときに一貫性のない結果になります。

In the case of Baked Indirect, Shadowmask and Distance Shadowmask, the direct lighting contribution behaves just like a Realtime Light, so you can change parameters like the color, intensity and even the Transform of the Light. However, baked values are precomputed, and cannot change at run time.

例えば、赤い 混合 ライトをライトマップにベイクし、実行時にその色を赤から緑に変更すると、すべての直接光が緑色に変更されます。ただし、すべての間接光はライトマップにベイクされるため、赤色のままです。実行時に混合ライトを移動する場合も同じことが発生します。直接光はライトに従って移動しますが、間接光はライトがベイクされた位置に残ります。

If only subtle changes are introduced to direct lighting (for example, by only slightly modifying the hue or intensity of a Light), it is possible to get the benefits of indirect lighting and for the Light to appear somewhat dynamic, without the extra processing time required for a Realtime Light. Indirect lighting is still incorrect, but the error might be subtle enough not to be objectionable. This works especially well for Lig hts without precomputed shadow information. This is achieved either by having shadows disabled for the Light, or by using Baked Indirect mode where shadows are real time. As shadowmasks are part of the direct lighting computation, moving such Lights causes visual inconsistencies with shadows not lining up correctly.

以下のビデオは、混合ライトがベイクされた位置から遠くに移動するとどうなるかを示しています。オブジェクトが遠くに移動したにもかかわらず、赤色の間接光が壁に残っている様子に注意してください。https://youtu.be/o6pVBqrj8-s

以下のビデオは、矛盾を目立たせずに間接光をわずかに変更した例を示しています。https://youtu.be/XN6ya31gm1I

技術的な詳細

In the case of Mixed Lights, the last segment of a light path (that is, the path from the Light to the surface) becomes part of the precomputation as well. However, Unity still handles direct lighting and indirect lighting separately. It bakes indirect lighting into light maps and Light Probes, which are then sampled at run time. Indirect lighting is generally low frequency, meaning it looks looks smooth and doesn’t contain detailed shadows or light transitions. Therefore, shadows are handled with direct lighting where they have a high visible impact.

影の事前計算と保存の方法の違いは、混合ライトのさまざまなサブモードに反映されています。

影の情報は事前に計算されシャドウマスクに格納されます。シャドウマスクは、対応するライトマップと同じ UV レイアウトと解像度を共有するテクスチャです。テクスチャは、テクセルあたり最大 4 つのライトのオクルージョン情報を保存します (現在の GPU で最大 4 チャンネルに制限されているため)。値の範囲は 0 から 1 で、その範囲の値にするとソフトシャドウを作ります。

If shadowmasks are enabled, Light Probes also store occlusion information for up to four Lights. If more than four Lights intersect, the excess Lights fall back to Baked Lights. You can inspect this behavior with the shadowmask overlap visualization mode. This information is precomputed, so only the only shadows Unity stores in the shadowmask are shadows cast from static GameObjects onto other static GameObjects. These shadows can have smoother edges providing better quality than real-time shadow maps, depending on the light map resolution. Because each Mixed Light retains its shadowmask channel mapping at run time, shadows cast by dynamic GameObjects via shadow maps can be correctly composited with precomputed shadows from static GameObjects, avoiding inconsistencies like double shadowing.

静的ゲームオブジェクトの影と動的ゲームオブジェクトの影の唯一の違いは、事前計算されたシャドウマスクとランタイムのシャドウマップの解像度とフィルタリングの違いであり、事前計算された影はさまざまな形のエリアライトをサポートしているため、 ソフトシャドウにさらに現実的な陰影ができます。

この画像では、ベイクしたシャドウマスクの解像度はリアルタイムの影の解像度とほぼ同じです
この画像では、ベイクしたシャドウマスクの解像度はリアルタイムの影の解像度とほぼ同じです
この画像では、ベイクしたシャドウマスクの解像度はリアルタイムの影の解像度よりかなり低下
この画像では、ベイクしたシャドウマスクの解像度はリアルタイムの影の解像度よりかなり低下

What all Mixed modes except for Subtractive mode have in common is that direct lighting is always computed in real time and added to the indirect lighting stored in the light map, so all Material effects that require a light direction continue to work. Dynamic GameObjects always cast shadows on other dynamic GameObjects via shadow maps within the Shadow Distance (Edit > Project Settings > Quality > Shadows), if shadows are enabled for that Light.

Baked Indirect モード: 間接光だけが事前計算されます
Baked Indirect モード: 間接光だけが事前計算されます
Shadowmask と Distance Shadowmask モード: 間接光と直接オクルージョンが事前計算されます
ShadowmaskDistance Shadowmask モード: 間接光と直接オクルージョンが事前計算されます
Subtractive モード: すべてのライトパスが事前計算されます
Subtractive モード: すべてのライトパスが事前計算されます

リアルタイムライティング
Baked Indirect モード