Remove focal_len parameter from camera (hard-code as 1.0)
This commit is contained in:
4
demo.c
4
demo.c
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#define W 800
|
#define W 800
|
||||||
#define H 600
|
#define H 600
|
||||||
#define FOCAL_LEN 1.0
|
|
||||||
#define FOV 120
|
#define FOV 120
|
||||||
#define SAMPLES_PER_PIXEL 100
|
#define SAMPLES_PER_PIXEL 100
|
||||||
|
|
||||||
@@ -31,8 +30,7 @@ static pix_t pixbuf[W * H];
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
img_t img = { .pix = pixbuf };
|
img_t img = { .pix = pixbuf };
|
||||||
camera_t camera
|
camera_t camera = camera_init(camera_pos, FOV, W, H, SAMPLES_PER_PIXEL);
|
||||||
= camera_init(camera_pos, FOCAL_LEN, FOV, W, H, SAMPLES_PER_PIXEL);
|
|
||||||
camera_render(&camera, scene, NELEMS(scene), &img);
|
camera_render(&camera, scene, NELEMS(scene), &img);
|
||||||
|
|
||||||
ff_write(STDOUT_FILENO, img);
|
ff_write(STDOUT_FILENO, img);
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ typedef struct {
|
|||||||
} camera_t;
|
} camera_t;
|
||||||
|
|
||||||
camera_t camera_init(
|
camera_t camera_init(
|
||||||
vec3_t pos, double focal_len, double fov, uint32_t img_width,
|
vec3_t pos, double fov, uint32_t img_width, uint32_t img_height,
|
||||||
uint32_t img_height, unsigned samples_per_pixel);
|
unsigned samples_per_pixel);
|
||||||
|
|
||||||
void camera_render(
|
void camera_render(
|
||||||
const camera_t *camera, const obj_t *scene, unsigned scene_count,
|
const camera_t *camera, const obj_t *scene, unsigned scene_count,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#define MAX_ITER 10
|
#define MAX_ITER 10
|
||||||
#define MIN_T 1e-6
|
#define MIN_T 1e-6
|
||||||
#define SAMPLE_STDDEV 0.333
|
#define SAMPLE_STDDEV 0.333
|
||||||
|
#define FOCAL_LEN 1.0
|
||||||
|
|
||||||
#define GAMMA 2.2
|
#define GAMMA 2.2
|
||||||
|
|
||||||
@@ -117,15 +118,15 @@ static int render_thread(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
camera_t camera_init(
|
camera_t camera_init(
|
||||||
vec3_t pos, double focal_len, double fov, uint32_t img_width,
|
vec3_t pos, double fov, uint32_t img_width, uint32_t img_height,
|
||||||
uint32_t img_height, unsigned samples_per_pixel)
|
unsigned samples_per_pixel)
|
||||||
{
|
{
|
||||||
const double aspect = (double)img_width / (double)img_height;
|
const double aspect = (double)img_width / (double)img_height;
|
||||||
|
|
||||||
const double fov_rad = M_PI * fov / 180.0;
|
const double fov_rad = M_PI * fov / 180.0;
|
||||||
const double viewport_height = focal_len * tan(fov_rad / 2);
|
const double viewport_height = FOCAL_LEN * tan(fov_rad / 2);
|
||||||
const double viewport_width = viewport_height * aspect;
|
const double viewport_width = viewport_height * aspect;
|
||||||
const vec3_t viewport_disp = { 0, 0, focal_len };
|
const vec3_t viewport_disp = { 0, 0, FOCAL_LEN };
|
||||||
|
|
||||||
const vec3_t u = { viewport_width, 0, 0 };
|
const vec3_t u = { viewport_width, 0, 0 };
|
||||||
const vec3_t v = { 0, -viewport_height, 0 };
|
const vec3_t v = { 0, -viewport_height, 0 };
|
||||||
|
|||||||
Reference in New Issue
Block a user