タイトル: 鏡を作成する方法
SEOタイトル: UE5 で鏡を作る方法 (Planar Reflection / Scene Capture / SSR / マテリアル)
| この記事の要点 |
|
1. Planar Reflection Actor (推奨・最も手軽)
平面鏡向け。Place Actors → Visual Effects → Planar Reflection を配置し、鏡となる Plane の前面に重ねるだけで動作します。
1. Project Settings > Rendering > Reflections
> "Support global clip plane for Planar Reflections" を ON
(要再起動)
2. Place Actors > Visual Effects > Planar Reflection を Scene にドラッグ
3. 鏡面の Plane と同じ位置・大きさ・回転に合わせる
4. Planar Reflection の Details で
- Normal Distortion Strength
- Prefilter Roughness
- Screen Percentage
を調整 (品質と負荷のバランス)
メリット: 視点に追従し、奥行きが正しく見える本物の鏡。
デメリット: シーン全体を再描画するため重い。複数枚の鏡は避ける。
2. Reflection Capture (Sphere / Box)
厳密には鏡というより「金属面の周辺環境を写す Cubemap」です。Place Actors → Lights → Sphere Reflection Capture。
- 事前計算 (Capture Now) で球面の周りを撮影 → 鏡面マテリアルがそれを参照
- 視点に追従しないため、本格的な姿見には不向き
- ガラスのショーケースや磨かれた床、金属球などに最適
3. Scene Capture 2D + Render Target (王道)
もっとも自由度の高い方法。カメラを 1 つ別途用意し、その視点を Render Target に書き出して鏡 Plane のマテリアルに貼る。
[手順]
1. Render Target Texture を作成
Content Browser > Add > Materials & Textures > Render Target (例: RT_Mirror)
解像度 1024x1024 / Format RTF_RGBA16f 推奨
2. Scene Capture 2D Actor を配置
Details:
- Texture Target = RT_Mirror
- Capture Source = Final Color (LDR / HDR)
- Capture Every Frame = true
3. プレイヤーの位置から鏡面に対して
「対称な位置」に Scene Capture を配置するロジックを書く
(Blueprint の Tick で計算)
4. 鏡 Plane の Material を作成
- Base Color = RT_Mirror
- Metallic = 1, Roughness = 0
- UV を Screen Position から取得 (or Plane UV)
Blueprint で対称位置を計算する
[Tick イベント内]
Player = Get Player Camera Manager
Mirror = self (鏡 Plane)
// 鏡の平面に対するプレイヤーの鏡像
ToPlayer = Player.Location - Mirror.Location
Distance = Dot Product (ToPlayer, Mirror.ForwardVector)
MirroredLoc = Player.Location - 2 * Distance * Mirror.ForwardVector
Scene Capture.SetWorldLocation(MirroredLoc)
Scene Capture.SetWorldRotation(
Mirror Reflection of Player.Rotation by Mirror.ForwardVector
)
マテリアルで UV をスクリーン空間に
[Material グラフ]
ScreenPosition --(ViewportUV)--> TextureSample(RT_Mirror)
|
v
Base Color
Metallic = 1
Roughness = 0
Specular = 1
4. Screen Space Reflections / Lumen Reflections
PostProcess Volume の Screen Space Reflections (SSR)、または UE5 の Lumen Lumen Reflections を使う方法。設定だけで安価に光沢を出せます。
- 画面外の情報は写らない (背中向きが消える)
- 鏡というより「濡れた床」「磨いた金属」向き
- マテリアルは Roughness を下げるだけで OK
Post Process Volume:
Lumen Reflections > Quality = 4
Screen Space Reflections > Intensity = 100
Screen Space Reflections > Quality = 100
Material:
Metallic = 1
Roughness = 0.05
→ 床として配置すると鏡面反射 (SSR) が乗る
方式比較
| 方式 | 品質 | 負荷 | 視点追従 | 向く用途 |
|---|---|---|---|---|
| Planar Reflection | ★★★★ | 高 | ★ | 平面の本格的な鏡 |
| Reflection Capture | ★★ | 低 (事前計算) | ― | 金属面 / ガラス球 |
| Scene Capture 2D | ★★★★★ | 高 | ★ | 自由な鏡 / 監視カメラ |
| SSR / Lumen Reflections | ★★★ | 低 | ★ | 床 / 磨いた壁 |
マテリアルのコツ
[完全な鏡]
Metallic = 1.0
Roughness = 0.0
Base Color = (白でも可。Reflection が支配的)
[少し曇った鏡 / 古い鏡]
Roughness = 0.05 ~ 0.15
Normal にうっすら歪みテクスチャ
[汚れ / 指紋]
Roughness = Texture (汚れ部は 0.3 程度)
Base Color に薄い茶色を Multiply
[割れた鏡]
Normal Map に割れ模様
Opacity (Masked) で割れ目を切り抜き
Forward Rendering 時の制約
VR タイトルなどで Forward Renderer を選んでいる場合、SSR が使えません。Planar Reflection か Scene Capture 2D を使う必要があります。
| Renderer | SSR | Lumen | Planar | Scene Capture 2D |
|---|---|---|---|---|
| Deferred (既定) | ★ | ★ (UE5) | ★ | ★ |
| Forward (VR 向け) | ― | ― | ★ | ★ |
| Mobile | ― | ― | ― | ★ (重い) |
パフォーマンス Tips
- Planar Reflection の Screen Percentage を 50 にすると半分の解像度で 2 倍速
- Scene Capture 2D の Render Target は必要解像度の最小で (姿見なら 1024、遠景の鏡は 256)
- Capture Every Frame を OFF にし、必要なときだけ
CaptureScene()を呼ぶ - 鏡が画面に映らない時は
Set Hidden In Gameで無効化 (Visibility カリング) - 同じシーンに鏡を複数置かない。1 個ずつでも重い
FAQ
Q: 鏡に自分のキャラクターが映らない
A: ファーストパーソンの場合、プレイヤーキャラ自体が非表示になっている可能性。OwnerNoSee をオフに、または Scene Capture 専用の Skeletal Mesh を持たせます。
Q: Planar Reflection を ON にしたのに何も映らない
A: Project Settings の Support global clip plane for Planar Reflections を有効化しエディタ再起動が必要です。
Q: モバイルで鏡を作りたい
A: Reflection Capture (Cubemap) + 低解像度 Render Target が現実的。Planar / SSR はモバイルでは非推奨です。