Skip to content

Commit cb8b232

Browse files
committed
VR support with foveated rendering and multi-GPU (one per eye)
Plus additional goodies, such as - equirectangular camera support - OpenGL 3.1 support - more accurate voxel pruning for training - cleaner GUI
1 parent 3971454 commit cb8b232

29 files changed

+4686
-1462
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@
2828
[submodule "dependencies/zlib"]
2929
path = dependencies/zlib
3030
url = https://github.com/Tom94/zlib
31+
[submodule "dependencies/OpenXR-SDK"]
32+
path = dependencies/OpenXR-SDK
33+
url = https://github.com/KhronosGroup/OpenXR-SDK.git

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,38 @@ if (NGP_BUILD_WITH_GUI)
119119
endif()
120120
endif()
121121

122+
# OpenXR
123+
if (WIN32)
124+
list(APPEND NGP_DEFINITIONS -DXR_USE_PLATFORM_WIN32 -DGLFW_EXPOSE_NATIVE_WGL)
125+
elseif (UNIX AND NOT APPLE)
126+
list(APPEND NGP_DEFINITIONS -DGLFW_EXPOSE_NATIVE_GLX)
127+
if (JK_USE_WAYLAND)
128+
set(PRESENTATION_BACKEND wayland CACHE STRING " " FORCE)
129+
set(BUILD_WITH_XLIB_HEADERS OFF CACHE BOOL " " FORCE)
130+
set(BUILD_WITH_XCB_HEADERS OFF CACHE BOOL " " FORCE)
131+
set(BUILD_WITH_WAYLAND_HEADERS ON CACHE BOOL " " FORCE)
132+
list(APPEND NGP_DEFINITIONS -DGLFW_EXPOSE_NATIVE_WAYLAND -DXR_USE_PLATFORM_WAYLAND)
133+
else()
134+
set(PRESENTATION_BACKEND xlib CACHE STRING " " FORCE)
135+
set(BUILD_WITH_XLIB_HEADERS ON CACHE BOOL " " FORCE)
136+
set(BUILD_WITH_XCB_HEADERS OFF CACHE BOOL " " FORCE)
137+
set(BUILD_WITH_WAYLAND_HEADERS OFF CACHE BOOL " " FORCE)
138+
list(APPEND NGP_DEFINITIONS -DGLFW_EXPOSE_NATIVE_X11 -DXR_USE_PLATFORM_XLIB)
139+
endif()
140+
else()
141+
message(FATAL_ERROR "No OpenXR platform set for this OS")
142+
endif()
143+
144+
add_subdirectory(dependencies/OpenXR-SDK)
145+
146+
list(APPEND NGP_INCLUDE_DIRECTORIES "dependencies/OpenXR-SDK/include" "dependencies/OpenXR-SDK/src/common")
147+
list(APPEND NGP_LIBRARIES openxr_loader)
148+
list(APPEND GUI_SOURCES src/openxr_hmd.cu)
149+
150+
# OpenGL
151+
find_package(OpenGL REQUIRED)
152+
153+
# GLFW
122154
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
123155
set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
124156
set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2022, NVIDIA Corporation & affiliates. All rights reserved.
1+
Copyright (c) 2022-2023, NVIDIA Corporation & affiliates. All rights reserved.
22

33

44
NVIDIA Source Code License for instant neural graphics primitives

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ Here are the main keyboard controls for the __instant-ngp__ application.
179179
| Spacebar / C | Move up / down. |
180180
| = or + / - or _ | Increase / decrease camera velocity. |
181181
| E / Shift+E | Increase / decrease exposure. |
182+
| Tab | Toggle menu visibility. |
182183
| T | Toggle training. After around two minutes training tends to settle down, so can be toggled off. |
184+
| { } | Go to the first/last training set image's camera view. |
185+
| [ ] | Go to the previous/next training set image's camera view. |
183186
| R | Reload network from file. |
184187
| Shift+R | Reset camera. |
185188
| O | Toggle visualization or accumulated error map. |

dependencies/OpenXR-SDK

Submodule OpenXR-SDK added at e2da9ce

include/neural-graphics-primitives/camera_path.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ struct CameraPath {
132132
#ifdef NGP_GUI
133133
ImGuizmo::MODE m_gizmo_mode = ImGuizmo::LOCAL;
134134
ImGuizmo::OPERATION m_gizmo_op = ImGuizmo::TRANSLATE;
135-
bool imgui_viz(ImDrawList* list, Eigen::Matrix<float, 4, 4>& view2proj, Eigen::Matrix<float, 4, 4>& world2proj, Eigen::Matrix<float, 4, 4>& world2view, Eigen::Vector2f focal, float aspect);
136135
int imgui(char path_filename_buf[1024], float frame_milliseconds, Eigen::Matrix<float, 3, 4>& camera, float slice_plane_z, float scale, float fov, float aperture_size, float bounding_radius, const Eigen::Matrix<float, 3, 4>& first_xform, int glow_mode, float glow_y_cutoff);
136+
bool imgui_viz(ImDrawList* list, Eigen::Matrix<float, 4, 4>& view2proj, Eigen::Matrix<float, 4, 4>& world2proj, Eigen::Matrix<float, 4, 4>& world2view, Eigen::Vector2f focal, float aspect, float znear, float zfar);
137137
#endif
138138
};
139139

include/neural-graphics-primitives/common.h

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,13 @@ enum class ELensMode : int {
232232
FTheta,
233233
LatLong,
234234
OpenCVFisheye,
235+
Equirectangular,
235236
};
236-
static constexpr const char* LensModeStr = "Perspective\0OpenCV\0F-Theta\0LatLong\0OpenCV Fisheye\0\0";
237+
static constexpr const char* LensModeStr = "Perspective\0OpenCV\0F-Theta\0LatLong\0OpenCV Fisheye\0Equirectangular\0\0";
238+
239+
inline bool supports_dlss(ELensMode mode) {
240+
return mode == ELensMode::Perspective || mode == ELensMode::OpenCV || mode == ELensMode::OpenCVFisheye;
241+
}
237242

238243
struct Lens {
239244
ELensMode mode = ELensMode::Perspective;
@@ -343,6 +348,47 @@ class Ema {
343348
std::chrono::time_point<std::chrono::steady_clock> m_creation_time;
344349
};
345350

351+
template <typename T>
352+
struct Buffer2DView {
353+
T* data = nullptr;
354+
Eigen::Vector2i resolution = Eigen::Vector2i::Zero();
355+
356+
// Lookup via integer pixel position (no bounds checking)
357+
NGP_HOST_DEVICE T at(const Eigen::Vector2i& xy) const {
358+
return data[xy.x() + xy.y() * resolution.x()];
359+
}
360+
361+
// Lookup via UV coordinates in [0,1]^2
362+
NGP_HOST_DEVICE T at(const Eigen::Vector2f& uv) const {
363+
Eigen::Vector2i xy = resolution.cast<float>().cwiseProduct(uv).cast<int>().cwiseMax(0).cwiseMin(resolution - Eigen::Vector2i::Ones());
364+
return at(xy);
365+
}
366+
367+
// Lookup via UV coordinates in [0,1]^2 and LERP the nearest texels
368+
NGP_HOST_DEVICE T at_lerp(const Eigen::Vector2f& uv) const {
369+
const Eigen::Vector2f xy_float = resolution.cast<float>().cwiseProduct(uv);
370+
const Eigen::Vector2i xy = xy_float.cast<int>();
371+
372+
const Eigen::Vector2f weight = xy_float - xy.cast<float>();
373+
374+
auto read_val = [&](Eigen::Vector2i pos) {
375+
pos = pos.cwiseMax(0).cwiseMin(resolution - Eigen::Vector2i::Ones());
376+
return at(pos);
377+
};
378+
379+
return (
380+
(1 - weight.x()) * (1 - weight.y()) * read_val({xy.x(), xy.y()}) +
381+
(weight.x()) * (1 - weight.y()) * read_val({xy.x()+1, xy.y()}) +
382+
(1 - weight.x()) * (weight.y()) * read_val({xy.x(), xy.y()+1}) +
383+
(weight.x()) * (weight.y()) * read_val({xy.x()+1, xy.y()+1})
384+
);
385+
}
386+
387+
NGP_HOST_DEVICE operator bool() const {
388+
return data;
389+
}
390+
};
391+
346392
uint8_t* load_stbi(const fs::path& path, int* width, int* height, int* comp, int req_comp);
347393
float* load_stbi_float(const fs::path& path, int* width, int* height, int* comp, int req_comp);
348394
uint16_t* load_stbi_16(const fs::path& path, int* width, int* height, int* comp, int req_comp);

0 commit comments

Comments
 (0)