Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 作业6 提高题结果比较(提升似乎有限?)

Tagged: 

Viewing 16 reply threads
  • Author
    Posts
    • #5047 Score: 1
      Bear
      Participant
      -11 pt

      使用原有的 MEDDLE 方法 BVH 耗时 0.2-0.3s 左右,渲染耗时 4-6s 横跳

      我这里 SAH 方法 BVH 耗时 0.20s 左右,渲染耗时 4s 左右

      我记得理论上 SAH 应该是建 BVH 慢一些但渲染快一些,感觉我这里的结果不太明显

      不知道大家那里怎么样?

      This post has received 3 votes up and 1 vote down.
    • #5057 Score: -1
      maajor
      Participant
      3 pts

      同样疑问…不过我这里,SAH构造BVH时间确实是跟bucket的数量成正比,当然32个bucket时时间也没多多少.

      一个猜想是,SAH在以下这种极端情况下表现比较好:一组面数量很多,另一组面数量很少,这两组距离很远.
      我们这个case里,就一个bunny,它还是比较紧凑的不太会出现那种极端情况.
      (当然另一个猜想是我代码写错了….

      This post has received 1 vote down.
      • #5058 Score: -1
        Bear
        Participant
        -11 pt

        我就是怕写错了才问问大家。。。我就用了 12 个 bucket

        我有一个复杂一点的标准模型你看看 BVH 构建和渲染用多少时间

        链接: https://pan.baidu.com/s/1TN9bdVWa0fjxQjpAZJlGGg 密码: jowv

        This post has received 1 vote down.
        • This reply was modified 4 years, 8 months ago by Bear.
        • #5072 Score: -2
          Abyss
          Participant

          构建时间类似,5s左右,渲染48305 ms vs 39525 ms, SAH用了32个bucket

          This post has received 1 vote down.
          • #5079 Score: -1
            Bear
            Participant
            -11 pt

            同样 32 个 bucket,我用我发的网盘里的模型

            Meddle BVH 7s 左右,渲染 82s 左右

            SAH BVH 8s 左右,渲染 71s 左右

            由此看来 SAH 基本上渲染时间会减少 10% 左右,供大家参考

            This post has received 1 vote down.
        • #5117 Score: 1
          李梦凡
          Participant
          1 pt

          这个大狼模型的视点要怎么设置,我没改视点渲染出来只能看到一个屁股

          This post has received 1 vote up.
          • #5118 Score: -1
            Abyss
            Participant

            Eye的z改大,往后调一点就好了。我其实给每个MeshTriangle包了个model transform,所以同屏放了50个随机分布的犰狳和兔子。

            This post has received 1 vote down.
    • #5085 Score: 0
      mvp
      Participant
      2 pts

      渲染时间,我的Middle BVH 11s左右, SAH 10s,构建时间没有明显区别,都是1s中

      This post has received 1 vote up.
      • #5086 Score: -1
        Bear
        Participant
        -11 pt

        你可以试试我发的那个模型,记得把 bucket 换成 32

        This post has received 1 vote down.
    • #5087 Score: 0
      mvp
      Participant
      2 pts

      你这个模型的eye_pose需要修改吗,渲染出来离眼睛好近

      This post has received 1 vote up.
      • #5089 Score: -1
        Bear
        Participant
        -11 pt

        用这个模型是拿来比较时间的,渲染结果不是很重要

        eye_pos 改不改实际上不是很重要。。。反正两种方法相对时间不会有很大差别

        This post has received 1 vote down.
    • #5088 Score: 1
      mvp
      Participant
      2 pts

      BVH 172s, SAH 149s,应该还算正常

      This post has received 1 vote up.
    • #5097 Score: -1
      cmc233
      Participant
      6 pts

      上面两行是bunny,BVH建树2s,渲染3.6s; SAH建树3s,渲染3.2s
      下面两行是那个复杂的模型,BVH建树6.0s,渲染29.9s; SAH建树7.9s,渲染24.8s
      都是32个buckets

      想问下你们SAH建树的时候是不是只对bounding最长的边进行考虑?我只有这样才能得到上面这么短的建树时间,如果x,y,z轴都考虑,bunny的建树就得7s。。。。(ps,我看参考链接ppt的伪代码考虑了x,y,z)

      This post has received 1 vote down.
      Attachments:
      You must be logged in to view attached files.
      • #5099 Score: 0
        cmc233
        Participant
        6 pts

        发现打错了,bunny的建树时间是0.2s,0.3s;SAH建树如果x,z,y都考虑,是0.8s

        This post has received 1 vote down.
      • #5101 Score: 1
        Bear
        Participant
        -11 pt

        只考虑最长的

        你都知道用 bucket 了,考虑最长的和这个一样都是工程上的做法

        This post has received 1 vote up.
    • #5102 Score: -1
      nightwatch
      Participant
      3 pts

      比建树时间的话,naive版本的要优化后,用std::nth_element才能比,现在用的std::sort,上来就是O(nlogn)的复杂度。我用g++ O3的话,用你的模型,渲染时间差不多,基本上都是14秒,差别不是很大,12个bucket。

      This post has received 1 vote down.
      • #5106 Score: -3
        Bear
        Participant
        -11 pt

        有道理。至于验证码的事情记得刷新下再输

        This post has received 1 vote down.
    • #5104 Score: -1
      枫吟
      Participant
      1 pt

      渲染感觉速度基本没有差别,10%以内,我是三个轴都考虑,速度感觉就慢了一点,是构造没有sort,加了点优化

      This post has received 1 vote down.
    • #5116 Score: -2
      Bear
      Participant
      -11 pt

      更新下,我把 MEDDLE 的 std::sort() 换成 std::partition() (O(n) 复杂度)后

      在我的模型上 32 个 bucket

      MEDDLE BVH 建立时间为 1.8s, 渲染时间 84s
      SAH BVH 建立时间 9s 左右, 渲染时间 73.43s

      This post has received 1 vote up and 1 vote down.
    • #5140 Score: 1
      xuyonglai
      Participant
      3 pts

      作业模型渲染时间分别为16 15
      楼主提供的模型渲染时间分别为168 146
      为什么和大家差别的挺大

      This post has received 1 vote up.
      • This reply was modified 4 years, 8 months ago by xuyonglai.
      • #5142 Score: -1
        Bear
        Participant
        -11 pt

        大家硬件配置不一样啊,要看自己机子上两种方法的对比

        This post has received 1 vote down.
      • #5168 Score: -1
        cmc233
        Participant
        6 pts

        除了硬件问题,渲染写法的一些细节上也会影响速度,例如我在BVHAccel::getIntersection里把dirIsNeg = {int(ray.direction.x > 0), int(ray.direction.y > 0), int(ray.direction.z > 0)}换成dirIsNeg = {int(ray.direction.x > 0), int(ray.direction.y > 0), 0},bunny的渲染速度直接快了一倍

        This post has received 1 vote down.
        • #5169 Score: -1
          Bear
          Participant
          -11 pt

          三个读取 + 一个 bool 判断 + bool 转 int 类型这么费时间???这不科学

          This post has received 1 vote down.
        • #5171 Score: -1
          Bear
          Participant
          -11 pt

          我实验了,没啥影响

          This post has received 1 vote down.
          • #5172 Score: 1
            cmc233
            Participant
            6 pts

            这是我刚刚跑的,确实只改了那一句话,不过也有可能是系统原因,我的macos。但是,如果建树时间差不多(在bvh建树没改助教源代码的情况下),但渲染时间相差很大,就不应该只是硬件问题了

            This post has received 1 vote up.
            Attachments:
            You must be logged in to view attached files.
            • #5174 Score: 1
              Bear
              Participant
              -11 pt

              首先这和系统扯不上关系。。。我也是 Mac。

              应该是我没用这个 std::array 判断正负所以影响不大,但你把 z 全部赋 0 难道不会影响实验结果?这不就是完全放弃了对 z 是否 neg 的判断?那 t_z_min, t_z_max 就有可能反了,最终的相交判断也会出问题啊

              其次上面那老哥是整体渲染时间和其他人有差别,而相对渲染时间提速差不多也是 10%,所以是硬件问题的原因很大

              This post has received 1 vote up.
              • #5176 Score: -1
                cmc233
                Participant
                6 pts

                在Renderer::Render里光源方向是Vector3f dir = normalize(Vector3f(x, y, -1)),z一直都是负数啊

                This post has received 1 vote down.
                • #5178 Score: -1
                  Bear
                  Participant
                  -11 pt

                  我完全删掉了 dirIsNeg, 取消了对 t_z_min 和 t_z_max 是否相反的判断,速度的确提升了

                  This post has received 1 vote down.
                • #5183 Score: -1
                  Bear
                  Participant
                  -11 pt

                  Mac 用 iterm2 啊,还可以再装 oh-my-zsh 做定制

                  This post has received 1 vote down.
                  • #5193 Score: -3
                    cmc233
                    Participant
                    6 pts

                    hhhh,奇怪的知识突然增加了,从没想过换个terminal(大概是因为用的少吧orz

                    This post has received 1 vote down.
                    • #5195 Score: -1
                      Bear
                      Participant
                      -11 pt

                      iterm2 是软件,替代原生 terminal 的

                      oh-my-zsh 是 zshell 的一套配置,比 bshell 好使,但能加自己的配置
                      (比如很重要的命令高亮)

                      This post has received 1 vote down.
                      • #5196 Score: -1
                        cmc233
                        Participant
                        6 pts

                        感谢安利

                        This post has received 1 vote down.
                • #8713 Score: 0
                  akira
                  Participant
                  3 pts

                  刚开始光线z方向是负的,但经过反射或折射后应该可能便为正吧,这样模型复杂一点应该会有bug的我估计

    • #5177 Score: 1
      戴皓天
      Participant
      9 pts

      大佬你好,可以请教几个问题吗
      SAH的原理我已经理解了,就是现在对实现上还有点疑惑
      1.我对老师提供的教程有点疑惑,具体见附件,也就是这段代码(括起来的三行),能否解答一下这一部分具体是在进行怎样的操作?
      2.教程里,在空间中buckets是如何分割出来的?比如此时objects中所有物体构成的包围盒在z轴上最长,那么此时是如何在z轴上对空间进行分割的?如果是等分成32分,那么是对哪一段长度进行32等分?(这个问题或许可以合并到第一个问题里)

      ps:我看了另一个教程,这个教程说的是,比如一共有10个物体,在z轴上按z轴大小排好序,分别编号为0~9,然后在这10个物体之间取分割线,比如先在0、1之间分割,然后再1、2之间分割,以此类推,算出各个cost(cost指的就是分割后两个子包围盒的[子包围盒体积/父包围盒体积*子包围盒中物体数量]的和,这里和老师提供的教程是一样的),然后采用最小的那个,这个教程与老师提供的教程的区别就是并不是对空间进行分割,实际上是对物体数量进行分割,不知道我这样行不行,但我想先弄懂老师提供的教程是什么意思

      谢谢了!

      This post has received 1 vote up.
      • This reply was modified 4 years, 8 months ago by 戴皓天.
      • This reply was modified 4 years, 8 months ago by 戴皓天.
      Attachments:
      You must be logged in to view attached files.
      • #5182 Score: 0
        Bear
        Participant
        -11 pt

        1.分 bucket 是工程上的做法,不然真的按 object 切分的话每一次找切分位置运算量太大,所以也别按物体切了

        2.你可以理解总 bucket 就是 centroidBounds 一个包围所有 object 的 bound,附件的 3 行其实就是算每个 object 在这个大 bound 中的相对位置也就是 offset,然后乘以 bucket 的数量就是该 object 所属 bucket 的index,那就 bucket[i].union(该 object) 就算把该 object 划分到了 bucket[i] 中

        This post has received 1 vote down.
        • #5190 Score: -2
          戴皓天
          Participant
          9 pts

          非常感谢!!!这样说就懂了~

          This post has received 2 votes down.
          • #5192 Score: 0
            Bear
            Participant
            -11 pt

            互帮互助还,以前你也帮过我

            This post has received 1 vote up and 1 vote down.
      • #5184 Score: -1
        SHERLOCK
        Participant
        -1 pt

        大佬请问你SAH是看的哪一套资料,可以分享下你的另外一套教程吗

        This post has received 1 vote down.
        • #5191 Score: -1
          戴皓天
          Participant
          9 pts

          https://www.cnblogs.com/lookof/p/3546320.html

          这个资料很简单,很好理解,但是实际上开销比较大,最好还是要按空间划分,而不是按我这个教程的按物体划分,因为可能有些场景会有大量物体,不过用于理解还是很好的,我就是看这个文章看懂的原理:)

          This post has received 1 vote down.
      • #5248 Score: -3
        Scott
        Participant
        -3 pt

        同问这里的bucket代码具体该怎么操作呢

        This post has received 1 vote down.
    • #5211 Score: -1
      戴皓天
      Participant
      9 pts

      在排序仍然用sort的情况下,用不用SAH在渲染时间上差别确实不是特别明显,对于你的那个复杂模型在总时间上还是不用SAH的更少一点(BVH with SAH建树时间太长),或许面对更大更复杂的场景SAH才能发挥出更大作用XD

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

        。。。你多跑几次,bucket 数量多点试试;不应该才快这么点

        This post has received 1 vote down.
    • #5232 Score: -1
      小狮子
      Participant
      1 pt

      用SAH 大概快了 10%的时间
      我这里用楼主的模型 native的是 97秒,sah是88秒~~但是构树时间很奇怪,SAH是2秒,native的却是3秒

      This post has received 1 vote down.
      • #5234 Score: -1
        xuyonglai
        Participant
        3 pts

        native用的是排序 慢正常

        This post has received 1 vote down.
    • #5291 Score: -1
      sublimation
      Participant
      3 pts

      我做了一个实验,关于加入SAH后的分割点与中间位置的偏移量,超过2的只有大约10%。靠近根节点的节点会差异比较大。
      再思考一下,这可能可以说明,如果出现了“一组面数量很多,另一组面数量很少,这两组距离很远.”,这个情况,在接下来几层应该只是影响了某一支路。总体来看可能影响没有那么大。

      ps:我的实验中,因为上述的两个模型点数都不是很多,我没有分桶,直接排序以后扫了一遍求得最优值。

      This post has received 1 vote down.
    • #5311 Score: 0
      Keneyr
      Participant
      7 pts

      我的naive建树0secs,渲染24secs
      sah建树1secs,渲染21secs
      另外buckets数量越大,渲染的越快么?我实验了一下,似乎并不是这样。

      还是我代码有问题?。。

      This post has received 1 vote up.
      • #5315 Score: -1
        HighSun
        Participant
        5 pts

        SAH 里面的桶数量越大, 不一定渲染的越快, 只是更加接近最优划分.

        要想得到最优划分只要对每一个物体之间的划分点都计算损失并取最小就可以, 就是上面 sublimation 同学实验的做法. 但是桶的数量越大, 建树时间越慢. 所以桶的数量设置为一个能达到建树时间和划分时间的平衡的值就可以了.

        This post has received 1 vote down.
        • #5320 Score: -1
          sublimation
          Participant
          3 pts

          我觉得桶的数量增多,时间复杂度是一样的。(假设不考虑常数。
          桶的数量增多,主要是空间复杂度增大。
          类比计数排序。

          This post has received 1 vote down.
    • #5321 Score: 1
      HighSun
      Participant
      5 pts

      确实,划分数为 p 时在最后计算各个桶的 cost 时只会有一个 O(p) 的常数,增大的主要还是空间复杂度。刚发现这部分常数我写成了 O(p^2),我修改一下,感谢提醒。

      This post has received 1 vote up.
      • #5322 Score: 1
        HighSun
        Participant
        5 pts

        刚才回复时提交验证码失败,最后忘记点回复了,上面这条回复的是 #5320

        This post has received 1 vote up.
    • #9015 Score: 0
      Riga27527
      Participant

      大家都没有遇到如果两个三角形重心重叠的情况吗?这时候就会把所有三角形都分到一边,然后另一边就数量为0,程序就直接dump掉了。bunny的模型好像不会遇到这种情况,我用自己的模型就是有可能的。

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