Version: 2022.3
言語: 日本語
Mesh Renderer コンポーネント
Mesh Filter コンポーネント

Skinned Mesh Renderer コンポーネント

Skinned Mesh Renderer コンポーネントは、可変 (deformable) のメッシュをレンダリングします。可変メッシュには、スキンされたメッシュ (ボーンとバインドポーズを持つメッシュ)、ブレンドシェイプを持つメッシュ、クロス (布) のシミュレーションを実行するメッシュが含まれます。

通常のメッシュをレンダリングする場合は、代わりに Mesh RendererMesh Filter を使用します。

可変のメッシュやそれを持つモデルをシーンに追加すると、Unity は生成されたゲームオブジェクトにSkinned Mesh Renderer コンポーネントを追加します。

C# コードでは、SkinnedMeshRenderer クラスは、Skinned Mesh Renderer コンポーネントを表します。SkinnedMeshRenderer クラスは、その機能の多くを Renderer クラスから継承しています。そのため、このコンポーネントは Renderer を継承する他のコンポーネント、例えば Line RendererTrail Renderer などと多くの共通点があります。

Skinned Mesh Renderer の可視性に関するトラブルシューティング

Unity はメッシュの境界を使用して、それをレンダリングするかどうかを決定します。メッシュのバウンディングボリューム全体がアクティブなカメラの視野の外側にあると、Unity はそのメッシュをレンダリングしません。

Skinned Mesh Renderer の場合、そのメッシュ境界は変形に伴って変化します。Unity はインポート時に存在するすべてのアニメーションを考慮して最大のバウンディングボリュームを計算し、この値を使用して可視性を決定します。ただし、インポート後に発生する以下の状況では、頂点やボーンが既知の最大境界の外に押し出される可能性があります。

  • アニメーションを追加する場合
  • ランタイムにスクリプトからボーンの位置を変更する場合
  • 頂点位置を変更する頂点シェーダーを使用する場合
  • ラグドールを使用する場合

頂点やボーンが境界の外に押し出されると、Unity がメッシュの可視性を正しく判断できず、表示されるべき時に表示されないことがあります。

このような場合は、以下のいずれかの解決策で問題を解決できます。

  • 境界を修正してメッシュの可能な最大のバウンディングボリュームに一致するように修正します。パフォーマンスの向上のために、可能であればこのオプションを使用してください。
  • Update When Offscreen を有効にします。これにより、Unity はメッシュが表示されないときでも、常にメッシュの境界を計算し続けます。パフォーマンスがあまり気にならない場合や、バウンディングボリュームのサイズを予測できない場合 (ラグドールを使用する場合など) にこのオプションを使用します。

Skinned Mesh Renderer Inspector リファレンス

Inspector ウィンドウに表示される Skinned Mesh Renderer コンポーネントです。
Inspector ウィンドウに表示される Skinned Mesh Renderer コンポーネントです。

プロパティ

プロパティ 説明 
Bounds Unity がメッシュをいつオフスクリーンにするかを決定するために使用するバウンディングボリュームを設定します。Unity はモデルファイルにメッシュとアニメーションをインポートするときに境界を事前計算し、シーンビューでモデルの周囲の境目をワイヤーフレームで表示します。

Update When Offscreen を True に設定すると、Unity はフレームごとにこれらの境界を再計算し、計算された値を使用してこのプロパティを上書きします。

このプロパティは Mesh.Bounds API に対応します。
BlendShapes メッシュに定義された ブレンドシェイプ に使用するウェイト値を保存します。
Quality 頂点に影響を与えることができるボーンの最大数のランタイムの上限を設定します。

Unity がメッシュをインポートするとき、Unity は 1 - 32 の数のボーンですべての頂点をスキンできます。影響力のあるボーン数が多いほど、動きの結果は向上します。ただし、これは必要な計算リソースも増加させるため、パフォーマンスに影響を与える可能性があります。

パフォーマンス上の理由から、ランタイムの上限を使用するのではなく、インポート時に頂点に影響を与えるボーン数を設定する方が良いでしょう。これを行うには、Model Import Settings ウィンドウ の Rig タブを使い、Skin Weights 設定を調整します。

この設定を使用してコンポーネントごとにランタイムの上限を設定するほかに、Edit > Project Settings > Quality > Other > Skin Weights でプロジェクトのグローバルの制限を設定することもできま す。

このプロパティは、SkinnedMeshRenderer.quality API に対応します。
Auto Quality Settings > Skin Weights で設定したグローバルの制限を使用します。

ノート: スキンウェイトのカスタム数をインポートし 5 つ以上のボーンに影響を与えたい場合は、このオプションを選択し Skin WeightsUnlimited に設定する必要があります。
1 Bone 1 つの頂点につき、1 つのボーンのみを使用します。
2 Bones 1 つの頂点につき、最大 2 つのボーンを使用します。
4 Bones 1 つの頂点につき、最大 4 つのボーンを使用します。5 つ以上のボーンが 1 つの頂点に影響を与えるようにするには、Auto 設定を使用します。
Update When Offscreen これを有効にすると、どのカメラからも見えない場合でも、すべてのフレームでバウンディングボリュームを計算します。このオプションを無効にすると、ゲームオブジェクトが画面上にないときにスキニングを停止し、ゲームオブジェクトが再び表示されるとスキニングを再開します。

これはパフォーマンス上の理由から、デフォルトでは無効になっています。

このプロパティはSkinnedMeshRenderer.updateWhenOffscreen API に対応します。
Mesh このレンダラーが使用するメッシュを設定します。メッシュは、有効なバインドポーズとスキンウェイトを含むか、ブレンドシェイプを使用するか、クロス (布) のシミュレーションを実行する必要があります。メッシュがこれらの技術を使用しない場合は、Mesh Renderer と Mesh Filter の使用を検討してください。

SkinnedMeshRenderer.sharedMesh プロパティに対応します。
Root bone スケルトンの “ルート” であるトランスフォームを設定します。境界線はこのトランスフォームに沿って動きます。
Rendering Layer Mask このプロパティは、このレンダラーが割り当てられるレンダリングレイヤーを決定します。このプロパティを使用して、レンダリング固有のレイヤーマスクを追加で指定できます。これにより、レンダラーが持つマスクに基づいてレンダラーがフィルタリングされます。

このプロパティは、Renderer.renderingLayerMask API に対応します。

Unity は、Scriptable Render Pipeline を使用する場合にのみ、このプロパティを表示します。
Renderer Priority レンダラーを優先度でソートします。低い値が最初に描画され、高い値が最後に描画されます。

このプロパティは、Renderer.rendererPriority API に対応します。

Unity は、HD レンダーパイプラインを使用する場合にのみ、このプロパティを表示します。

Materials

Materials セクション、Mesh Renderer
Materials セクション、Mesh Renderer

Materials セクションには、このコンポーネントが使用するすべての マテリアル が列挙されています。

プロパティ 説明
Size The number of elements in the material list.

If you decrease the number of elements, Unity deletes the elements at the end of the list. If you increase the number of elements, Unity adds new elements to the end of the list. Unity populates new elements with the same material that the element at the end of the list uses.
Element The materials in the list. You can assign a material asset to each element.

By default, Unity orders the list alphabetically based on the name of the materials. This list is reorderable, and Unity updates the number of the elements automatically as you change their order.

ノート: サブメッシュの数よりもマテリアルの数が多い場合、Unity は最後のサブメッシュを残っている各マテリアルでレンダリングし、1 つずつ重ねていきます。マテリアルが完全に不透明でない場合、さまざまなマテリアルを重ねて、興味深い視覚効果を作成できます。ただし、完全に不透明なマテリアルは前のレイヤーを上書きします。そのため、Unity が最後のサブメッシュに不透明なマテリアルを加えると、パフォーマンスに悪い影響があり、メリットがありません。

Lighting

Lighting セクションには、ライティングに関連するプロパティを含まれています。

プロパティ 説明
Cast Shadows Specify if and how this Renderer casts shadows when a suitable Light shines on it.

This property corresponds to the Renderer.shadowCastingMode API.
On This Renderer casts a shadow when a shadow-casting Light shines on it.
Off This Renderer does not cast shadows.
Two-sided This Renderer casts two-sided shadows. This means that single-sided objects like a plane or a quad can cast shadows, even if the light source is behind the mesh.

For Baked Global Illumination or Enlighten Realtime Global Illumination to support two-sided shadows, the material must support Double Sided Global Illumination.
Shadows Only This Renderer casts shadows, but the Renderer itself isn’t visible.
Receive Shadows Specify if Unity displays shadows cast onto this Renderer.

This property only has an effect if you enable Baked Global Illumination or Enlighten Realtime Global Illumination for this scene.

This property corresponds to the Renderer.receiveShadows API.
Contribute Global Illumination Include this Renderer in global illumination calculations, which take place at bake time.

This property only has an effect if you enable Baked Global Illumination or Enlighten Realtime Global Illumination for this scene.

Enabling this property enables the Contribute GI flag in the GameObject’s Static Editor Flags. It corresponds to the StaticEditorFlags.ContributeGI API.
Receive Global Illumination Whether Unity provides global illumination data to this Renderer from baked lightmaps, or from runtime Light Probes.

This property is only editable if you enable Contribute Global Illumination. It only has an effect if you enable Baked Global Illumination or Enlighten Realtime Global Illumination for this scene.

This property corresponds to the MeshRenderer.receiveGI API.
Lightmaps Unity provides global illumination data to this Renderer from lightmaps.
Light Probes Unity provides global illumination data to this Renderer from Light Probes in the scene.
Prioritize Illumination Enable this property to always include this Renderer in Enlighten Realtime Global Illumination calculations. This ensures that the Renderer is affected by distant emissives, even those which are normally excluded from Global Illumination calculations for performance reasons.

This property is visible only if Contribute GI is enabled in the GameObject’s Static Editor Flags, your project uses the Built-in Render Pipeline, and Enlighten Realtime Global Illumination is enabled in your scene.

Probes

Probes セクションには、ライトプローブリフレクションプローブ に関するプロパティが含まれています。

プロパティ 説明
Light Probes Set how this Renderer receives light from the Light Probes system.

This property corresponds to the Renderer.lightProbeUsage API.
Off The Renderer doesn’t use any interpolated Light Probes.
Blend Probes The Renderer uses one interpolated Light Probe. This is the default value.
Use Proxy Volume The Renderer uses a 3D grid of interpolated Light Probes.
Custom Provided The Renderer extracts Light Probe shader uniform values from the MaterialPropertyBlock.
Proxy Volume Override Set a reference to another GameObject that has a Light Probe Proxy Volume component.

This property is only visible when Light Probes is set to Use Proxy Volume.
Reflection Probes Set how the Renderer receives reflections from the Reflection Probe system.

This property corresponds to the Renderer.probeAnchor API.
Off Disables Reflection Probes. Unity uses a skybox for reflection.
Blend Probes Enables Reflection Probes. Blending occurs only between Reflection Probes. This is useful in indoor environments where the character may transition between areas with different lighting settings.
Blend Probes and Skybox Enables Reflection Probes. Blending occurs between Reflection Probes, or between Reflection Probes and the default reflection. This is useful for outdoor environments.
Simple Enables Reflection Probes, but no blending occurs between Reflection Probes when there are two overlapping volumes.
Anchor Override Set the Transform that Unity uses to determine the interpolation position when using the Light Probe or Reflection Probe systems. By default, this is the centre of the bounding box of the Renderer’s geometry.

This property corresponds to the Renderer.probeAnchor API.

Additional Settings

Additional Settings には付加的なプロパティが含まれています。

プロパティ 説明
Skinned Motion Vectors これを有効にすると、メッシュのスキンデータをダブルバッファにします。そのため、Unity はスキンしたモーションを補間し、モーションベクトルテクスチャにそれを置くことができます。これは、より多くの GPU メモリを使用しますが、より正確なモーションベクトルになります。
Dynamic Occlusion When Dynamic Occlusion is enabled, Unity’s occlusion culling system culls this Renderer when it is blocked from a Camera’s view by a Static Occluder. Otherwise, the system does not cull this Renderer when it is blocked from a Camera’s view by a Static Occluder.

Dynamic Occlusion is enabled by default. Disable it for effects such as drawing the outline of a character behind a wall.

SkinnedMeshRenderer

Mesh Renderer コンポーネント
Mesh Filter コンポーネント