You can generate your own lightmap UVs for a Mesh, or Unity can automatically generate them.
You can author your own lightmap UVs in the content creation software of your choice. You must place lightmap UVs in the second UV channel of your mesh.
A good UV set for lightmaps should adhere to the following rules:
You can tell Unity to automatically generate lightmap UVs for a Model, using the Model Import Settings.
These are the settings that appear in the Model tab of the Model Import Settings, when you enable Generate Lightmap UVs.
プロパティー | 説明 | |
---|---|---|
Hard Angle | 隣接する三角形間の角度 (単位は度)。Unityはそれを鋭い切れ目と見なし、継ぎ目を作成します。これを 0 と 180 の間の値に設定できます。これはデフォルトで 88 度に設定されています。 これを 180 度に設定すると、Unity はすべてのエッジが滑らかであると見なし、これは有機的なモデルでは現実的です。デフォルト値 (88度) は機械的なモデルには現実的です。 |
|
Angle Error | ソースジオメトリの角度から UV 角度の可能な最大偏差 (0–100%)。これはデフォルトで 8% に設定されています。 これにより、UV 空間の三角形と元のジオメトリの三角形との違いを制御します。通常、ライトマップを適用するときにアーティファクトを避けるため、これはかなり低くする必要があります。 |
|
Area Error | ソースジオメトリの領域から UV 領域の可能な最大偏差 (0–100%)。これは、デフォルトでは 15% に設定されています。 これにより、相対的な三角形領域を維持する度合いを制御します。値を大きくするとチャートを少なくすることができますが、三角形の解像度が変わる可能性があります。そのため、発生する歪みがライトマップの品質を損なわないことを確認してください。 |
|
Margin Method | Whether you specify the Pack Margin manually, or whether Unity automatically calculates it. | |
Manual | You specify the Pack Margin manually. | |
Calculate | Based on expected lightmap resolution and object scale, Unity calculates a Pack Margin just large enough to avoid UV overlaps. | |
Pack Margin | The margin between neighboring charts (in pixels), assuming the Mesh takes up the entire 1024x1024 lightmap. You can set this to a value between 1 and 64. A larger value increases the margin, but also increases the amount of space the chart needs. This is set to 4 pixels by default. For more information, see Pack Margin. This property is only visible when Margin Method is set to Manual. |
|
Min Lightmap Resolution | The minimum lightmap resolution (in texels per unit) of the MeshRenderers that use this Mesh, across all Scenes. The lightmap resolution of a MeshRenderer is a combination of the MeshRenderer’s Scale in Lightmap property, and the Lightmap Resolution property of the Lighting Settings Asset of the Scene it appears in.For more information, see Min Lightmap Resolution and Min Object Scale. Unity uses this information to calculate pack margin. This property is only visible when Margin Method is set to Calculate. |
|
Min Object Scale | The minimum transform scale that of the GameObjects that use this Mesh, across all Scenes. For more information, see Min Lightmap Resolution and Min Object Scale. Unity uses this information to calculate pack margin. This property is only visible when Margin Method is set to Calculate. |
フィルタリングを可能にするために、ライトマップは、チャート境界近くのライティング情報 (単位はテクセル) を含んでいます。そのため、常にチャート間にいくらかのマージンを含めて、ライトマップを適用するときにライトのにじみを回避します。
ライトマップの解像度は、ライトマップのテクセル解像度を定義します。ライトマッパーは、ライトマップ内のいくつかのチャートテクセルを広げてエッジが黒くなることを避けます。そのため、メッシュの UV チャートは、ライトのにじみを避けるために、その間に少なくとも 2 テクセルの間隔を空ける必要があります。 Pack Margin 設定を使用して、ジオメトリの UV チャート間に十分なマージンがあることを確認します。
ライトマップの UV 空間では、UV オーバーラップや偶発的なライトのにじみを避けるために、チャート間のパディングは少なくとも 2 テクセルである必要があります。この画像では、黒いスペースはチャート間のスペースを表します。
Placing UV charts too close together may cause cross-chart texel bleeding in the final lightmap. Placing charts too far away from each other wastes memory. The ideal packing margin of an object depends on how many lightmap texels are allotted to it.
The number of texels that Unity uses for a MeshRenderer depends on the MeshRenderer’s lightmap resolution and transform scale. To calculate a good margin, Unity needs to know the expected minimum values for these properties.
A MeshRenderer’s lightmap resolution is a combination of the Lightmap Resolution
property of the Lighting Settings Asset for the Scene that the MeshRenderer appears in, and the Scale in Lightmap
property of the MeshRenderer. Note that this means that the same MeshRenderer can have a different lightmap resolution in different Scenes.
You can use the Inspector to view the lightmap resolution of a MeshRenderer in a given Scene:
以下のスクリーンショットは解像度が同じですが、UV が異なります。最初の画像の Angle Error は高く設定され、結果に意図しないアーティファクトが含まれています。2 番目の画像ではデフォルトの Angle Error (8%) が設定されています。メッシュがより多くの三角形を持つと、角度の歪みにより形状を著しく歪ませます。
以下の画像では、同じパラメーターを持つ 2 つのスポットライトがシリンダーの側面を照らしています。その右側面は Area Error の値が高く、そのため、三角形が歪み、解像度が低くなり、ライトにアーティファクトが発生しています。
プログレッシブライトマッパーは 2018.1 で追加 NewIn20181
Calculate Pack Margin added in 2020.1 NewIn20201