Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 作业2:三角形覆盖顺序不对

Tagged: 

Viewing 2 reply threads
  • Author
    Posts
    • #11380 Score: 0
      RickJager
      Participant

      完成作业2时我的结果是下图(和原作业要求不符合)

      查看了一下投影矩阵,发现传入的znear和zfar是正数,我感觉自己是不是在这里错了,下面是我的投影矩阵代码
      //cout << eye_fov << ” ” << zNear << ” ” << zFar << endl;
      // // // Students will implement this function
      zNear = -zNear;
      zFar = -zFar;
      Eigen::Matrix4f projection = Eigen::Matrix4f::Identity();
      Eigen::Matrix4f M_persp2ortho;
      M_persp2ortho << zNear, 0, 0, 0,
      0, zNear, 0, 0,
      0, 0, zNear+zFar, -zNear*zFar,
      0, 0, 1, 0;
      eye_fov = eye_fov * M_PI / 180;
      float t = tan(eye_fov/2.0) * abs(zNear), b = -t;
      float r = aspect_ratio * t, l = -r;
      Eigen::Matrix4f M_ortho1;
      M_ortho1 << 2.0/(r-l), 0, 0, 0,
      0, 2.0/(t-b), 0, 0,
      0, 0, 2.0/(zNear-zFar), 0,
      0, 0, 0, 1.0;
      Eigen::Matrix4f M_ortho2;
      M_ortho2 << 1.0, 0, 0, -(r+l)/2,
      0, 1, 0, -(t+b)/2,
      0, 0, 1, -(zNear+zFar)/2,
      0, 0, 0, 1.0;
      Eigen::Matrix4f M_ortho = M_ortho1 * M_ortho2;
      projection = M_ortho * M_persp2ortho;
      // TODO: Implement this function
      // Create the projection matrix for the given parameters.
      // Then return it.
      return projection;

      Attachments:
      You must be logged in to view attached files.
    • #11455 Score: 0
      Andy
      Participant

      这个取决于你怎么做z-buffer的判断。在rasterize_triangle 函数中。

      Attachments:
      You must be logged in to view attached files.
    • #11471 Score: 0
      輕山柒海
      Participant

      这篇文章里有详细的讲解!!
      《GAMES101》作业框架问题详解

Viewing 2 reply threads
  • You must be logged in to reply to this topic.