#include "ff.h" #include "render.h" #include #define W 1920 #define H 1080 #define FOV 90 #define APERTURE 0.8 #define FOCAL_LEN -1 #define SAMPLES_PER_PIXEL 1000 #define NELEMS(arr) (sizeof(arr) / sizeof(arr[0])) static const vec3_t camera_pos = { 80.0, 20.0, 60.0 }; static const vec3_t target = { 0.0, 0.0, 10.0 }; static const vec3_t sky_pos = { 0.4, 0.7, 1.0 }; static const vec3_t sky_neg = { 1.0, 1.0, 1.0 }; static const material_t floor = LAMBERTIAN(1.0, 0.94, 0.80); static const material_t light = AREA_LIGHT(1.0, 0.8, 0.5, 3.0); static const material_t white = LAMBERTIAN(1.0, 1.0, 1.0); static const material_t gold = REFLECTIVE(1.0, 0.9, 0.5, 0.0); static const material_t silver = REFLECTIVE(0.9, 0.9, 0.9, 0.0); static const material_t glass = DIELECTRIC(1.5); static obj_t objs[] = { SPHERE(0.0, -100'000.0, 0.0, 100'000.0, floor), SPHERE(-3000.0, 3000.0, -2000.0, 1000.0, light), SPHERE(0.0, 10.0, -33.0, 10.0, gold), SPHERE(0.0, 10.0, -11.0, 10.0, glass), SPHERE(0.0, 10.0, 11.0, 10.0, silver), SPHERE(0.0, 10.0, 33.0, 10.0, white), }; static pix_t pixbuf[W * H]; int main() { img_t img = { .pix = pixbuf }; camera_t camera = camera_init(camera_pos, target, FOV, W, H, APERTURE, FOCAL_LEN); const scene_t scene = { .sky_pos = sky_pos, .sky_neg = sky_neg, .objs = objs, .obj_count = NELEMS(objs), }; render(&camera, &scene, &img, SAMPLES_PER_PIXEL); ff_write(STDOUT_FILENO, img); return 0; }