static void load_intersect(bool base, bool out, float dist, t_vertex const *ray, t_intersect *intersect) { intersect->dist = dist; intersect->pos = VEC3_ADD(ray->pos, VEC3_MUL1(ray->dir, dist)); if (base) intersect->norm = VEC3(0, 0, 1.f); else intersect->norm = ft_vec3norm(VEC3_Z(intersect->pos, -intersect->pos.z)); if (out) intersect->norm = VEC3_SUB(VEC3_0(), intersect->norm); if (base) intersect->tex = VEC2(intersect->pos.x, intersect->pos.y); else intersect->tex = VEC2(intersect->norm.z, intersect->norm.y / 2.f + 0.5f); }
void CamGetRay(const struct Camera *cam, const double *screen_uv, double time, struct Ray *ray) { const struct Transform *transform_interp = get_interpolated_transform(cam, time); double target[3] = {0, 0, 0}; double eye[3] = {0, 0, 0}; compute_ray_target(cam, screen_uv, target); XfmTransformPoint(transform_interp, target); XfmTransformPoint(transform_interp, eye); VEC3_SUB(ray->dir, target, eye); VEC3_NORMALIZE(ray->dir); VEC3_COPY(ray->orig, eye); ray->tmin = cam->znear; ray->tmax = cam->zfar; }