Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 作业7判断直接光照是否被其他物体遮挡的疑问

Viewing 3 reply threads
  • Author
    Posts
    • #6418 Score: 0
      saniac
      Participant
      -1 pt

      运行结果全黑,调试发现 bool block = (intersect(Ray(hitPoint, ws)).coords – lightInter.coords).norm() > EPSILON;

      算出来的block全是true。
      代码见下图,请问我哪里搞错了?

      Attachments:
      You must be logged in to view attached files.
    • #6431 Score: 0
      JackieZhou
      Participant
      -2 pt

      coords是位置,distance才是距离

      • #6432 Score: -1
        saniac
        Participant
        -1 pt

        非常感谢,改成(intersect(Ray(hitPoint, ws)).distance – lightInter.distance) > EPSILON;有画面了,但是我有点不理解,bool block = (intersect(Ray(hitPoint, ws)).coords – lightInter.coords).norm() > EPSILON;我理解这个指两个交点有距离,为啥这个不能代表光线被其他物体挡住了呢?

        另外画面变成了这样,能帮忙分析一下可能是啥问题么?

        This post has received 1 vote down.
        Attachments:
        You must be logged in to view attached files.
        • #6434 Score: 0
          saniac
          Participant
          -1 pt

          看别的帖子解决了,是因为IntersectP里面应该用t_enter <= t_exit

        • #6436 Score: 0
          有时间吗
          Participant

          请问一下这里为什么使用的是(intersect(Ray(hitPoint, ws)).distance – lightInter.distance) > EPSILON呢?判断直接光源是否被物体遮挡,那么不应该是intersect(Ray(hitPoint, ws)).distance 比 lightInter.distance 小才是遮挡吗?

          • #6469 Score: 1
            oxine
            Participant
            9 pts

            说的没错,我是这样的
            if ((insec_light.distance - Scene::intersect(Ray(hitPoint, ws)).distance)<EPSILON) {// if not blocked
            能得到正确的结果,注意insec_light.distance需要手动赋值
            insec_light.distance = (insec_light.coords - hitPoint).norm();

            This post has received 1 vote up.
    • #6522 Score: 0
      windsmoon
      Participant
      1 pt

      你的 nolight_reflectInter 那个不应该是判断 没有 emission 才反弹下一个光线吗

    • #7425 Score: 0
      kwshh
      Participant
      1 pt

      个人开始也是全屏黑的问题,仔细核查代码发现是因为cosx部分应该用-ws而不是ws,
      个人判断直接光阻挡的三个思路,我同步跑了一下,应该是1,3效果是一样的(2可能我写的定义有问题吧)

      
      // 尝试判断x与交点之间的距离(
      //if(dotProduct(te_intersection.coords - x, te_intersection.coords - x) < EPSILON)
      // 尝试判断p到x距离与p到交点距离的差(
      //if(abs(te_intersection.distance - (p - x).norm()) < EPSILON)
      
      // 尝试判断相交物体是否是自发光物体
      if (te_intersection.obj && te_intersection.obj->hasEmit())
      
Viewing 3 reply threads
  • You must be logged in to reply to this topic.