@@ -261,66 +261,66 @@ inline __host__ __device__ Ray pixel_to_ray(
261261 bool snap_to_pixel_centers = false ,
262262 float focus_z = 1 .0f ,
263263 float dof = 0 .0f ,
264- const ECameraMode camera_mode = ECameraMode::Perspective,
264+ const ECameraMode camera_mode = ECameraMode::Perspective,
265265 const CameraDistortion& camera_distortion = {},
266266 const float * __restrict__ distortion_data = nullptr ,
267267 const Eigen::Vector2i distortion_resolution = Eigen::Vector2i::Zero()
268268) {
269269 Eigen::Vector2f offset = ld_random_pixel_offset (snap_to_pixel_centers ? 0 : spp);
270270 Eigen::Vector2f uv = (pixel.cast <float >() + offset).cwiseQuotient (resolution.cast <float >());
271271
272- const Eigen::Vector3f shift = {parallax_shift.x (), parallax_shift.y (), 0 .f };
272+ const Eigen::Vector3f shift = {parallax_shift.x (), parallax_shift.y (), 0 .f };
273273 Eigen::Vector3f dir;
274- Eigen::Vector3f head_pos;
275- if (camera_mode == ECameraMode::Orthographic){
276- dir = {0 .f , 0 .f , 1 .f }; // Camera forward
277- head_pos = {
278- (uv.x () - screen_center.x ()) * (float )resolution.x () / focal_length.x (),
279- (uv.y () - screen_center.y ()) * (float )resolution.y () / focal_length.y (),
280- 0 .0f
281- };
274+ Eigen::Vector3f head_pos;
275+ if (camera_mode == ECameraMode::Orthographic){
276+ dir = {0 .f , 0 .f , 1 .f }; // Camera forward
277+ head_pos = {
278+ (uv.x () - screen_center.x ()) * (float )resolution.x () / focal_length.x (),
279+ (uv.y () - screen_center.y ()) * (float )resolution.y () / focal_length.y (),
280+ 0 .0f
281+ };
282282 head_pos += shift;
283283 dir -= shift / parallax_shift.z (); // we could use focus_z here in the denominator. for now, we pack m_scale in here.
284- }
285- else if (camera_mode == ECameraMode::Environment){
286- // Camera convention: XYZ <-> Right Down Front
287- head_pos = {0 .f , 0 .f , 0 .f };
288- const float phi = (uv.y ()-0.5 ) * M_PI;
289- const float theta = (uv.x ()-0.5 ) * 2.0 * M_PI;
290- const float cos_phi = std::cos (phi);
291- dir = {
292- cos_phi*std::sin (theta),
293- std::sin (phi),
294- cos_phi*std::cos (theta)
295- };
284+ }
285+ else if (camera_mode == ECameraMode::Environment){
286+ // Camera convention: XYZ <-> Right Down Front
287+ head_pos = {0 .f , 0 .f , 0 .f };
288+ const float phi = (uv.y ()-0.5 ) * M_PI;
289+ const float theta = (uv.x ()-0.5 ) * 2.0 * M_PI;
290+ const float cos_phi = std::cos (phi);
291+ dir = {
292+ cos_phi*std::sin (theta),
293+ std::sin (phi),
294+ cos_phi*std::cos (theta)
295+ };
296296 // Parallax isn't handled
297- }
298- else { // Perspective
299- head_pos = {0 .f , 0 .f , 0 .f };
300- if (camera_distortion.mode == ECameraDistortionMode::FTheta) {
301- dir = f_theta_undistortion (uv - screen_center, camera_distortion.params , {1000 .f , 0 .f , 0 .f });
302- if (dir.x () == 1000 .f ) {
303- return {{1000 .f , 0 .f , 0 .f }, {0 .f , 0 .f , 1 .f }}; // return a point outside the aabb so the pixel is not rendered
304- }
305- } else {
306- dir = {
307- (uv.x () - screen_center.x ()) * (float )resolution.x () / focal_length.x (),
308- (uv.y () - screen_center.y ()) * (float )resolution.y () / focal_length.y (),
309- 1 .0f
310- };
311- if (camera_distortion.mode == ECameraDistortionMode::Iterative) {
312- iterative_camera_undistortion (camera_distortion.params , &dir.x (), &dir.y ());
313- }
314- }
315- if (distortion_data) {
316- dir.head <2 >() += read_image<2 >(distortion_data, distortion_resolution, uv);
317- }
297+ }
298+ else { // Perspective
299+ head_pos = {0 .f , 0 .f , 0 .f };
300+ if (camera_distortion.mode == ECameraDistortionMode::FTheta) {
301+ dir = f_theta_undistortion (uv - screen_center, camera_distortion.params , {1000 .f , 0 .f , 0 .f });
302+ if (dir.x () == 1000 .f ) {
303+ return {{1000 .f , 0 .f , 0 .f }, {0 .f , 0 .f , 1 .f }}; // return a point outside the aabb so the pixel is not rendered
304+ }
305+ } else {
306+ dir = {
307+ (uv.x () - screen_center.x ()) * (float )resolution.x () / focal_length.x (),
308+ (uv.y () - screen_center.y ()) * (float )resolution.y () / focal_length.y (),
309+ 1 .0f
310+ };
311+ if (camera_distortion.mode == ECameraDistortionMode::Iterative) {
312+ iterative_camera_undistortion (camera_distortion.params , &dir.x (), &dir.y ());
313+ }
314+ }
315+ if (distortion_data) {
316+ dir.head <2 >() += read_image<2 >(distortion_data, distortion_resolution, uv);
317+ }
318318 head_pos += shift;
319319 dir -= shift / parallax_shift.z (); // we could use focus_z here in the denominator. for now, we pack m_scale in here.
320- }
320+ }
321321
322- dir = camera_matrix.block <3 , 3 >(0 , 0 ) * dir;
323- Eigen::Vector3f origin = camera_matrix.block <3 , 3 >(0 , 0 ) * head_pos + camera_matrix.col (3 );
322+ dir = camera_matrix.block <3 , 3 >(0 , 0 ) * dir;
323+ Eigen::Vector3f origin = camera_matrix.block <3 , 3 >(0 , 0 ) * head_pos + camera_matrix.col (3 );
324324
325325 if (dof == 0 .0f ) {
326326 return {origin, dir};
@@ -425,7 +425,7 @@ inline __host__ __device__ Eigen::Vector2f motion_vector_3d(
425425 snap_to_pixel_centers,
426426 1 .0f ,
427427 0 .0f ,
428- camera_mode,
428+ camera_mode,
429429 camera_distortion,
430430 nullptr ,
431431 Eigen::Vector2i::Zero ()
0 commit comments