Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 [作业3] 光栅化(重心坐标计算插值)

Viewing 2 reply threads
  • Author
    Posts
    • #3980 Score: 2
      欠你一枝花
      Participant
      4 pts

      在基于作业2来完成作业3的rst::rasterizer::rasterize_triangle时,
      我发现几个地方有点难以理解:

      1) void rst::rasterizer::rasterize_triangle(const Triangle& t, const std::array<Eigen::Vector3f, 3>& view_pos)中的view_pos参数的作用和意义?

      2) 以法线插值为例:
      我的实现如下, 请问在interpolate里面的weight参数是做什么用的? 我这里传的是1.0, 效果跟正常的normal shader 效果不一样…
      `

      auto[alpha2, beta2, gamma2] = computeBarycentric2D(x, y, t.normal);
      auto interpolated_normal = interpolate(alpha2, beta2, gamma2, t.normal[0], t.normal[1], t.normal[2], 1.0);

      `

      3) interpolated_shadingcoords是根据什么来进行插值? 是三角形的顶点坐标vertex还是别的?

      感谢各位大佬, 再次谢过~

      This post has received 2 votes up.
      Attachments:
      You must be logged in to view attached files.
    • #4009 Score: 1
      Atlas
      Participant

      1)view_pos是投影前的坐标,也就是真实坐标。t里面的vertex坐标是投影后的。
      void rst::rasterizer::draw(std::vector<Triangle *> &Triangle)里有写view_pos大概是怎么算出来的。
      2)你的alpha,beta,gamma好像算错了,之前的代码框架里自带的是(x, y, t.v),而且x和y还可以改成x + 0.5和y + 0.5。正常情况下w是1和手算是一样的。
      3)应该用view_pos插值。

      This post has received 1 vote up.
      • This reply was modified 4 years ago by Atlas.
      • This reply was modified 4 years ago by Atlas.
    • #4012 Score: 0
      Angus
      Participant
      23 pts

      其实在本次实验中对attribute的插值被简化了(老师在课上也提到了,透视投影会影响插值,但实验中不要求这么复杂了),应该使用view space的坐标进行插值。
      所以view_pos本来的作用是参与所有attribute的插值的,现在只是在计算interpolated_shadingcoords时需要了。

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