벡터(vector)란?

https://www.cs.princeton.edu/courses/archive/spring14/cos426/lectures/12-ray.pdf

RayTracing.pdf

Ray-Tracing: Generating Camera Rays.pdf

ray.pdf

shade.pdf

phongshading.pdf

o.pdf

Raytracing code

https://web.cse.ohio-state.edu/~shen.94/681/Site/Slides_files/shadow.pdf

https://box2d.org/files/ErinCatto_DynamicBVH_GDC2019.pdf


bvh.c

minirt.h

struct.h

bool split_aabb(const aabb* box, aabb* left, aabb* right) {
    vec3 center = {
        .x = (box->lowerbound.x + box->upperbound.x) * 0.5,
        .y = (box->lowerbound.y + box->upperbound.y) * 0.5,
        .z = (box->lowerbound.z + box->upperbound.z) * 0.5
    };

    // 가장 긴 축을 찾아 그 축을 기준으로 분할합니다.
    double dx = box->upperbound.x - box->lowerbound.x;
    double dy = box->upperbound.y - box->lowerbound.y;
    double dz = box->upperbound.z - box->lowerbound.z;

    if (dx >= dy && dx >= dz) {
        // x축을 기준으로 분할
        *left = (aabb){box->lowerbound, {center.x, box->upperbound.y, box->upperbound.z}};
        *right = (aabb){{center.x, box->lowerbound.y, box->lowerbound.z}, box->upperbound};
    } else if (dy >= dx && dy >= dz) {
        // y축을 기준으로 분할
        *left = (aabb){box->lowerbound, {box->upperbound.x, center.y, box->upperbound.z}};
        *right = (aabb){{box->lowerbound.x, center.y, box->lowerbound.z}, box->upperbound};
    } else {
        // z축을 기준으로 분할
        *left = (aabb){box->lowerbound, {box->upperbound.x, box->upperbound.y, center.z}};
        *right = (aabb){{box->lowerbound.x, box->lowerbound.y, center.z}, box->upperbound};
    }

    return true;