Allow -1 to be passed for auto focal length
This commit is contained in:
@@ -12,6 +12,9 @@ camera_t camera_init(
|
|||||||
vec3_t pos, vec3_t target, double fov, uint32_t img_width,
|
vec3_t pos, vec3_t target, double fov, uint32_t img_width,
|
||||||
uint32_t img_height, double aperture, double focal_len)
|
uint32_t img_height, double aperture, double focal_len)
|
||||||
{
|
{
|
||||||
|
if (focal_len = -1)
|
||||||
|
focal_len = vec3_len(vec3_sub(target, pos));
|
||||||
|
|
||||||
const double fov_rad = M_PI * fov / 180.0;
|
const double fov_rad = M_PI * fov / 180.0;
|
||||||
const double aspect = (double)img_width / (double)img_height;
|
const double aspect = (double)img_width / (double)img_height;
|
||||||
const double viewport_height = focal_len * tan(fov_rad / 2);
|
const double viewport_height = focal_len * tan(fov_rad / 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user