Skip to content

Commit f956e61

Browse files
🎨 format tabulations
1 parent 30cd007 commit f956e61

File tree

5 files changed

+61
-61
lines changed

5 files changed

+61
-61
lines changed

include/neural-graphics-primitives/common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ enum class ERenderMode : int {
8282
static constexpr const char* RenderModeStr = "AO\0Shade\0Normals\0Positions\0Depth\0Distortion\0Cost\0Slice\0\0";
8383

8484
enum class ECameraMode : int {
85-
Perspective,
86-
Orthographic,
87-
Environment
85+
Perspective,
86+
Orthographic,
87+
Environment
8888
};
8989

9090
static constexpr const char* CameraModeStr = "Perspective\0Orthographic\0Environment\0\0";

include/neural-graphics-primitives/common_device.cuh

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -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()

include/neural-graphics-primitives/testbed.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class Testbed {
156156
int show_accel,
157157
float cone_angle_constant,
158158
ERenderMode render_mode,
159-
ECameraMode camera_mode,
159+
ECameraMode camera_mode,
160160
cudaStream_t stream
161161
);
162162

@@ -465,7 +465,7 @@ class Testbed {
465465
float m_bounding_radius = 1;
466466
float m_exposure = 0.f;
467467

468-
ECameraMode m_camera_mode = ECameraMode::Perspective;
468+
ECameraMode m_camera_mode = ECameraMode::Perspective;
469469
ERenderMode m_render_mode = ERenderMode::Shade;
470470
EMeshRenderMode m_mesh_render_mode = EMeshRenderMode::VertexNormals;
471471

src/python_api.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ PYBIND11_MODULE(pyngp, m) {
238238
.value("Slice", ERenderMode::Slice)
239239
.export_values();
240240

241-
py::enum_<ECameraMode>(m, "CameraMode")
241+
py::enum_<ECameraMode>(m, "CameraMode")
242242
.value("Perspective", ECameraMode::Perspective)
243-
.value("Orthographic", ECameraMode::Orthographic)
243+
.value("Orthographic", ECameraMode::Orthographic)
244244
.value("Environment", ECameraMode::Environment)
245245
.export_values();
246246

@@ -419,7 +419,7 @@ PYBIND11_MODULE(pyngp, m) {
419419
.def_readwrite("shall_train_network", &Testbed::m_train_network)
420420
.def_readwrite("render_groundtruth", &Testbed::m_render_ground_truth)
421421
.def_readwrite("render_mode", &Testbed::m_render_mode)
422-
.def_readwrite("camera_mode", &Testbed::m_camera_mode)
422+
.def_readwrite("camera_mode", &Testbed::m_camera_mode)
423423
.def_readwrite("slice_plane_z", &Testbed::m_slice_plane_z)
424424
.def_readwrite("dof", &Testbed::m_dof)
425425
.def_readwrite("autofocus", &Testbed::m_autofocus)

src/testbed_nerf.cu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ __global__ void init_rays_with_payload_kernel_nerf(
17811781
const float* __restrict__ distortion_data,
17821782
const Vector2i distortion_resolution,
17831783
ERenderMode render_mode,
1784-
ECameraMode camera_mode
1784+
ECameraMode camera_mode
17851785
) {
17861786
uint32_t x = threadIdx.x + blockDim.x * blockIdx.x;
17871787
uint32_t y = threadIdx.y + blockDim.y * blockIdx.y;
@@ -1812,7 +1812,7 @@ __global__ void init_rays_with_payload_kernel_nerf(
18121812
snap_to_pixel_centers,
18131813
plane_z,
18141814
dof,
1815-
camera_mode,
1815+
camera_mode,
18161816
camera_distortion,
18171817
distortion_data,
18181818
distortion_resolution
@@ -1962,7 +1962,7 @@ void Testbed::NerfTracer::init_rays_from_camera(
19621962
int show_accel,
19631963
float cone_angle_constant,
19641964
ERenderMode render_mode,
1965-
ECameraMode camera_mode,
1965+
ECameraMode camera_mode,
19661966
cudaStream_t stream
19671967
) {
19681968
// Make sure we have enough memory reserved to render at the requested resolution
@@ -1994,7 +1994,7 @@ void Testbed::NerfTracer::init_rays_from_camera(
19941994
distortion_data,
19951995
distortion_resolution,
19961996
render_mode,
1997-
camera_mode
1997+
camera_mode
19981998
);
19991999

20002000
m_n_rays_initialized = resolution.x() * resolution.y();
@@ -2257,7 +2257,7 @@ void Testbed::render_nerf(CudaRenderBuffer& render_buffer, const Vector2i& max_r
22572257
m_nerf.show_accel,
22582258
m_nerf.cone_angle_constant,
22592259
render_mode,
2260-
m_camera_mode,
2260+
m_camera_mode,
22612261
stream
22622262
);
22632263

@@ -2435,7 +2435,7 @@ void Testbed::Nerf::Training::export_camera_extrinsics(const std::string& filena
24352435
trajectory.emplace_back(frame);
24362436
}
24372437
std::ofstream file(filename);
2438-
file << std::setw(2) << trajectory << std::endl;
2438+
file << std::setw(2) << trajectory << std::endl;
24392439
}
24402440

24412441
Eigen::Matrix<float, 3, 4> Testbed::Nerf::Training::get_camera_extrinsics(int frame_idx) {

0 commit comments

Comments
 (0)