Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 作业1三角形无法实现远小近大的效果

Viewing 1 reply thread
  • Author
    Posts
    • #9285 Score: 0
      剑心
      Participant

      我发现我修改相机pos的z轴图像始终都是一样大小, 我猜测可能是我的投影矩阵出现了问题, 希望各位大佬能指点一下.
      我的投影矩阵:
      void Rst::Rasterizer::SetProjection(float eyeFov, float aspectRatio, float zNear, float zFar)
      {
      Eigen::Vector4f temp = Eigen::Vector4f::Identity();
      auto n = zNear;
      auto f = zFar;

      //KS: https://smuwm007.feishu.cn/docs/doccn2FNKtTm58i2R4jISC7vd4e#KufB6G
      Eigen::Matrix4f p2o;
      p2o <<
      n, 0, 0, 0,
      0, n, 0, 0,
      0, 0, f + n, -f * n,
      0, 0, 1, 0;

      float halve = eyeFov / 2 * MY_PI / 180;
      float top = -zNear * std::tan(halve);
      float bottom = -top;

      float right = top * aspectRatio;
      float left = -right;

      Eigen::Matrix4f m, s;
      m <<
      1, 0, 0, -(left + right) / 2,
      0, 1, 0, -(top + bottom) / 2,
      0, 0, 1, -(zNear + zFar) / 2,
      0, 0, 0, 1;

      s <<
      2 / (right – left), 0, 0, 0,
      0, 2 / (top – bottom), 0, 0,
      0, 0, 2 / (zNear – zFar), 0,
      0, 0, 0, 1;

      projection = p2o * m * s;

      }

      Attachments:
      You must be logged in to view attached files.
    • #9298 Score: -1
      qh
      Participant
      -1 pt

      最后的 projection = s * m * p2o 。

      This post has received 1 vote down.
Viewing 1 reply thread
  • You must be logged in to reply to this topic.