Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Camera.projectionMatrix

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

マニュアルに切り替える
public var projectionMatrix: Matrix4x4;
public Matrix4x4 projectionMatrix;

説明

カスタム射影行列を設定します。

この行列を変更した場合、カメラは fieldOfView に基づいたレンダリングの更新をまったく行わなくなります。 これは ResetProjectionMatrix を呼び出すまで続きます。

本当に標準的ではない投影が必要な場合にのみカスタム投影を使用してください。 このプロパティーは Unity で水の描画を行うときに "斜め投影" 行列を設定するのに使用されます。 カスタム投影を使用するには 変換と投影行列に対する正しい知識が必要です。

シェーダーに渡される投影行列がプラットフォームや他のステートに応じて 変更可能であることに注意してください。カメラ投影から使用するシェーダー用の投影行列を計算する必要がある場合、 GL.GetGPUProjectionMatrix を使用します。


        
	// Make camera wobble in a funky way!
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Matrix4x4 originalProjection; Camera camera; void Start() { camera = GetComponent<Camera>(); } void Update() { Matrix4x4 p = originalProjection; p.m01 += Mathf.Sin(Time.time * 1.2F) * 0.1F; p.m10 += Mathf.Sin(Time.time * 1.5F) * 0.1F; camera.projectionMatrix = p; } }

        
	// Set an off-center projection, where perspective's vanishing
// point is not necessarily in the center of the screen.
//
// left/right/top/bottom define near plane size, i.e.
// how offset are corners of camera's near plane.
// Tweak the values and you can see camera's frustum change.

using UnityEngine; using System.Collections;

[ExecuteInEditMode] public class ExampleClass : MonoBehaviour { public float left = -0.2F; public float right = 0.2F; public float top = 0.2F; public float bottom = -0.2F; void LateUpdate() { Camera cam = Camera.main; Matrix4x4 m = PerspectiveOffCenter(left, right, bottom, top, cam.nearClipPlane, cam.farClipPlane); cam.projectionMatrix = m; } static Matrix4x4 PerspectiveOffCenter(float left, float right, float bottom, float top, float near, float far) { float x = 2.0F * near / (right - left); float y = 2.0F * near / (top - bottom); float a = (right + left) / (right - left); float b = (top + bottom) / (top - bottom); float c = -(far + near) / (far - near); float d = -(2.0F * far * near) / (far - near); float e = -1.0F; Matrix4x4 m = new Matrix4x4(); m[0, 0] = x; m[0, 1] = 0; m[0, 2] = a; m[0, 3] = 0; m[1, 0] = 0; m[1, 1] = y; m[1, 2] = b; m[1, 3] = 0; m[2, 0] = 0; m[2, 1] = 0; m[2, 2] = c; m[2, 3] = d; m[3, 0] = 0; m[3, 1] = 0; m[3, 2] = e; m[3, 3] = 0; return m; } }