waliwaliwa

瓦利瓦利哇

@waliwaliwa

  • 上次的问题还没有解决😭。当设置 Model 偏移量很小的时候translation(0,0.1,0) 渲染出来存在黑色块。
    byh_y+|636x500

    // 使用 BVH 求交
    optional<Intersection> BVH::intersect(const Ray& ray, [[maybe_unused]] const GL::Mesh& mesh,
                                          const Eigen::Matrix4f obj_model)
    {
        model = obj_model;
        optional<Intersection> isect;
        if (!root) {
            isect = std::nullopt;
            return isect;
        }
        Ray trans_ray;
        Eigen::Matrix4f model_inv = this->model.inverse();
        trans_ray.direction =
            (model_inv * Vector4f(ray.direction.x(), ray.direction.y(), ray.direction.z(), 1.0f))
                .head<3>().normalized();
        trans_ray.origin =
            (model_inv * Vector4f(ray.origin.x(), ray.origin.y(), ray.origin.z(), 1.0f)).head<3>();
        isect = ray_node_intersect(root, trans_ray);
        if (isect.has_value()) {
            Vector3f world_intersection =
                (model * (isect->t * trans_ray.direction + trans_ray.origin).homogeneous()).head<3>();
            float dis     = (world_intersection - ray.origin).norm();
            isect->t      = dis;
            isect->normal = (model_inv.transpose() *
                             Vector4f(isect->normal.x(), isect->normal.y(), isect->normal.z(), 1.0f))
                                .head<3>();
        }
        return isect;
    }
    

    if (isect.has_value()) 中对返回值的坐标变换存在问题吗,还是在 ray_node_intersect() 函数进行一些特殊处理?

    Post #4
  • 谢谢老师的解答。现在问题已经解决了,发现大小不变是因为depth没改。

    Post #3
  • 我去,markdown 有些格式打错了😢
    忘了补充了,我也很爱崔健、窦唯等国内摇滚🤘🏻

    Post #18
  • 我很喜欢==摇滚==,无论是迷幻、硬摇、英伦还是前卫等都很喜欢。碎瓜、大门、披头士、yes、创世纪等是我的最爱。
    但是考试周了没时间写一堆介绍。由于这个地方是“交大门”,那我就推荐一首大门乐队的*《Take it as it come》*,祝大家期末考试一切顺利😊☺️

    Post #17 ❤️ 4 likes