Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 【作业3】在view space进行插值,结果会与文档中不一致

Viewing 1 reply thread
  • Author
    Posts
    • #4316 Score: 0
      Angus
      Participant
      23 pts

      我在完成作业3时,忘记了老师说过这次的作业只需要在screen space插值即可,在插值时我把顶点映射回了view space,最终的结果可能会与文档中的结果略有不同。不知是否算作正确结果?
      8JO77j.png

      • This topic was modified 4 years, 8 months ago by Angus.
      • This topic was modified 4 years, 8 months ago by Angus.
    • #4332 Score: 0
      Angus
      Participant
      23 pts

      突然发现这不是插值的问题,是因为我bump mapping的最后一步跟框架中不一样,框架中是:

      result_color = normal;

      而我把normal的值像normal shader一样进行了归一化:

      result_color = (normal.normalized() + Eigen::Vector3f(1.0f, 1.0f, 1.0f)) / 2.f;

      • This reply was modified 4 years, 8 months ago by Angus.
      • #4341 Score: 0
        sublimation
        Participant
        3 pts

        咦,其实这个问题我觉得挺有意思的,为什么normal shader要进行这样的操作。我看wikipedia上面的normal mapping,好像不是这样做的。
        https://en.wikipedia.org/wiki/Normal_mapping

        • #4345 Score: 0
          Angus
          Participant
          23 pts

          因为要把normal的xyz坐标映射为 0~1 之间,这样再乘255才是0~255。链接里也说了:

          X: -1 to +1 : Red: 0 to 255
          Y: -1 to +1 : Green: 0 to 255
          Z: 0 to -1 : Blue: 128 to 255

          所以文档里这个凹凸法线的可视化是偏暗的(大部分颜色值为负数,都被截去了)
          而我的结果和normal shader的结果都是比较像大多数法线贴图的颜色,偏亮。

          • #4348 Score: 0
            sublimation
            Participant
            3 pts

            是啊,但是result_color = (normal.normalized() + Eigen::Vector3f(1.0f, 1.0f, 1.0f)) / 2.f;并不能放到这个范围内,而且这个变换很有意思,不加的话看起来很丑。。

            • #4349 Score: 0
              Angus
              Participant
              23 pts

              欸?

              result_color = (normal.normalized() + Eigen::Vector3f(1.0f, 1.0f, 1.0f)) / 2.f;
              result_color = result_color * 255.0f;

              [-1, 1] + 1 = [0, 2]
              [0, 2] / 2 = [0, 1]
              [0, 1] * 255 = [0, 255]

              不是这样吗

            • #4355 Score: 0
              sublimation
              Participant
              3 pts

              对于x,y轴应该不变啊

              • #4357 Score: 0
                Angus
                Participant
                23 pts

                x, y轴不变是什么意思,不变它如何得出0~255的颜色值呢😂

                可能我没理解你的意思。

                • #4360 Score: 0
                  sublimation
                  Participant
                  3 pts

                  不好意思,我没说清楚。因为x,y应该是映射到0~255,只有z是0~128,所以为什么x,y分量也加一,,

                  • #4361 Score: 1
                    Angus
                    Participant
                    23 pts

                    因为它把x,y映射到0~255的方法是:
                    x,y ∈ [-1, 1]
                    x, y += 1
                    x,y ∈ [0, 2]
                    x, y /= 2
                    x,y ∈ [0, 1]
                    x, y *= 255.0f
                    x,y ∈ [0, 255.0f]

                    把z映射到128~255的方法是:
                    z ∈ [0, 1]
                    z += 1
                    z ∈ [1, 2]
                    z /= 2
                    z ∈ [0.5, 1]
                    z *= 255.0f
                    z ∈ [128.0f, 255.0f]

                    你可以看到这一加一除一乘三个操作完全一样,所以xyz一起映射与分开做是一样的。

                    This post has received 1 vote up.
                    • This reply was modified 4 years, 8 months ago by Angus.
Viewing 1 reply thread
  • You must be logged in to reply to this topic.