Version: 2022.3
言語: 日本語
Line Renderer コンポーネント
Billboard Renderer コンポーネント

Trail Renderer コンポーネント

Trail Renderer コンポーネントは、動いているゲームオブジェクトの後ろにポリゴンの軌跡を、経時的に描画します。これにより、動いているオブジェクトの動きを強調したり、動いているオブジェクトの軌跡や位置を強調したりすることができます。

Trail Renderer は、ラインレンダラー と同じアルゴリズムでトレイルレンダリングを行います。

はじめに

トレイルレンダラーを作成するには、以下を行います。

  1. Unity メニューバーで GameObject > Effects > Trail の順に選択します 。
  2. Trail Renderer ゲームオブジェクトを選択し、それをトレイルを生成したいゲームオブジェクトの親にします。
  3. Inspector ウィンドウを使用して、トレイルの色、 幅、その他の表示設定を行います。
  4. 編集モードでトレイルをプレビューするには、シーンビューでゲームオブジェクトを移動して効果を観察します。
Trail Renderer の設定例と、その結果の軌跡です。
Trail Renderer の設定例と、その結果の軌跡です。

トレイルレンダラーのマテリアル

デフォルトでは、トレイルレンダラーはビルトインのマテリアルである Default-Line を使用します。このマテリアルを変更せずに、トレイルのカラーグラデーションや幅など、トレイルの外観に多くの変更を加えることができます。

トレイルにテクスチャを適用するなどの他の効果の場合は、異なるマテリアルを使用する必要があります。新しいマテリアル用に独自のシェーダーを作成したくない場合は、Unity のビルトインの スタンダードパーティクルシェーダー がラインレンダラーでうまく機能します。テクスチャをトレイルレンダラーに適用する場合、テクスチャは正方形である必要があります (例えば、256x256 や 512x512)。

トレイルレンダラーに複数のマテリアルを適用する場合、トレイルは各マテリアルに対して 1 回描画されます。

詳細は マテリアルの作成と使用 を参照してください。

点の間の距離

Min Vertex Distance の値は、新しいセグメント (1 区分) がトレイルに加えられる前に、トレイルが適用されるゲームオブジェクトが移動しなければならない距離 (ワールド単位) を決定します。0.1 のような低い値にすると、より頻繁にトレイルセグメントが作成され、より滑らかなトレイルが作成されます。1.5 のような高い値にすると、セグメントがよりギザギザになります。さらに、頂点が互いに非常に接近していて、トレイルが短い距離で著しく向きを変える場合、幅の広いトレイルは視覚的なアーティファクトを示す場合があります。

パフォーマンス上の理由から、作成しようとしている効果を実現できる範囲の最大値を使用するのが最善です。

Trail Renderer Inspector の参照

このセクションには、以下のサブセクションがあります。

トレイルの設定

プロパティ 機能
Width 幅とカーブの値を決め、トレイルのさまざまな位置で幅を制御します。

カーブは各頂点でサンプリングされます。そのため、その正確さはトレイルに存在する頂点数によって制限されます。トレイル全体の幅は Width 値によって制御されます。
Time トレイルのポイントの生存期間を秒単位で定義します。
Min Vertex Distance トレイル内の点の最小間隔 (ワールド単位)。
Autodestruct これを有効にすると、Time 秒移動しなかった場合は、Trail Renderer コンポーネントをアタッチしているゲームオブジェクトを破棄します。
Emitting これを有効にすると、Unity はトレイルに新しい点を追加します。これを無効にすると、Unity はトレイルに新しいポイントを追加しません。これは、トレイル生成の一時停止と一時停止解除を行うために使用します。
Color (色) グラデーションを定義して、トレイルのさまざまな位置で色をコントロールします。

Unity は各頂点でカラーグラデーションから色をサンプリングします。Unity は、各頂点間で色に線形補間を適用します。トレイルにより多く頂点を追加すると、より詳細なグラデーションがより精密に近似されます。
Corner Vertices トレイルに曲がり角を描画するとき、追加の頂点をいくつ使用するかを制御します。この値を増やすと、トレイルの曲がり角がより丸く表示されます。
End Cap Vertices トレイルにエンドキャップを描画するとき、追加の頂点をいくつ使用するかを制御します。この値を増やすと、トレイルのキャップがより丸く表示されます。
Alignment トレイルの向きを設定します。
表示 トレイルはカメラに正面を向けます。
TransformZ トレイルは Transform コンポーネントの Z 軸に正面を向けます。
Texture Mode テクスチャをトレイルに適用する方法を制御します。
Stretch トレイルの全長に沿ってテクスチャを 1 回マッピングします。
Tile ワールド単位の長さに基づいて、トレイルに沿ってテクスチャを繰り返します。タイリング率を設定するには、Material.SetTextureScale を使用します。
DistributePerSegment トレイルの全長に沿ってテクスチャを 1 回マッピングします。すべての頂点間隔は均等であると仮定します。
RepeatPerSegment トレイルに沿ってテクスチャを繰り返します。トレイルごとに 1 回の割合で繰り返します。タイリングレートを調整するには、Material.SetTextureScale を使用します。
Shadow Bias ライトを影から遠ざける量を設定して、影のアーティファクトを削除します。
Generate Lighting Data これを有効にすると、Unity は法線と接線を含むトレイルジオメトリを構築します。これにより、シーンのライティングを使用するマテリアルを使用できます。

Materials

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.

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 には付加的なプロパティが含まれています。

Property Description
Motion Vectors Set whether to use motion vectors to track this Renderer’s per-pixel, screen-space motion from one frame to the next. You can use this information to apply post-processing effects such as motion blur.

Note: not all platforms support motion vectors. See SystemInfo.supportsMotionVectors for more information.

This property corresponds to the Renderer.motionVectorGenerationMode API.
Camera Motion Only Use only Camera movement to track motion.
Per Object Motion Use a specific pass to track motion for this Renderer.
Force No Motion Do not track motion.
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.
Sorting Layer The name of this Renderer’s Sorting Layer.
Order in Layer This Renderer’s order within a Sorting Layer.

TrailRenderer

Line Renderer コンポーネント
Billboard Renderer コンポーネント