rayd 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rayd-0.1.0/.github/workflows/pypi.yml +179 -0
- rayd-0.1.0/.gitignore +21 -0
- rayd-0.1.0/CMakeLists.txt +217 -0
- rayd-0.1.0/PKG-INFO +236 -0
- rayd-0.1.0/README.md +225 -0
- rayd-0.1.0/docs/api_reference.md +454 -0
- rayd-0.1.0/docs/build_optimization.md +71 -0
- rayd-0.1.0/docs/slang_interop.md +95 -0
- rayd-0.1.0/examples/README.md +10 -0
- rayd-0.1.0/examples/basics/camera_edge_sampling_gradient.py +103 -0
- rayd-0.1.0/examples/basics/nearest_edge_query.py +53 -0
- rayd-0.1.0/examples/basics/ray_mesh_intersection.py +53 -0
- rayd-0.1.0/examples/renderer/README.md +1 -0
- rayd-0.1.0/examples/renderer/optical.py +261 -0
- rayd-0.1.0/include/rayd/camera.h +172 -0
- rayd-0.1.0/include/rayd/constants.h +13 -0
- rayd-0.1.0/include/rayd/edge.h +142 -0
- rayd-0.1.0/include/rayd/fwd.h +41 -0
- rayd-0.1.0/include/rayd/intersection.h +32 -0
- rayd-0.1.0/include/rayd/mesh.h +168 -0
- rayd-0.1.0/include/rayd/optix.h +291 -0
- rayd-0.1.0/include/rayd/ray.h +34 -0
- rayd-0.1.0/include/rayd/rayd.h +22 -0
- rayd-0.1.0/include/rayd/scene/scene.h +112 -0
- rayd-0.1.0/include/rayd/scene/scene_edge.h +70 -0
- rayd-0.1.0/include/rayd/scene/scene_optix.h +66 -0
- rayd-0.1.0/include/rayd/slang/interop.h +402 -0
- rayd-0.1.0/include/rayd/slang/rayd.slang +350 -0
- rayd-0.1.0/include/rayd/transform.h +96 -0
- rayd-0.1.0/include/rayd/types.h +133 -0
- rayd-0.1.0/include/rayd/utils.h +296 -0
- rayd-0.1.0/pyproject.toml +22 -0
- rayd-0.1.0/src/camera.cpp +463 -0
- rayd-0.1.0/src/mesh.cpp +439 -0
- rayd-0.1.0/src/optix.cpp +233 -0
- rayd-0.1.0/src/rayd/__init__.py +15 -0
- rayd-0.1.0/src/rayd/torch/__init__.py +1495 -0
- rayd-0.1.0/src/rayd.cpp +373 -0
- rayd-0.1.0/src/scene/edge_bvh.cu +1220 -0
- rayd-0.1.0/src/scene/edge_bvh.h +31 -0
- rayd-0.1.0/src/scene/scene.cpp +826 -0
- rayd-0.1.0/src/scene/scene_edge.cpp +1623 -0
- rayd-0.1.0/src/scene/scene_optix.cpp +841 -0
- rayd-0.1.0/tests/baseline_cases.py +422 -0
- rayd-0.1.0/tests/baseline_utils.py +154 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/camera/perspective_fov.json +80 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/camera/perspective_intrinsic.json +80 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/camera/sample_primary_ray.json +158 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/camera/sample_to_world.json +90 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/camera/world_to_sample.json +90 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/edges/primary_edge_sampling.json +31 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/edges/secondary_edges.json +182 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/geometry/batched_hits.json +76 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/geometry/constant_hit.json +30 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/geometry/degenerate.json +29 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/geometry/miss.json +6 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/geometry/multi_mesh.json +11 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/geometry/uv.json +10 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/gradients/transform_gradients.json +31 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/gradients/vertex_gradients.json +21 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/manifest.json +17 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/stress/repeated_run_summary.json +5 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/transforms/composition_left_right.json +218 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/transforms/direction_transform_checks.json +252 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/transforms/matrix_entry_checks.json +132 -0
- rayd-0.1.0/tests/baselines/drjit_v0_4_6/transforms/point_transform_checks.json +312 -0
- rayd-0.1.0/tests/benchmark_support.py +751 -0
- rayd-0.1.0/tests/test_baseline.py +50 -0
- rayd-0.1.0/tests/test_geometry.py +1580 -0
- rayd-0.1.0/tests/test_torch_geometry.py +474 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
name: Build And Publish PyPI Wheels
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
release:
|
|
9
|
+
types:
|
|
10
|
+
- published
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build_linux_wheels:
|
|
15
|
+
name: linux / manylinux_2_28
|
|
16
|
+
runs-on: ubuntu-22.04
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v5
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
|
|
27
|
+
- name: Build Linux wheels
|
|
28
|
+
uses: pypa/cibuildwheel@v3.3.0
|
|
29
|
+
env:
|
|
30
|
+
CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64"
|
|
31
|
+
CIBW_SKIP: "*-musllinux_*"
|
|
32
|
+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
|
|
33
|
+
CIBW_BEFORE_ALL_LINUX: >-
|
|
34
|
+
dnf install -y dnf-plugins-core gcc-toolset-13 &&
|
|
35
|
+
rpm --import https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/D42D0685.pub &&
|
|
36
|
+
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo &&
|
|
37
|
+
dnf clean expire-cache &&
|
|
38
|
+
dnf install -y cuda-toolkit-12-5 &&
|
|
39
|
+
ln -sfn /usr/local/cuda-12.5 /usr/local/cuda &&
|
|
40
|
+
/usr/local/cuda/bin/nvcc --version
|
|
41
|
+
CIBW_ENVIRONMENT_LINUX: >-
|
|
42
|
+
CUDA_HOME=/usr/local/cuda
|
|
43
|
+
CUDA_PATH=/usr/local/cuda
|
|
44
|
+
CUDA_ROOT=/usr/local/cuda
|
|
45
|
+
CUDA_BIN_PATH=/usr/local/cuda
|
|
46
|
+
CUDACXX=/usr/local/cuda/bin/nvcc
|
|
47
|
+
CC=/opt/rh/gcc-toolset-13/root/usr/bin/gcc
|
|
48
|
+
CXX=/opt/rh/gcc-toolset-13/root/usr/bin/g++
|
|
49
|
+
CUDAHOSTCXX=/opt/rh/gcc-toolset-13/root/usr/bin/g++
|
|
50
|
+
PATH=/usr/local/cuda/bin:$PATH
|
|
51
|
+
LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
|
|
52
|
+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >-
|
|
53
|
+
auditwheel repair
|
|
54
|
+
--exclude libcuda.so.1
|
|
55
|
+
--exclude libnvoptix.so.1
|
|
56
|
+
--exclude libdrjit-core.so
|
|
57
|
+
--exclude libdrjit-extra.so
|
|
58
|
+
--exclude libnanothread.so
|
|
59
|
+
-w {dest_dir} {wheel}
|
|
60
|
+
with:
|
|
61
|
+
output-dir: dist
|
|
62
|
+
|
|
63
|
+
- name: Upload Linux wheel artifacts
|
|
64
|
+
uses: actions/upload-artifact@v4
|
|
65
|
+
with:
|
|
66
|
+
name: wheels-linux
|
|
67
|
+
path: dist/*.whl
|
|
68
|
+
if-no-files-found: error
|
|
69
|
+
|
|
70
|
+
build_windows_wheels:
|
|
71
|
+
name: windows / py${{ matrix.python_version }}
|
|
72
|
+
runs-on: windows-2022
|
|
73
|
+
strategy:
|
|
74
|
+
fail-fast: false
|
|
75
|
+
matrix:
|
|
76
|
+
python_version: ["3.10", "3.11", "3.12", "3.13"]
|
|
77
|
+
|
|
78
|
+
steps:
|
|
79
|
+
- name: Checkout
|
|
80
|
+
uses: actions/checkout@v5
|
|
81
|
+
|
|
82
|
+
- name: Set up Python
|
|
83
|
+
uses: actions/setup-python@v5
|
|
84
|
+
with:
|
|
85
|
+
python-version: ${{ matrix.python_version }}
|
|
86
|
+
|
|
87
|
+
- name: Install CUDA Toolkit
|
|
88
|
+
uses: Jimver/cuda-toolkit@v0.2.29
|
|
89
|
+
with:
|
|
90
|
+
cuda: "12.5.0"
|
|
91
|
+
method: local
|
|
92
|
+
log-file-suffix: "windows-py${{ matrix.python_version }}.log"
|
|
93
|
+
|
|
94
|
+
- name: Show toolchain
|
|
95
|
+
shell: bash
|
|
96
|
+
run: |
|
|
97
|
+
python --version
|
|
98
|
+
cmake --version || true
|
|
99
|
+
nvcc --version
|
|
100
|
+
|
|
101
|
+
- name: Install build frontend
|
|
102
|
+
run: python -m pip install --upgrade pip build cmake ninja
|
|
103
|
+
|
|
104
|
+
- name: Build wheel
|
|
105
|
+
env:
|
|
106
|
+
CMAKE_BUILD_PARALLEL_LEVEL: "4"
|
|
107
|
+
run: python -m build --wheel
|
|
108
|
+
|
|
109
|
+
- name: Upload Windows wheel artifacts
|
|
110
|
+
uses: actions/upload-artifact@v4
|
|
111
|
+
with:
|
|
112
|
+
name: wheels-windows-py${{ matrix.python_version }}
|
|
113
|
+
path: dist/*.whl
|
|
114
|
+
if-no-files-found: error
|
|
115
|
+
|
|
116
|
+
build_sdist:
|
|
117
|
+
name: sdist
|
|
118
|
+
runs-on: ubuntu-22.04
|
|
119
|
+
|
|
120
|
+
steps:
|
|
121
|
+
- name: Checkout
|
|
122
|
+
uses: actions/checkout@v5
|
|
123
|
+
|
|
124
|
+
- name: Set up Python
|
|
125
|
+
uses: actions/setup-python@v5
|
|
126
|
+
with:
|
|
127
|
+
python-version: "3.12"
|
|
128
|
+
|
|
129
|
+
- name: Install build frontend
|
|
130
|
+
run: python -m pip install --upgrade pip build
|
|
131
|
+
|
|
132
|
+
- name: Build source distribution
|
|
133
|
+
run: python -m build --sdist
|
|
134
|
+
|
|
135
|
+
- name: Upload sdist artifact
|
|
136
|
+
uses: actions/upload-artifact@v4
|
|
137
|
+
with:
|
|
138
|
+
name: sdist
|
|
139
|
+
path: dist/*.tar.gz
|
|
140
|
+
if-no-files-found: error
|
|
141
|
+
|
|
142
|
+
publish:
|
|
143
|
+
name: Publish To PyPI
|
|
144
|
+
if: github.event_name == 'release' && github.event.action == 'published'
|
|
145
|
+
needs:
|
|
146
|
+
- build_linux_wheels
|
|
147
|
+
- build_windows_wheels
|
|
148
|
+
- build_sdist
|
|
149
|
+
runs-on: ubuntu-latest
|
|
150
|
+
environment:
|
|
151
|
+
name: pypi
|
|
152
|
+
url: https://pypi.org/p/rayd
|
|
153
|
+
permissions:
|
|
154
|
+
contents: read
|
|
155
|
+
id-token: write
|
|
156
|
+
|
|
157
|
+
steps:
|
|
158
|
+
- name: Download wheel artifacts
|
|
159
|
+
uses: actions/download-artifact@v4
|
|
160
|
+
with:
|
|
161
|
+
path: dist
|
|
162
|
+
pattern: wheels-*
|
|
163
|
+
merge-multiple: true
|
|
164
|
+
|
|
165
|
+
- name: Download sdist artifact
|
|
166
|
+
uses: actions/download-artifact@v4
|
|
167
|
+
with:
|
|
168
|
+
name: sdist
|
|
169
|
+
path: dist
|
|
170
|
+
|
|
171
|
+
- name: Remove non-package files
|
|
172
|
+
shell: bash
|
|
173
|
+
run: find dist -maxdepth 1 -type f ! \( -name '*.whl' -o -name '*.tar.gz' \) -delete
|
|
174
|
+
|
|
175
|
+
- name: Publish distributions
|
|
176
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
177
|
+
with:
|
|
178
|
+
packages-dir: dist
|
|
179
|
+
verbose: true
|
rayd-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
*.o
|
|
2
|
+
*.so
|
|
3
|
+
*.log
|
|
4
|
+
*.exe
|
|
5
|
+
__pycache__
|
|
6
|
+
build/
|
|
7
|
+
ext_win64/
|
|
8
|
+
local/
|
|
9
|
+
scripts/
|
|
10
|
+
AGENTS.md
|
|
11
|
+
claude.md
|
|
12
|
+
dev_notes.md
|
|
13
|
+
dist/
|
|
14
|
+
tmp/
|
|
15
|
+
**/*.log
|
|
16
|
+
unit_test/*.exr
|
|
17
|
+
unit_test/inv_test/
|
|
18
|
+
unit_test/result/
|
|
19
|
+
.ipynb_checkpoints
|
|
20
|
+
.vscode/
|
|
21
|
+
.claude
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15...3.22)
|
|
2
|
+
if(POLICY CMP0146)
|
|
3
|
+
cmake_policy(SET CMP0146 OLD)
|
|
4
|
+
endif()
|
|
5
|
+
|
|
6
|
+
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION})
|
|
7
|
+
|
|
8
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
9
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
10
|
+
|
|
11
|
+
option(RAYD_OPTIX_PRODUCTION_CONFIG "Use OptiX production module settings (LEVEL_3 + no exceptions)." ON)
|
|
12
|
+
option(RAYD_NANOBIND_NOMINSIZE "Disable nanobind's size-oriented optimization flags in optimized configs." ON)
|
|
13
|
+
option(RAYD_ENABLE_LTO "Enable nanobind/C++ link-time optimization." OFF)
|
|
14
|
+
|
|
15
|
+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
|
|
16
|
+
execute_process(
|
|
17
|
+
COMMAND "${Python_EXECUTABLE}" -c "import importlib.util, pathlib, sys; spec = importlib.util.find_spec('drjit'); sys.stdout.write(str(pathlib.Path(next(iter(spec.submodule_search_locations))).resolve() / 'cmake')) if spec and spec.submodule_search_locations else sys.exit(1)"
|
|
18
|
+
RESULT_VARIABLE DRJIT_CMAKE_DIR_RESULT
|
|
19
|
+
OUTPUT_VARIABLE DRJIT_CMAKE_DIR
|
|
20
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
21
|
+
)
|
|
22
|
+
if(NOT DRJIT_CMAKE_DIR_RESULT EQUAL 0)
|
|
23
|
+
message(FATAL_ERROR "Could not locate the installed Dr.Jit CMake package. Ensure drjit>=1.3.0 is installed in the build environment.")
|
|
24
|
+
endif()
|
|
25
|
+
|
|
26
|
+
execute_process(
|
|
27
|
+
COMMAND "${Python_EXECUTABLE}" -c "import importlib.util, pathlib, sys; spec = importlib.util.find_spec('nanobind'); sys.stdout.write(str(pathlib.Path(next(iter(spec.submodule_search_locations))).resolve() / 'cmake')) if spec and spec.submodule_search_locations else sys.exit(1)"
|
|
28
|
+
RESULT_VARIABLE NANOBIND_CMAKE_DIR_RESULT
|
|
29
|
+
OUTPUT_VARIABLE NANOBIND_CMAKE_DIR
|
|
30
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
31
|
+
)
|
|
32
|
+
if(NOT NANOBIND_CMAKE_DIR_RESULT EQUAL 0)
|
|
33
|
+
message(FATAL_ERROR "Could not locate the installed nanobind CMake package.")
|
|
34
|
+
endif()
|
|
35
|
+
|
|
36
|
+
list(PREPEND CMAKE_PREFIX_PATH "${DRJIT_CMAKE_DIR}" "${NANOBIND_CMAKE_DIR}")
|
|
37
|
+
find_package(drjit CONFIG REQUIRED)
|
|
38
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
39
|
+
|
|
40
|
+
if(WIN32)
|
|
41
|
+
add_definitions(-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS)
|
|
42
|
+
else()
|
|
43
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder -Wno-sign-compare -fPIC")
|
|
44
|
+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
|
|
45
|
+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -DNDEBUG")
|
|
46
|
+
endif()
|
|
47
|
+
|
|
48
|
+
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
|
49
|
+
|
|
50
|
+
if(RAYD_OPTIX_PRODUCTION_CONFIG)
|
|
51
|
+
set(RAYD_OPTIX_MODULE_OPT_LEVEL 0x2343)
|
|
52
|
+
set(RAYD_OPTIX_EXCEPTION_FLAGS 0)
|
|
53
|
+
else()
|
|
54
|
+
set(RAYD_OPTIX_MODULE_OPT_LEVEL 0x2340)
|
|
55
|
+
set(RAYD_OPTIX_EXCEPTION_FLAGS 11)
|
|
56
|
+
endif()
|
|
57
|
+
|
|
58
|
+
find_package(CUDA 11.0 REQUIRED)
|
|
59
|
+
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
|
|
60
|
+
mark_as_advanced(CLEAR CUDA_64_BIT_DEVICE_CODE)
|
|
61
|
+
|
|
62
|
+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
|
63
|
+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|
64
|
+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|
65
|
+
|
|
66
|
+
include_directories(
|
|
67
|
+
include/
|
|
68
|
+
${CMAKE_CURRENT_SOURCE_DIR}
|
|
69
|
+
${CMAKE_CURRENT_BINARY_DIR}
|
|
70
|
+
${CUDA_INCLUDE_DIRS}
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
set(RAYD_INCLUDE_DIR include/rayd)
|
|
74
|
+
set(RAYD_SOURCE_DIR src)
|
|
75
|
+
set(RAYD_CORE_SOURCE_FILES
|
|
76
|
+
${RAYD_INCLUDE_DIR}/rayd.h
|
|
77
|
+
${RAYD_INCLUDE_DIR}/constants.h
|
|
78
|
+
${RAYD_INCLUDE_DIR}/fwd.h
|
|
79
|
+
${RAYD_INCLUDE_DIR}/types.h
|
|
80
|
+
${RAYD_INCLUDE_DIR}/utils.h
|
|
81
|
+
|
|
82
|
+
${RAYD_INCLUDE_DIR}/ray.h
|
|
83
|
+
${RAYD_INCLUDE_DIR}/intersection.h
|
|
84
|
+
${RAYD_INCLUDE_DIR}/transform.h
|
|
85
|
+
|
|
86
|
+
${RAYD_INCLUDE_DIR}/edge.h
|
|
87
|
+
|
|
88
|
+
${RAYD_INCLUDE_DIR}/mesh.h
|
|
89
|
+
${RAYD_SOURCE_DIR}/mesh.cpp
|
|
90
|
+
|
|
91
|
+
${RAYD_INCLUDE_DIR}/optix.h
|
|
92
|
+
|
|
93
|
+
${RAYD_INCLUDE_DIR}/camera.h
|
|
94
|
+
${RAYD_SOURCE_DIR}/camera.cpp
|
|
95
|
+
|
|
96
|
+
${RAYD_INCLUDE_DIR}/scene/scene_optix.h
|
|
97
|
+
${RAYD_SOURCE_DIR}/scene/scene_optix.cpp
|
|
98
|
+
${RAYD_INCLUDE_DIR}/scene/scene_edge.h
|
|
99
|
+
${RAYD_SOURCE_DIR}/scene/scene_edge.cpp
|
|
100
|
+
${RAYD_SOURCE_DIR}/scene/edge_bvh.h
|
|
101
|
+
|
|
102
|
+
${RAYD_INCLUDE_DIR}/scene/scene.h
|
|
103
|
+
${RAYD_SOURCE_DIR}/scene/scene.cpp
|
|
104
|
+
|
|
105
|
+
${RAYD_SOURCE_DIR}/optix.cpp
|
|
106
|
+
)
|
|
107
|
+
if(WIN32)
|
|
108
|
+
set(RAYD_CUDA_OBJECT "${CMAKE_CURRENT_BINARY_DIR}/edge_bvh.obj")
|
|
109
|
+
set(RAYD_VSDEVCMD "${CMAKE_GENERATOR_INSTANCE}/Common7/Tools/VsDevCmd.bat")
|
|
110
|
+
set(RAYD_CUDA_BUILD_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/build_edge_bvh.bat")
|
|
111
|
+
file(GENERATE OUTPUT "${RAYD_CUDA_BUILD_SCRIPT}" CONTENT
|
|
112
|
+
"@echo off\r\n\
|
|
113
|
+
call \"${RAYD_VSDEVCMD}\" -arch=x64\r\n\
|
|
114
|
+
if errorlevel 1 exit /b %errorlevel%\r\n\
|
|
115
|
+
\"${CUDA_NVCC_EXECUTABLE}\" --extended-lambda -std=c++17 -c \"${CMAKE_CURRENT_SOURCE_DIR}/${RAYD_SOURCE_DIR}/scene/edge_bvh.cu\" -I\"${CMAKE_CURRENT_SOURCE_DIR}/include\" -I\"${CMAKE_CURRENT_SOURCE_DIR}\" -Xcompiler \"/MD /O2 /EHsc /wd4819\" -o \"${RAYD_CUDA_OBJECT}\"\r\n\
|
|
116
|
+
")
|
|
117
|
+
add_custom_command(
|
|
118
|
+
OUTPUT "${RAYD_CUDA_OBJECT}"
|
|
119
|
+
COMMAND "${RAYD_CUDA_BUILD_SCRIPT}"
|
|
120
|
+
DEPENDS
|
|
121
|
+
"${RAYD_CUDA_BUILD_SCRIPT}"
|
|
122
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/${RAYD_SOURCE_DIR}/scene/edge_bvh.cu"
|
|
123
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/${RAYD_SOURCE_DIR}/scene/edge_bvh.h"
|
|
124
|
+
VERBATIM
|
|
125
|
+
)
|
|
126
|
+
else()
|
|
127
|
+
set(RAYD_CUDA_OBJECT "${CMAKE_CURRENT_BINARY_DIR}/edge_bvh.o")
|
|
128
|
+
add_custom_command(
|
|
129
|
+
OUTPUT "${RAYD_CUDA_OBJECT}"
|
|
130
|
+
COMMAND "${CUDA_NVCC_EXECUTABLE}" -ccbin "${CMAKE_CXX_COMPILER}" -std=c++17 -Xcompiler=-fPIC -c
|
|
131
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/${RAYD_SOURCE_DIR}/scene/edge_bvh.cu"
|
|
132
|
+
-I"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
133
|
+
-I"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
134
|
+
-o "${RAYD_CUDA_OBJECT}"
|
|
135
|
+
DEPENDS
|
|
136
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/${RAYD_SOURCE_DIR}/scene/edge_bvh.cu"
|
|
137
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/${RAYD_SOURCE_DIR}/scene/edge_bvh.h"
|
|
138
|
+
VERBATIM
|
|
139
|
+
)
|
|
140
|
+
endif()
|
|
141
|
+
set_source_files_properties("${RAYD_CUDA_OBJECT}" PROPERTIES EXTERNAL_OBJECT TRUE GENERATED TRUE)
|
|
142
|
+
list(APPEND RAYD_CORE_SOURCE_FILES "${RAYD_CUDA_OBJECT}")
|
|
143
|
+
|
|
144
|
+
set(RAYD_NANOBIND_ARGS NB_DOMAIN drjit)
|
|
145
|
+
if(RAYD_NANOBIND_NOMINSIZE)
|
|
146
|
+
list(APPEND RAYD_NANOBIND_ARGS NOMINSIZE)
|
|
147
|
+
endif()
|
|
148
|
+
if(RAYD_ENABLE_LTO)
|
|
149
|
+
list(APPEND RAYD_NANOBIND_ARGS LTO)
|
|
150
|
+
endif()
|
|
151
|
+
|
|
152
|
+
add_library(rayd_core STATIC ${RAYD_CORE_SOURCE_FILES})
|
|
153
|
+
target_include_directories(rayd_core PUBLIC
|
|
154
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
155
|
+
${CMAKE_CURRENT_SOURCE_DIR}
|
|
156
|
+
${CMAKE_CURRENT_BINARY_DIR}
|
|
157
|
+
${CUDA_INCLUDE_DIRS}
|
|
158
|
+
)
|
|
159
|
+
target_compile_definitions(rayd_core PRIVATE
|
|
160
|
+
RAYD_OPTIX_MODULE_OPT_LEVEL=${RAYD_OPTIX_MODULE_OPT_LEVEL}
|
|
161
|
+
RAYD_OPTIX_EXCEPTION_FLAGS=${RAYD_OPTIX_EXCEPTION_FLAGS}
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
if(WIN32)
|
|
165
|
+
target_compile_options(rayd_core PRIVATE
|
|
166
|
+
$<$<COMPILE_LANGUAGE:CXX>:/wd4251>
|
|
167
|
+
$<$<COMPILE_LANGUAGE:CXX>:/MP>
|
|
168
|
+
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:Release>>:/O2>
|
|
169
|
+
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RelWithDebInfo>>:/O2>
|
|
170
|
+
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:MinSizeRel>>:/O2>
|
|
171
|
+
)
|
|
172
|
+
endif()
|
|
173
|
+
|
|
174
|
+
set(PYRAYD_LIBRARIES drjit drjit-core drjit-extra nanothread)
|
|
175
|
+
if(WIN32)
|
|
176
|
+
list(APPEND PYRAYD_LIBRARIES version)
|
|
177
|
+
endif()
|
|
178
|
+
target_link_libraries(rayd_core PUBLIC ${PYRAYD_LIBRARIES} ${CUDA_LIBRARIES})
|
|
179
|
+
set_property(TARGET rayd_core PROPERTY CXX_STANDARD 17)
|
|
180
|
+
set_target_properties(rayd_core PROPERTIES
|
|
181
|
+
POSITION_INDEPENDENT_CODE ON
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
nanobind_add_module(rayd ${RAYD_NANOBIND_ARGS} ${RAYD_SOURCE_DIR}/rayd.cpp)
|
|
185
|
+
target_link_libraries(rayd PRIVATE rayd_core)
|
|
186
|
+
if(WIN32)
|
|
187
|
+
target_compile_options(rayd PRIVATE
|
|
188
|
+
$<$<COMPILE_LANGUAGE:CXX>:/wd4251>
|
|
189
|
+
$<$<COMPILE_LANGUAGE:CXX>:/MP>
|
|
190
|
+
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:Release>>:/O2>
|
|
191
|
+
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RelWithDebInfo>>:/O2>
|
|
192
|
+
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:MinSizeRel>>:/O2>
|
|
193
|
+
)
|
|
194
|
+
endif()
|
|
195
|
+
|
|
196
|
+
install(TARGETS rayd DESTINATION rayd)
|
|
197
|
+
install(TARGETS rayd_core
|
|
198
|
+
ARCHIVE DESTINATION rayd/lib
|
|
199
|
+
LIBRARY DESTINATION rayd/lib
|
|
200
|
+
RUNTIME DESTINATION rayd/bin
|
|
201
|
+
)
|
|
202
|
+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/rayd
|
|
203
|
+
DESTINATION .
|
|
204
|
+
FILES_MATCHING
|
|
205
|
+
PATTERN "*.h"
|
|
206
|
+
PATTERN "*.slang"
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
set_target_properties(rayd PROPERTIES
|
|
210
|
+
SKIP_BUILD_RPATH FALSE
|
|
211
|
+
BUILD_WITH_INSTALL_RPATH FALSE
|
|
212
|
+
INSTALL_RPATH "$ORIGIN"
|
|
213
|
+
INSTALL_RPATH_USE_LINK_PATH TRUE
|
|
214
|
+
)
|
|
215
|
+
set_property(TARGET rayd PROPERTY CXX_STANDARD 17)
|
|
216
|
+
set_target_properties(rayd PROPERTIES PREFIX "")
|
|
217
|
+
|
rayd-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: rayd
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: RayD: minimalist differentiable ray tracing package wrapping Dr.Jit and OptiX.
|
|
5
|
+
Author: Xingyu Chen
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: drjit>=1.3.0
|
|
8
|
+
Provides-Extra: torch
|
|
9
|
+
Requires-Dist: torch; extra == "torch"
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# RayD
|
|
13
|
+
|
|
14
|
+
RayD is a minimalist differentiable ray tracing package built on top of Dr.Jit and OptiX.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install rayd
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
RayD is not a full renderer. It is a thin wrapper around Dr.Jit and OptiX for building your own renderers and simulators.
|
|
21
|
+
|
|
22
|
+
The goal is simple: expose differentiable ray-mesh intersection on the GPU without bringing in a full graphics framework.
|
|
23
|
+
|
|
24
|
+
## Why RayD?
|
|
25
|
+
|
|
26
|
+
RayD is for users who want OptiX acceleration and autodiff, but do not want a full renderer.
|
|
27
|
+
|
|
28
|
+
Why not `Mitsuba`? `Mitsuba` is excellent for graphics rendering, but often too high-level for RF, acoustics, sonar, or custom wave simulation. In those settings, direct access to ray-scene queries and geometry gradients is usually more useful than a full material-light-integrator stack.
|
|
29
|
+
|
|
30
|
+
RayD keeps only the geometric core:
|
|
31
|
+
|
|
32
|
+
- differentiable ray-mesh intersection
|
|
33
|
+
- scene-level GPU acceleration through OptiX
|
|
34
|
+
- edge acceleration structures for nearest-edge queries
|
|
35
|
+
- primary-edge sampling support for edge-based gradient terms
|
|
36
|
+
|
|
37
|
+
For intersection workloads, RayD targets Mitsuba-level performance and matching results with a much smaller API surface.
|
|
38
|
+
|
|
39
|
+
## What RayD Provides
|
|
40
|
+
|
|
41
|
+
- `Mesh`: triangle geometry, transforms, UVs, and edge topology
|
|
42
|
+
- `Scene`: a container of meshes plus OptiX acceleration
|
|
43
|
+
- `scene.intersect(ray)`: differentiable ray-mesh intersection
|
|
44
|
+
- `scene.nearest_edge(query)`: nearest-edge queries for points and rays
|
|
45
|
+
- edge acceleration data that is useful for edge sampling and edge diffraction methods
|
|
46
|
+
|
|
47
|
+
## PyTorch Wrapper
|
|
48
|
+
|
|
49
|
+
RayD also provides an optional `rayd.torch` module implemented at the Python package layer.
|
|
50
|
+
|
|
51
|
+
`rayd.torch` mirrors the core `rayd` API:
|
|
52
|
+
|
|
53
|
+
- `rayd.torch.Mesh`
|
|
54
|
+
- `rayd.torch.Scene`
|
|
55
|
+
- `rayd.torch.Camera`
|
|
56
|
+
- `rayd.torch.Ray` / `rayd.torch.RayDetached`
|
|
57
|
+
- the same intersection and nearest-edge result types
|
|
58
|
+
|
|
59
|
+
Key conventions:
|
|
60
|
+
|
|
61
|
+
- array inputs and outputs use CUDA `torch.Tensor`
|
|
62
|
+
- vectors use shape `(N, 3)` or `(N, 2)`; `(3,)` and `(2,)` are accepted as batch size `1`
|
|
63
|
+
- index tensors use shape `(F, 3)`
|
|
64
|
+
- images use shape `(H, W)`
|
|
65
|
+
- transforms use shape `(4, 4)`
|
|
66
|
+
- CPU tensors are rejected; `rayd.torch` does not do implicit device transfers
|
|
67
|
+
|
|
68
|
+
The original `rayd` Dr.Jit API remains unchanged and does not depend on PyTorch.
|
|
69
|
+
|
|
70
|
+
## Quick Examples
|
|
71
|
+
|
|
72
|
+
If you only want to see the package in action, start here:
|
|
73
|
+
|
|
74
|
+
- [`examples/basics/ray_mesh_intersection.py`](examples/basics/ray_mesh_intersection.py): custom rays against a mesh
|
|
75
|
+
- [`examples/basics/nearest_edge_query.py`](examples/basics/nearest_edge_query.py): nearest-edge queries
|
|
76
|
+
- [`examples/basics/camera_edge_sampling_gradient.py`](examples/basics/camera_edge_sampling_gradient.py): camera-driven edge-sampling gradients
|
|
77
|
+
- [`docs/slang_interop.md`](docs/slang_interop.md): Slang `cpp` target interop for host-side RayD scene queries
|
|
78
|
+
|
|
79
|
+
Build meshes, put them in a scene, launch rays, define a loss, and backpropagate through geometry.
|
|
80
|
+
|
|
81
|
+
## Minimal Differentiable Ray Tracing Example
|
|
82
|
+
|
|
83
|
+
The example below traces a single ray against one triangle and backpropagates the hit distance to the vertex positions.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import rayd as rd
|
|
87
|
+
import drjit as dr
|
|
88
|
+
import drjit.cuda as cuda
|
|
89
|
+
import drjit.cuda.ad as ad
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
mesh = rd.Mesh(
|
|
93
|
+
cuda.Array3f([0.0, 1.0, 0.0],
|
|
94
|
+
[0.0, 0.0, 1.0],
|
|
95
|
+
[0.0, 0.0, 0.0]),
|
|
96
|
+
cuda.Array3i([0], [1], [2]),
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
verts = ad.Array3f(
|
|
100
|
+
[0.0, 1.0, 0.0],
|
|
101
|
+
[0.0, 0.0, 1.0],
|
|
102
|
+
[0.0, 0.0, 0.0],
|
|
103
|
+
)
|
|
104
|
+
dr.enable_grad(verts)
|
|
105
|
+
|
|
106
|
+
mesh.vertex_positions = verts
|
|
107
|
+
|
|
108
|
+
scene = rd.Scene()
|
|
109
|
+
scene.add_mesh(mesh)
|
|
110
|
+
scene.configure()
|
|
111
|
+
|
|
112
|
+
ray = rd.Ray(
|
|
113
|
+
ad.Array3f([0.25], [0.25], [-1.0]),
|
|
114
|
+
ad.Array3f([0.0], [0.0], [1.0]),
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
its = scene.intersect(ray)
|
|
118
|
+
loss = dr.sum(its.t)
|
|
119
|
+
dr.backward(loss)
|
|
120
|
+
|
|
121
|
+
print("t =", its.t)
|
|
122
|
+
print("grad z =", dr.grad(verts)[2])
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
This is the core RayD workflow. Replace the single ray with your own batched rays, RF paths, acoustic paths, or edge-based objectives.
|
|
126
|
+
|
|
127
|
+
## Edge Acceleration Structure
|
|
128
|
+
|
|
129
|
+
RayD also provides a scene-level edge acceleration structure.
|
|
130
|
+
|
|
131
|
+
This is useful for:
|
|
132
|
+
|
|
133
|
+
- edge sampling
|
|
134
|
+
- nearest-edge queries
|
|
135
|
+
- visibility-boundary terms
|
|
136
|
+
- geometric edge diffraction models
|
|
137
|
+
|
|
138
|
+
In other words, RayD is not limited to triangle hits. It also gives you direct access to edge-level geometry queries, which are important in many non-graphics simulators.
|
|
139
|
+
|
|
140
|
+
## Compiling Locally
|
|
141
|
+
|
|
142
|
+
RayD is a Python package with a C++/CUDA extension.
|
|
143
|
+
|
|
144
|
+
You need Python `>=3.10`, CUDA Toolkit `>=11.0`, CMake, a C++17 compiler, `drjit>=1.3.0`, `nanobind==2.11.0`, and `scikit-build-core`.
|
|
145
|
+
|
|
146
|
+
On Windows, use Visual Studio 2022 with Desktop C++ tools. On Linux, use GCC or Clang with C++17 support.
|
|
147
|
+
|
|
148
|
+
### Recommended environment
|
|
149
|
+
|
|
150
|
+
```powershell
|
|
151
|
+
conda create -n myenv python=3.10 -y
|
|
152
|
+
conda activate myenv
|
|
153
|
+
python -m pip install -U pip setuptools wheel
|
|
154
|
+
python -m pip install cmake scikit-build-core nanobind==2.11.0
|
|
155
|
+
python -m pip install "drjit>=1.3.0"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Install
|
|
159
|
+
|
|
160
|
+
```powershell
|
|
161
|
+
conda activate myenv
|
|
162
|
+
python -m pip install .
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Dependencies
|
|
166
|
+
|
|
167
|
+
RayD depends on:
|
|
168
|
+
|
|
169
|
+
- Python `3.10+`
|
|
170
|
+
- Dr.Jit `1.3.0+`
|
|
171
|
+
- OptiX `8+`
|
|
172
|
+
|
|
173
|
+
RayD does not include:
|
|
174
|
+
|
|
175
|
+
- BSDFs
|
|
176
|
+
- emitters
|
|
177
|
+
- integrators
|
|
178
|
+
- scene loaders
|
|
179
|
+
- image I/O
|
|
180
|
+
- path tracing infrastructure
|
|
181
|
+
|
|
182
|
+
That is by design.
|
|
183
|
+
|
|
184
|
+
## Repository Layout
|
|
185
|
+
|
|
186
|
+
- [`include/rayd/`](include/rayd): public C++ headers
|
|
187
|
+
- [`src/`](src): C++ and CUDA implementation
|
|
188
|
+
- [`src/rayd.cpp`](src/rayd.cpp): Python bindings
|
|
189
|
+
- [`include/rayd/slang/interop.h`](include/rayd/slang/interop.h): C++ POD/handle bridge for Slang
|
|
190
|
+
- [`include/rayd/slang/rayd.slang`](include/rayd/slang/rayd.slang): Slang declarations for the C++ interop layer
|
|
191
|
+
- [`examples/`](examples): basic and renderer-side examples
|
|
192
|
+
- [`tests/test_geometry.py`](tests/test_geometry.py): geometry regression tests
|
|
193
|
+
- [`docs/api_reference.md`](docs/api_reference.md): Python API reference
|
|
194
|
+
- [`docs/slang_interop.md`](docs/slang_interop.md): Slang interop notes and examples
|
|
195
|
+
|
|
196
|
+
## Testing
|
|
197
|
+
|
|
198
|
+
```powershell
|
|
199
|
+
python -m unittest tests.test_geometry -v
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Optional PyTorch wrapper tests:
|
|
203
|
+
|
|
204
|
+
```powershell
|
|
205
|
+
python -m unittest tests.test_torch_geometry -v
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Credits
|
|
209
|
+
|
|
210
|
+
RayD is developed with reference to:
|
|
211
|
+
|
|
212
|
+
- [psdr-jit](https://github.com/andyyankai/psdr-jit)
|
|
213
|
+
- [redner](https://github.com/BachiLi/redner)
|
|
214
|
+
- [mitsuba3](https://github.com/mitsuba-renderer/mitsuba3)
|
|
215
|
+
|
|
216
|
+
## Citation
|
|
217
|
+
|
|
218
|
+
```bibtex
|
|
219
|
+
@inproceedings{chen2026rfdt,
|
|
220
|
+
title = {Physically Accurate Differentiable Inverse Rendering
|
|
221
|
+
for Radio Frequency Digital Twin},
|
|
222
|
+
author = {Chen, Xingyu and Zhang, Xinyu and Zheng, Kai and
|
|
223
|
+
Fang, Xinmin and Li, Tzu-Mao and Lu, Chris Xiaoxuan
|
|
224
|
+
and Li, Zhengxiong},
|
|
225
|
+
booktitle = {Proceedings of the 32nd Annual International Conference
|
|
226
|
+
on Mobile Computing and Networking (MobiCom)},
|
|
227
|
+
year = {2026},
|
|
228
|
+
doi = {10.1145/3795866.3796686},
|
|
229
|
+
publisher = {ACM},
|
|
230
|
+
address = {Austin, TX, USA},
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## License
|
|
235
|
+
|
|
236
|
+
MIT
|