カメラ
公式サイト:
目次
概要
参考:
使い方
参考:
設定
- Clear Flags
- Skybox
- Solid Color
- Depth only
- Don’t Clear
- Background
- Culling Mask
- Projection
- Perspective
- Orthographic
- Size
- Field of View
- Physical Camera
- Clipping Planes
- Near
- Far
- Viewport Rect
- X
- Y
- W
- H
- Depth
- Rendering Path
- Use Graphics Settings
- Forward
- Deferred
- Legacy Vertex Lit
- Legacy Deferred (light prepass)
- Target Texture
- Occlusion Culling
- Allow HDR
- Allow MSAA
- Allow Dynamic Resolution
- Target Display
参考:
リアルなレンダリングをする場合のチェック項目 | Shade3D チュートリアル
マウスで操作する
コード:
CameraController.cs – GitHub Gist
シーンビューの視点位置にカメラを配置する
Ctrl
+ Shift
+ F
:シーンビューに整列させる (Align with View)
動画:
Ctrl Shift F to Match the Camera to the Scene View
参考:
シーンビューカメラの位置に Camera を移動する | いんでぃーづ
カメラを選択した状態で Ctrl + Shift + F を押すと Scene ビューと Game ビューのカメラを同期できる | コガネブログ
これは便利!カメラの位置をシーンビューの視点と一致させる方法 | おもちゃラボ
Unity ホットキー | Unity 2018.4 マニュアル [公式]
背景
参考:
Camera.backgroundColor | Unity スクリプトリファレンス [公式]
描画順 (Depth)
カメラのレンダリング順序を指定する。
参考:
Camera.depth | Unity スクリプトリファレンス [公式]
How do I force my cameras to render in a certain order? | Unity Support [Official]
Camera Rendering Order | Unity Forum
Problems with camera rendering order | Unity Forum
焦点距離/画角 (FOV)
- Field of View:画角 (デフォルト:
60
/単位:度)
参考:
投影方法 (Projection)
- 透視投影 (Perspective)
- 平行投影 (Orthographic)
参考:
Camera.orthographic | Unity スクリプトリファレンス [公式]
物理カメラ (Physical Camera)
- Focal Length:焦点距離 (デフォルト:
50
/単位:mm) - Sensor Type / Sensor Size (単位:mm)
- 8mm (
4.8
×3.5
) - Super 8mm (
5.79
×4.01
) - 16mm (
10.26
×7.49
) - Super 16mm (
12.52
×7.41
) - 32mm 2-perf (
21.95
×9.35
) - 35mm Academy (
21
×15.2
) - Super-35 (
24.89
×18.66
) - 65mm ALEXA (
54.12
×25.59
) - 70mm (
70
×51
) - 70mm IMAX (
70.41
×52.63
) - Custom (デフォルト:
36
×24
)
- 8mm (
- Lens Shift
- Gate Fit
- Vertical:解像度ゲートをフィルムゲートの高さに合わせる
- Horizontal:解像度ゲートをフィルムゲートの幅に合わせる (デフォルト)
- Fill:解像度ゲートをフィルムゲートの高さあるいは幅のいずれか小さい方に合わせる
- Overscan::解像度ゲートをフィルムゲートの高さあるいは幅のいずれか大きい方に合わせる
- None:解像度ゲートを無視して、フィルムゲートのみを使用する。アスペクト比を保つことなく、レンダリング画像をゲームビューの大きさに合わせて縦横拡大する。
参考:
Unity 2018.2 で追加された Physical Camera とはナンゾや? | テラシュールブログ
カメラを切り替える
参考:
カメラの切り替えをスクリプトで実現しよう! | XR-Hub
Unity でカメラをスクリプトから切り替えられるようにする | かめくめ
主観カメラへの切り替えと、プレイヤーの移動方法について | TECH Projin
Unity でカメラ切り替えをするスクリプトを書いたよ/5つのカメラを数字キーで切り替え | 神部まゆみのブログ
カメラの切り替えの実装/実装パターン3つ紹介 | dasuko の技術ブログ
複数のカメラを切り替えたり画面を分割したりする方法 | Uinty 使い方ガイド
複数のカメラを使用する | Unity マニュアル [公式]
スクリプトで操作する
参考:
スクリプトから Main Camera を取得するのは簡単だよ | TECH Projin
VR カメラを任意のポジションに移動する方法 – Qiita
スクリプトから MainCamera の Position、Rotation の変更 | kyam 研の忘備録
Unity の Camera 使い方とスクリプト | ゲームの作り方!(dkrevel.com)
UnityEngine.Camera | Unity スクリプトリファレンス [公式]
How to arbitrarily set camera position in world coordinates – Unity Forum
How to get the position of the Main Camera – Unity Answers
camera position in UNITY – Stack Overflow
カリングマスク (Culling Mask)
動画:
Using Camera Culling Mask to Not Render Specific Layers
参考:
Camera の Culliing Mask 設定 – Qiita
特定のゲームオブジェクトだけをカメラに映す方法 | Uinty 使い方ガイド
カメラとレイヤー | KAYAC engineers’ blog
レイヤーによる Main Camera の非表示 | フタバゼミ
Camera.cullingMask | Unity スクリプトリファレンス [公式]
座標変換
参考:
Camera.WorldToScreenPoint | Unity スクリプトリファレンス [公式]
How to get a world position from the center of the screen ? – Unity Forum
Getting game object coordinate (from world coordinate) in screen coordinate – Stack Overflow
How to position 3D object to the camera screen in unity – Stack Overflow
オブジェクトを中心にして回転させる
参考:
Rotate a camera around the object – Unity Forum
複数台のカメラを使う
- 切り替え
- ピクチャインピクチャ/ワイプ (PIP / Picture in Picture)
- 分割 (PBP / Picture by Picture)
- 合成
- テクスチャ描画 (Render Texture)
- マルチディスプレイ
- バーチャルカメラ (Virtual Camera / Cinemachine)
参考:
複数のカメラの使い方/複数カメラ表示/カメラ切り替え | TECH PROjin
画面分割して複数のカメラの映像を表示する | Unity の使い方
複数のカメラを使用する | Unity マニュアル [公式]
視野錘台を傾ける (CalculateObliqueMatrix)
クリップ平面を与えて投影行列を計算する。
Code language: C# (cs)projection = camera.CalculateObliqueMatrix(clipPlane);
参考:
斜め (Oblique) の投影行列で空間を切り取る – Qiita
Camera.projectionMatrix の罠まとめ | fuqunaga
Camera.CalculateObliqueMatrix | Unity スクリプトリファレンス [公式]
Camera.projectionMatrix | Unity スクリプトリファレンス [公式]
Camera.ResetProjectionMatrix | Unity スクリプトリファレンス [公式]
Using an Oblique Frustum | Unity マニュアル [公式]
GeometryUtility.CalculateFrustumPlanes | Unity スクリプトリファレンス [公式]
フレームデバッガー
メニューから「Window > Analysis > Frame Debugger」を選択して開く。
参考:
Problems with camera rendering order | Unity Forum
Camera コンポーネント
参考:
UnityEngine.Camera | Unity スクリプトリファレンス [公式]
Render Texture を使う
参考:
Camera.targetTexture | Unity スクリプトリファレンス [公式]
OnPreCull
動画:
How to Hide Objects from a Camera without Layer Masks
参考:
MonoBehaviour.OnPreCull() | Unity スクリプトリファレンス [公式]
Camera.onPreCull | Unity スクリプトリファレンス [公式]
URP
参考:
Cameras | Universal RP 8.2 Manual [Official]
Class UniversalAdditionalCameraData | Universal RP 8.2 Manual [Official]
Cinemachine
ドキュメント: