簡體   English   中英

正確使用視錐

[英]Using frustums properly

我正在讀一本書,說: For perspective projection, avoid setting your near or far plane to zero or a negative number. Mathematically this just doesn't work out. For perspective projection, avoid setting your near or far plane to zero or a negative number. Mathematically this just doesn't work out.

它指的是這樣的矩陣的nearfar參數:

static Matrix4<T> Frustum(T left, T right, T bottom, T top, T near, T far)
{
    T a = 2 * near / (right - left);
    T b = 2 * near / (top - bottom);
    T c = (right + left) / (right - left);
    T d = (top + bottom) / (top - bottom);
    T e = - (far + near) / (far - near);
    T f = -2 * far * near / (far - near);
    Matrix4 m;
    m.x.x = a; m.x.y = 0; m.x.z = 0; m.x.w = 0;
    m.y.x = 0; m.y.y = b; m.y.z = 0; m.y.w = 0;
    m.z.x = c; m.z.y = d; m.z.z = e; m.z.w = -1;
    m.w.x = 0; m.w.y = 0; m.w.z = f; m.w.w = 1;
    return m;
}

好吧,我明白了。 但是我沒有得到的是作者隨后將-7的az轉換為所有演示模型,這在屏幕上很好顯示。 但是,如果將“視錐”的“近”和“遠”分別設置為5和10,為什么在屏幕上顯示-7? 是否不僅會出現轉換為5到10之間的z的對象?

因為攝像機的znear和zfar值是攝像機的距離 ,而不是絕對數。 他們總是很積極的。 這就是數學的原理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM