Viewing 3 reply threads
  • Author
    Posts
    • #10908 Score: 0
      XYZ
      Participant

      如图和pdf给出的结果颜色覆盖相反了

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

      应该是不能直接取最小值,黄色三角的插值深度是75.6614,蓝色三角是75.448(见附图),如果认为较小的值更近的话,就是蓝色遮挡黄色
      这应该是zbuffer初始化为inf引起的误导

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

        编辑:是我搞错了

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

      谢谢你的解答,我已经解决了这个问题,应该是透视矩阵的错误导致的

    • #11315 Score: 0
      见龙
      Participant

      请问楼主是怎么解决的?目前我也遇到了同样的问题

      • #11325 Score: 0
        XYZ
        Participant

        应该是你的projection矩阵哪里出现的问题,你需要讲znear和zfar取负数 只在求top的时候使用距离时abs用绝对值。

        • #11378 Score: 0
          RickJager
          Participant

          请问能不能post一下你投影矩阵的代码,我也遇到这个问题,怎么调都调不通

          • #11379 Score: 0
            XYZ
            Participant

            zNear = -zNear;
            zFar = -zFar;
            Eigen::Matrix4f projection = Eigen::Matrix4f::Identity();
            projection = Eigen::Matrix4f::Zero();
            eye_fov = eye_fov / 180 * MY_PI;
            projection(0,0) = zNear;
            projection(1,1) = zNear;
            projection(2,2) = zNear + zFar;
            projection(2,3) = -zNear * zFar;
            projection(3,2) = 1.0;
            projection(3,3) = 0.0;

            Eigen::Matrix4f ort = Eigen::Matrix4f::Identity();;

            float t = tan(eye_fov / 2) * abs(zNear);
            float r = t * aspect_ratio;
            ort(0,0) = 1.0 / r;
            ort(1,1) = 1.0 / t;
            ort(2,2) = 2.0 / (zFar – zNear);
            ort(2,3) = (zNear + zFar) / 2;
            projection = ort * projection;
            return projection;

            • #11449 Score: 0
              hellowGraphic
              Participant

              我感觉代码最后ort(2,3)不应该这样写,因为这样表达的意思是先做线性变换再做平移,但这里应该是先平移再缩放,这两者是不相等的。

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