├── .devcontainer ├── Dockerfile ├── README.md ├── devcontainer.json └── docker-compose.yml ├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── cmake ├── FindOptiX.cmake └── bin2c_wrapper.cmake ├── configs ├── image │ ├── base.json │ ├── frequency.json │ ├── hashgrid.json │ └── oneblob.json ├── nerf │ ├── base.json │ ├── base_0layer.json │ ├── base_14.json │ ├── base_1layer.json │ ├── base_2layer.json │ ├── base_3layer.json │ ├── big.json │ ├── densegrid.json │ ├── densegrid_1res.json │ ├── frequency.json │ ├── hashgrid.json │ ├── linear.json │ ├── none.json │ ├── small.json │ └── tensor.json ├── sdf │ ├── base.json │ ├── frequency.json │ ├── hashgrid.json │ ├── oneblob.json │ └── takikawa.json └── volume │ └── base.json ├── data ├── image │ ├── LICENSE.txt │ └── albert.exr ├── nerf │ └── fox │ │ ├── images │ │ ├── 0001.jpg │ │ ├── 0002.jpg │ │ ├── 0003.jpg │ │ ├── 0004.jpg │ │ ├── 0006.jpg │ │ ├── 0007.jpg │ │ ├── 0008.jpg │ │ ├── 0009.jpg │ │ ├── 0012.jpg │ │ ├── 0014.jpg │ │ ├── 0018.jpg │ │ ├── 0019.jpg │ │ ├── 0021.jpg │ │ ├── 0022.jpg │ │ ├── 0025.jpg │ │ ├── 0026.jpg │ │ ├── 0027.jpg │ │ ├── 0029.jpg │ │ ├── 0030.jpg │ │ ├── 0031.jpg │ │ ├── 0033.jpg │ │ ├── 0034.jpg │ │ ├── 0035.jpg │ │ ├── 0039.jpg │ │ ├── 0042.jpg │ │ ├── 0044.jpg │ │ ├── 0045.jpg │ │ ├── 0046.jpg │ │ ├── 0049.jpg │ │ ├── 0052.jpg │ │ ├── 0054.jpg │ │ ├── 0072.jpg │ │ ├── 0073.jpg │ │ ├── 0074.jpg │ │ ├── 0076.jpg │ │ ├── 0077.jpg │ │ ├── 0078.jpg │ │ ├── 0081.jpg │ │ ├── 0084.jpg │ │ ├── 0085.jpg │ │ ├── 0089.jpg │ │ ├── 0090.jpg │ │ ├── 0094.jpg │ │ ├── 0097.jpg │ │ ├── 0103.jpg │ │ ├── 0105.jpg │ │ ├── 0107.jpg │ │ ├── 0108.jpg │ │ ├── 0110.jpg │ │ └── 0115.jpg │ │ └── transforms.json └── sdf │ ├── armadillo.obj │ └── bunny.obj ├── dependencies ├── cuda-cmake-github-actions │ ├── LICENSE │ └── scripts │ │ └── actions │ │ ├── install_cuda_ubuntu.sh │ │ └── install_cuda_windows.ps1 ├── filesystem │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── filesystem │ │ ├── directory.h │ │ ├── fwd.h │ │ ├── path.h │ │ └── resolver.h │ └── path_demo.cpp ├── gl3w │ └── GL │ │ ├── gl3w.c │ │ ├── gl3w.h │ │ └── glcorearb.h ├── imguizmo │ ├── ImGuizmo.cpp │ └── ImGuizmo.h ├── nanovdb │ ├── LICENSE.txt │ ├── README.md │ └── nanovdb │ │ └── NanoVDB.h ├── pybind11_json │ ├── LICENSE │ └── pybind11_json.hpp ├── stb_image │ ├── stb_image.h │ └── stb_image_write.h ├── tinyexr │ ├── LICENSE.txt │ ├── Makefile │ ├── README.md │ ├── appveyor.yml │ ├── config-msvc.py │ ├── deps │ │ ├── ZFP │ │ │ ├── API │ │ │ ├── Config │ │ │ ├── FAQ │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── VERSIONS │ │ │ ├── array │ │ │ │ ├── cache.h │ │ │ │ ├── memory.h │ │ │ │ ├── zfparray.h │ │ │ │ ├── zfparray1.h │ │ │ │ ├── zfparray2.h │ │ │ │ ├── zfparray3.h │ │ │ │ ├── zfpcodec.h │ │ │ │ ├── zfpcodecd.h │ │ │ │ └── zfpcodecf.h │ │ │ ├── examples │ │ │ │ ├── Makefile │ │ │ │ ├── array2d.h │ │ │ │ ├── diffusion.cpp │ │ │ │ ├── fields.c │ │ │ │ ├── fields.h │ │ │ │ ├── pgm.c │ │ │ │ ├── simple.c │ │ │ │ ├── speed.c │ │ │ │ ├── testzfp.cpp │ │ │ │ └── zfp.c │ │ │ ├── inc │ │ │ │ ├── bitstream.h │ │ │ │ ├── macros.h │ │ │ │ ├── system.h │ │ │ │ ├── types.h │ │ │ │ └── zfp.h │ │ │ └── src │ │ │ │ ├── Makefile │ │ │ │ ├── bitstream.c │ │ │ │ ├── block1.h │ │ │ │ ├── block2.h │ │ │ │ ├── block3.h │ │ │ │ ├── decode1d.c │ │ │ │ ├── decode1f.c │ │ │ │ ├── decode2d.c │ │ │ │ ├── decode2f.c │ │ │ │ ├── decode3d.c │ │ │ │ ├── decode3f.c │ │ │ │ ├── encode1d.c │ │ │ │ ├── encode1f.c │ │ │ │ ├── encode2d.c │ │ │ │ ├── encode2f.c │ │ │ │ ├── encode3d.c │ │ │ │ ├── encode3f.c │ │ │ │ ├── inline │ │ │ │ ├── bitstream.c │ │ │ │ └── inline.h │ │ │ │ ├── template │ │ │ │ ├── codec.h │ │ │ │ ├── codec1.c │ │ │ │ ├── codec2.c │ │ │ │ ├── codec3.c │ │ │ │ ├── compress.c │ │ │ │ ├── decode.c │ │ │ │ ├── decode1.c │ │ │ │ ├── decode2.c │ │ │ │ ├── decode3.c │ │ │ │ ├── decompress.c │ │ │ │ ├── encode.c │ │ │ │ ├── encode1.c │ │ │ │ ├── encode2.c │ │ │ │ ├── encode3.c │ │ │ │ └── template.h │ │ │ │ ├── traitsd.h │ │ │ │ ├── traitsf.h │ │ │ │ └── zfp.c │ │ └── cpplint.py │ ├── experimental │ │ └── js │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── binding.cc │ │ │ ├── compile_to_js.sh │ │ │ ├── index.html │ │ │ ├── test.js │ │ │ └── tinyexr.js │ ├── jni │ │ ├── Android.mk │ │ ├── Application.mk │ │ ├── Makefile │ │ └── README.md │ ├── kuroga.py │ ├── premake4.lua │ ├── test_tinyexr.cc │ ├── tinyexr.cc │ ├── tinyexr.h │ └── vcbuild.bat └── tinyobjloader │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── appveyor.yml │ ├── azure-pipelines.yml │ ├── build.ninja │ ├── cmake_uninstall.cmake.in │ ├── deps │ └── cpplint.py │ ├── loader_example.cc │ ├── premake4.lua │ ├── python │ ├── LICENSE │ ├── MANIFEST.in │ ├── Makefile │ ├── README.md │ ├── bindings.cc │ ├── pyproject.toml │ ├── sample.py │ ├── setup.py │ └── tiny_obj_loader.cc │ ├── tiny_obj_loader.cc │ ├── tiny_obj_loader.h │ ├── tinyobjloader-config.cmake.in │ ├── tinyobjloader.pc.in │ └── vcsetup.bat ├── docs ├── assets │ ├── cloud_training.mp4 │ ├── gargoyle_loop_base.mp4 │ ├── gargoyle_loop_base_14.mp4 │ ├── gargoyle_loop_densegrid.mp4 │ ├── gargoyle_loop_densegrid_1res.mp4 │ ├── gargoyle_loop_frequency.mp4 │ ├── gargoyle_loop_none.mp4 │ ├── modsynth.mp4 │ ├── mueller2022instant.bib │ ├── mueller2022instant.mp4 │ ├── mueller2022instant.pdf │ ├── nerf_grid_lq.mp4 │ ├── nerfbox.jpg │ ├── nerfboxrobot.jpg │ ├── nrc_new_vs_old.mp4 │ ├── paper-thumbnail.png │ ├── robot.mp4 │ ├── sdf_grid_lq.mp4 │ ├── teaser.mp4 │ ├── teaser_small.jpg │ ├── tokyo_online_training_counter.mp4 │ └── twitter.jpg ├── assets_readme │ ├── albert.png │ ├── armadillo.png │ ├── cloud.png │ ├── fox-representative.png │ ├── fox.gif │ ├── fox.png │ ├── robot5.gif │ └── testbed.png ├── index.html └── nerf_dataset_tips.md ├── include └── neural-graphics-primitives │ ├── adam_optimizer.h │ ├── bounding_box.cuh │ ├── camera_models.cuh │ ├── camera_path.h │ ├── common.h │ ├── common_device.cuh │ ├── discrete_distribution.h │ ├── dlss.h │ ├── envmap.cuh │ ├── json_binding.h │ ├── marching_cubes.h │ ├── nerf.h │ ├── nerf │ ├── mask_3D.cuh │ ├── nerf_descriptor.cuh │ ├── nerf_props.cuh │ ├── nerf_render_proxy.cuh │ ├── nerf_renderer.cuh │ ├── nerf_utils.cuh │ ├── neural_radiance_field.cuh │ ├── render_data.cuh │ ├── render_data_workspace.cuh │ ├── render_modifiers.cuh │ ├── render_modifiers_descriptor.cuh │ └── render_request.cuh │ ├── nerf_kernels.cuh │ ├── nerf_loader.h │ ├── nerf_network.h │ ├── random_val.cuh │ ├── render_buffer.h │ ├── sdf.h │ ├── shared_queue.h │ ├── takikawa_encoding.cuh │ ├── testbed.h │ ├── thread_pool.h │ ├── tinyexr_wrapper.h │ ├── tinyobj_loader_wrapper.h │ ├── trainable_buffer.cuh │ ├── triangle.cuh │ ├── triangle_bvh.cuh │ └── triangle_octree.cuh ├── notebooks └── instant_ngp.ipynb ├── requirements.txt ├── scripts ├── colmap2nerf.py ├── common.py ├── convert_image.py ├── flip │ ├── __init__.py │ ├── main.py │ └── utils.py ├── nsvf2nerf.py ├── run.py └── scenes.py └── src ├── camera_path.cu ├── common_device.cu ├── dlss.cu ├── main.cu ├── marching_cubes.cu ├── nerf_data.cu ├── nerf_loader.cu ├── nerf_renderer.cu ├── nerf_trainer.cu ├── nerf_utils.cu ├── optix ├── pathescape.cu ├── pathescape.h ├── program.h ├── raystab.cu ├── raystab.h ├── raytrace.cu └── raytrace.h ├── python_api.cu ├── render_buffer.cu ├── testbed.cu ├── testbed_image.cu ├── testbed_nerf.cu ├── testbed_sdf.cu ├── testbed_volume.cu ├── thread_pool.cpp ├── tinyexr_wrapper.cu ├── tinyobj_loader_wrapper.cpp └── triangle_bvh.cu /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:10.2-devel-ubuntu18.04 2 | 3 | ENV COLMAP_VERSION=3.7 4 | ENV CMAKE_VERSION=3.21.0 5 | ENV PYTHON_VERSION=3.7.0 6 | ENV OPENCV_VERSION=4.5.5.62 7 | ENV CERES_SOLVER_VERSION=2.0.0 8 | 9 | RUN echo "Installing apt packages..." \ 10 | && export DEBIAN_FRONTEND=noninteractive \ 11 | && apt -y update --no-install-recommends \ 12 | && apt -y install --no-install-recommends \ 13 | git \ 14 | wget \ 15 | ffmpeg \ 16 | tk-dev \ 17 | libxi-dev \ 18 | libc6-dev \ 19 | libbz2-dev \ 20 | libffi-dev \ 21 | libomp-dev \ 22 | libssl-dev \ 23 | zlib1g-dev \ 24 | libcgal-dev \ 25 | libgdbm-dev \ 26 | libglew-dev \ 27 | python3-dev \ 28 | python3-pip \ 29 | qtbase5-dev \ 30 | checkinstall \ 31 | libglfw3-dev \ 32 | libeigen3-dev \ 33 | libgflags-dev \ 34 | libxrandr-dev \ 35 | libopenexr-dev \ 36 | libsqlite3-dev \ 37 | libxcursor-dev \ 38 | build-essential \ 39 | libcgal-qt5-dev \ 40 | libxinerama-dev \ 41 | libboost-all-dev \ 42 | libfreeimage-dev \ 43 | libncursesw5-dev \ 44 | libatlas-base-dev \ 45 | libqt5opengl5-dev \ 46 | libgoogle-glog-dev \ 47 | libsuitesparse-dev \ 48 | python3-setuptools \ 49 | libreadline-gplv2-dev \ 50 | && apt autoremove -y \ 51 | && apt clean -y \ 52 | && export DEBIAN_FRONTEND=dialog 53 | 54 | RUN echo "Installing Python ver. ${PYTHON_VERSION}..." \ 55 | && cd /opt \ 56 | && wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \ 57 | && tar xzf Python-${PYTHON_VERSION}.tgz \ 58 | && cd ./Python-${PYTHON_VERSION} \ 59 | && ./configure --enable-optimizations \ 60 | && make \ 61 | && checkinstall 62 | 63 | COPY ./requirements.txt ./ 64 | 65 | RUN echo "Installing pip packages..." \ 66 | && python3 -m pip install -U pip \ 67 | && pip3 --no-cache-dir install -r ./requirements.txt \ 68 | && pip3 --no-cache-dir install cmake==${CMAKE_VERSION} opencv-python==${OPENCV_VERSION} \ 69 | && rm ./requirements.txt 70 | 71 | RUN echo "Installing Ceres Solver ver. ${CERES_SOLVER_VERSION}..." \ 72 | && cd /opt \ 73 | && git clone https://github.com/ceres-solver/ceres-solver \ 74 | && cd ./ceres-solver \ 75 | && git checkout ${CERES_SOLVER_VERSION} \ 76 | && mkdir ./build \ 77 | && cd ./build \ 78 | && cmake ../ -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF \ 79 | && make -j \ 80 | && make install 81 | 82 | RUN echo "Installing COLMAP ver. ${COLMAP_VERSION}..." \ 83 | && cd /opt \ 84 | && git clone https://github.com/colmap/colmap \ 85 | && cd ./colmap \ 86 | && git checkout ${COLMAP_VERSION} \ 87 | && mkdir ./build \ 88 | && cd ./build \ 89 | && cmake ../ \ 90 | && make -j \ 91 | && make install \ 92 | && colmap -h 93 | -------------------------------------------------------------------------------- /.devcontainer/README.md: -------------------------------------------------------------------------------- 1 | ## VS Code Dev Container 2 | 3 | > Basic dev container for running Instant Neural Graphics Primitives without GUI. 4 | 5 | ### Requirements 6 | 7 | - #### **[Docker](https://www.docker.com/get-started)** 8 | 9 | - #### **[VS Code](https://code.visualstudio.com/Download)** 10 | 11 | - #### **[Docker VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker)** 12 | 13 | ### How to build 14 | 15 | ```sh 16 | cmake -DNGP_BUILD_WITH_GUI=off ./ -B ./build 17 | cmake --build build --config RelWithDebInfo -j 16 18 | ``` 19 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Instant NGP Dev Container", 3 | "dockerComposeFile": "docker-compose.yml", 4 | "service": "instant-ngp", 5 | "workspaceFolder": "/volume", 6 | "shutdownAction": "stopCompose", 7 | "extensions": [ 8 | "ms-vscode.cpptools", 9 | "ms-vscode.cmake-tools", 10 | "mutantdino.resourcemonitor", 11 | "ms-azuretools.vscode-docker", 12 | "nvidia.nsight-vscode-edition" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.devcontainer/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | 3 | services: 4 | instant-ngp: 5 | image: instantngp:latest 6 | build: 7 | context: .. 8 | dockerfile: ./.devcontainer/Dockerfile 9 | stdin_open: true 10 | tty: true 11 | environment: 12 | NVIDIA_DRIVER_CAPABILITIES: compute,utility,graphics 13 | DISPLAY: $DISPLAY 14 | volumes: 15 | - ../:/volume 16 | - /tmp/.X11-unix:/tmp/.X11-unix 17 | working_dir: /volume 18 | command: /bin/bash 19 | deploy: 20 | resources: 21 | reservations: 22 | devices: 23 | - driver: nvidia 24 | count: 1 25 | capabilities: [gpu] 26 | 27 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | indent_style = tab 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | /notebooks/* linguist-vendored 2 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build_linux: 13 | name: Build on linux systems 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | include: 18 | - os: ubuntu-22.04 19 | cuda: "11.7" 20 | arch: 86 21 | - os: ubuntu-18.04 22 | cuda: "10.2" 23 | arch: 75 24 | - os: ubuntu-18.04 25 | cuda: "10.2" 26 | arch: 70 27 | - os: ubuntu-18.04 28 | cuda: "10.2" 29 | arch: 61 30 | - os: ubuntu-18.04 31 | cuda: "10.2" 32 | arch: 53 33 | - os: ubuntu-18.04 34 | cuda: "10.2" 35 | arch: 37 36 | env: 37 | build_dir: "build" 38 | config: "Release" 39 | TCNN_CUDA_ARCHITECTURES: ${{ matrix.arch }} 40 | steps: 41 | - name: Install dependencies 42 | run: sudo apt-get update && sudo apt-get install build-essential python3-dev libglfw3-dev libglew-dev libxinerama-dev libxcursor-dev libxi-dev 43 | - uses: actions/checkout@v2 44 | with: 45 | submodules: recursive 46 | - name: Install CUDA 47 | env: 48 | cuda: ${{ matrix.cuda }} 49 | run: ./dependencies/cuda-cmake-github-actions/scripts/actions/install_cuda_ubuntu.sh 50 | shell: bash 51 | - name: CMake 52 | run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} 53 | - name: Build 54 | working-directory: ${{ env.build_dir }} 55 | run: cmake --build . --target all --verbose -j `nproc` 56 | 57 | 58 | build_windows: 59 | name: Build on Windows 60 | runs-on: ${{ matrix.os }} 61 | strategy: 62 | matrix: 63 | include: 64 | - os: windows-2019 65 | visual_studio: "Visual Studio 16 2019" 66 | cuda: "11.5.1" 67 | arch: 86 68 | - os: windows-2019 69 | visual_studio: "Visual Studio 16 2019" 70 | cuda: "11.5.1" 71 | arch: 75 72 | - os: windows-2019 73 | visual_studio: "Visual Studio 16 2019" 74 | cuda: "11.5.1" 75 | arch: 70 76 | - os: windows-2019 77 | visual_studio: "Visual Studio 16 2019" 78 | cuda: "11.5.1" 79 | arch: 61 80 | - os: windows-2019 81 | visual_studio: "Visual Studio 16 2019" 82 | cuda: "11.5.1" 83 | arch: 53 84 | - os: windows-2019 85 | visual_studio: "Visual Studio 16 2019" 86 | cuda: "11.5.1" 87 | arch: 37 88 | env: 89 | build_dir: "build" 90 | config: "Release" 91 | TCNN_CUDA_ARCHITECTURES: ${{ matrix.arch }} 92 | steps: 93 | - uses: actions/checkout@v2 94 | with: 95 | submodules: recursive 96 | - name: Install CUDA 97 | env: 98 | cuda: ${{ matrix.cuda }} 99 | visual_studio: ${{ matrix.visual_studio }} 100 | shell: powershell 101 | run: .\dependencies\cuda-cmake-github-actions\scripts\actions\install_cuda_windows.ps1 102 | - name: CMake 103 | run: cmake . -B ${{ env.build_dir }} -G "${{ matrix.visual_studio }}" -A x64 104 | - name: Build 105 | working-directory: ${{ env.build_dir }} 106 | run: cmake --build . --config ${{ env.config }} --target ALL_BUILD --verbose 107 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode 2 | /.vs 3 | /build* 4 | /figures 5 | /out 6 | /results 7 | /tmp 8 | /venv 9 | /video 10 | /*.json 11 | *.msgpack 12 | *.training 13 | __pycache__ 14 | .DS_Store 15 | imgui.ini 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies/pybind11"] 2 | path = dependencies/pybind11 3 | url = https://github.com/Tom94/pybind11 4 | [submodule "dependencies/eigen"] 5 | path = dependencies/eigen 6 | url = https://github.com/Tom94/eigen 7 | [submodule "dependencies/glfw"] 8 | path = dependencies/glfw 9 | url = https://github.com/Tom94/glfw 10 | [submodule "dependencies/args"] 11 | path = dependencies/args 12 | url = https://github.com/Taywee/args 13 | [submodule "dependencies/tinylogger"] 14 | path = dependencies/tinylogger 15 | url = https://github.com/Tom94/tinylogger 16 | [submodule "dependencies/tiny-cuda-nn"] 17 | path = dependencies/tiny-cuda-nn 18 | url = https://github.com/NVlabs/tiny-cuda-nn 19 | [submodule "dependencies/imgui"] 20 | path = dependencies/imgui 21 | url = https://github.com/ocornut/imgui.git 22 | [submodule "dependencies/dlss"] 23 | path = dependencies/dlss 24 | url = https://github.com/NVIDIA/DLSS 25 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/LICENSE.txt -------------------------------------------------------------------------------- /cmake/FindOptiX.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # * Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # * Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in the 11 | # documentation and/or other materials provided with the distribution. 12 | # * Neither the name of NVIDIA CORPORATION nor the names of its 13 | # contributors may be used to endorse or promote products derived 14 | # from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 17 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | 29 | # Locate the OptiX distribution. Search relative to the SDK first, then look in the system. 30 | 31 | # Our initial guess will be within the SDK. 32 | if(DEFINED ENV{OptiX_INSTALL_DIR}) 33 | set(OptiX_INSTALL_DIR $ENV{OptiX_INSTALL_DIR}) 34 | else() 35 | message(NOTICE "-- !!! Warning OptiX_INSTALL_DIR not set in environment. using default") 36 | if (MSVC) 37 | set(OptiX_INSTALL_DIR "C:\\ProgramData\\NVIDIA Corporation\\OptiX SDK 7.5.0") 38 | else() 39 | set(OptiX_INSTALL_DIR "/usr/local/NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64") 40 | endif() 41 | #set(OptiX_INSTALL_DIR "${CMAKE_SOURCE_DIR}/../" CACHE PATH "Path to OptiX installed location.") 42 | endif() 43 | message(NOTICE "-- OptiX_INSTALL_DIR value: ${OptiX_INSTALL_DIR}") 44 | 45 | # The distribution contains only 64 bit libraries. Error when we have been mis-configured. 46 | if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) 47 | if(WIN32) 48 | message(SEND_ERROR "Make sure when selecting the generator, you select one with Win64 or x64.") 49 | endif() 50 | message(FATAL_ERROR "OptiX only supports builds configured for 64 bits.") 51 | endif() 52 | 53 | # search path based on the bit-ness of the build. (i.e. 64: bin64, lib64; 32: 54 | # bin, lib). Note that on Mac, the OptiX library is a universal binary, so we 55 | # only need to look in lib and not lib64 for 64 bit builds. 56 | if(NOT APPLE) 57 | set(bit_dest "64") 58 | else() 59 | set(bit_dest "") 60 | endif() 61 | 62 | # Include 63 | find_path(OptiX_INCLUDE 64 | NAMES optix.h 65 | PATHS "${OptiX_INSTALL_DIR}/include" 66 | NO_DEFAULT_PATH 67 | ) 68 | find_path(OptiX_INCLUDE 69 | NAMES optix.h 70 | ) 71 | 72 | # Check to make sure we found what we were looking for 73 | function(OptiX_report_error error_message required component ) 74 | if(DEFINED OptiX_FIND_REQUIRED_${component} AND NOT OptiX_FIND_REQUIRED_${component}) 75 | set(required FALSE) 76 | endif() 77 | if(OptiX_FIND_REQUIRED AND required) 78 | message(FATAL_ERROR "${error_message} Please locate before proceeding.") 79 | else() 80 | if(NOT OptiX_FIND_QUIETLY) 81 | message(STATUS "${error_message}") 82 | endif(NOT OptiX_FIND_QUIETLY) 83 | endif() 84 | endfunction() 85 | 86 | if(NOT OptiX_INCLUDE) 87 | OptiX_report_error("OptiX headers (optix.h and friends) not found." TRUE headers ) 88 | set(OptiX_FOUND FALSE) 89 | else() 90 | set(OptiX_FOUND TRUE) 91 | endif() 92 | 93 | -------------------------------------------------------------------------------- /cmake/bin2c_wrapper.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # * Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # * Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in the 11 | # documentation and/or other materials provided with the distribution. 12 | # * Neither the name of NVIDIA CORPORATION nor the names of its 13 | # contributors may be used to endorse or promote products derived 14 | # from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 17 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | 29 | set(file_contents) 30 | foreach(obj ${OBJECTS}) 31 | get_filename_component(obj_fullname ${obj} NAME) 32 | get_filename_component(obj_ext ${obj} EXT) 33 | get_filename_component(obj_name ${obj} NAME_WE) 34 | get_filename_component(obj_dir ${obj} DIRECTORY) 35 | 36 | STRING(REPLACE "." "_" FILENAME_FIXED ${obj_fullname}) 37 | 38 | if(obj_ext MATCHES ".ptx" OR obj_ext MATCHES ".bin" OR obj_ext MATCHES ".mdl") 39 | set(args --name ${FILENAME_FIXED} ${obj}) 40 | execute_process(COMMAND "${BIN_TO_C_COMMAND}" ${args} 41 | WORKING_DIRECTORY ${obj_dir} 42 | RESULT_VARIABLE result 43 | OUTPUT_VARIABLE output 44 | ERROR_VARIABLE error_var 45 | ) 46 | set(file_contents "${file_contents} \n${output}") 47 | else() 48 | message(WARNING "Unhandled extension in bin2c wrapper: " ${obj_ext}) 49 | endif() 50 | endforeach() 51 | file(WRITE "${OUTPUT}" "${file_contents}") 52 | -------------------------------------------------------------------------------- /configs/image/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "loss": { 3 | "otype": "L2" 4 | }, 5 | "optimizer": { 6 | // "otype": "Ema", 7 | // "decay": 0.95, 8 | // "nested": { 9 | "otype": "ExponentialDecay", 10 | "decay_start": 20000, 11 | "decay_interval": 10000, 12 | "decay_base": 0.33, 13 | "nested": { 14 | "otype": "Adam", 15 | "learning_rate": 1e-2, 16 | "beta1": 0.9, 17 | "beta2": 0.99, 18 | "epsilon": 1e-15, 19 | "l2_reg": 1e-6 20 | } 21 | // } 22 | }, 23 | "encoding": { 24 | "otype": "HashGrid", 25 | "n_levels": 16, 26 | "n_features_per_level": 2, 27 | "log2_hashmap_size": 24, 28 | "base_resolution": 16 29 | }, 30 | "network": { 31 | "otype": "FullyFusedMLP", 32 | "activation": "ReLU", 33 | "output_activation": "None", 34 | "n_neurons": 64, 35 | "n_hidden_layers": 2 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /configs/image/frequency.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json", 3 | "encoding": { 4 | "otype": "Frequency", 5 | "n_frequencies": 16 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /configs/image/hashgrid.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json" 3 | } 4 | -------------------------------------------------------------------------------- /configs/image/oneblob.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json", 3 | "encoding": { 4 | "otype": "OneBlob", 5 | "n_bins": 32 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /configs/nerf/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "loss": { 3 | "otype": "Huber" 4 | }, 5 | "optimizer": { 6 | "otype": "Ema", 7 | "decay": 0.95, 8 | "nested": { 9 | "otype": "ExponentialDecay", 10 | "decay_start": 20000, 11 | "decay_interval": 10000, 12 | "decay_base": 0.33, 13 | "nested": { 14 | "otype": "Adam", 15 | "learning_rate": 1e-2, 16 | "beta1": 0.9, 17 | "beta2": 0.99, 18 | "epsilon": 1e-15, 19 | "l2_reg": 1e-6 20 | } 21 | } 22 | }, 23 | "encoding": { 24 | "otype": "HashGrid", 25 | "n_levels": 16, 26 | "n_features_per_level": 2, 27 | "log2_hashmap_size": 19, 28 | "base_resolution": 16 29 | }, 30 | "network": { 31 | "otype": "FullyFusedMLP", 32 | "activation": "ReLU", 33 | "output_activation": "None", 34 | "n_neurons": 64, 35 | "n_hidden_layers": 1 36 | }, 37 | "dir_encoding": { 38 | "otype": "Composite", 39 | "nested": [ 40 | { 41 | "n_dims_to_encode": 3, 42 | "otype": "SphericalHarmonics", 43 | "degree": 4 44 | }, 45 | { 46 | "otype": "Identity", 47 | "n_bins": 4, 48 | "degree": 4 49 | } 50 | ] 51 | }, 52 | "rgb_network": { 53 | "otype": "FullyFusedMLP", 54 | "activation": "ReLU", 55 | "output_activation": "None", 56 | "n_neurons": 64, 57 | "n_hidden_layers": 2 58 | }, 59 | "distortion_map": { 60 | "resolution": [32, 32], 61 | "optimizer": { 62 | "otype": "ExponentialDecay", 63 | "decay_start": 10000, 64 | "decay_interval": 5000, 65 | "decay_end": 25000, 66 | "decay_base": 0.33, 67 | "nested": { 68 | "otype": "Adam", 69 | "learning_rate": 1e-4, 70 | "beta1": 0.9, 71 | "beta2": 0.99, 72 | "epsilon": 1e-8 73 | } 74 | } 75 | }, 76 | "envmap": { 77 | "loss": { 78 | "otype": "RelativeL2" 79 | }, 80 | "optimizer": { 81 | "otype": "Ema", 82 | "decay": 0.99, 83 | "nested": { 84 | "otype": "ExponentialDecay", 85 | "decay_start": 10000, 86 | "decay_interval": 5000, 87 | "decay_base": 0.33, 88 | "nested": { 89 | "otype": "Adam", 90 | "learning_rate": 1e-2, 91 | "beta1": 0.9, 92 | "beta2": 0.99, 93 | "beta3": 0.9, 94 | "beta_shampoo": 0.0, 95 | "epsilon": 1e-10, 96 | "identity": 0.0001, 97 | "cg_on_momentum": false, 98 | "frobenius_normalization": true, 99 | "l2_reg": 1e-10 100 | } 101 | } 102 | } 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /configs/nerf/base_0layer.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "linear.json", 3 | "network": { 4 | "otype": "FullyFusedMLP", 5 | "activation": "ReLU", 6 | "output_activation": "None", 7 | "n_neurons": 64, 8 | "n_hidden_layers": 1 9 | }, 10 | "rgb_network": { 11 | "otype": "CutlassMLP", 12 | "n_neurons": 64, 13 | "n_hidden_layers": 0 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /configs/nerf/base_14.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "base.json", 3 | "encoding": { 4 | "log2_hashmap_size": 14 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /configs/nerf/base_1layer.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "linear.json", 3 | "network": { 4 | "otype": "FullyFusedMLP", 5 | "activation": "ReLU", 6 | "output_activation": "None", 7 | "n_neurons": 64, 8 | "n_hidden_layers": 1 9 | }, 10 | "rgb_network": { 11 | "otype": "FullyFusedMLP", 12 | "n_neurons": 64, 13 | "n_hidden_layers": 1 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /configs/nerf/base_2layer.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "linear.json", 3 | "network": { 4 | "otype": "FullyFusedMLP", 5 | "activation": "ReLU", 6 | "output_activation": "None", 7 | "n_neurons": 64, 8 | "n_hidden_layers": 1 9 | }, 10 | "rgb_network": { 11 | "otype": "FullyFusedMLP", 12 | "n_neurons": 64, 13 | "n_hidden_layers": 2 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /configs/nerf/base_3layer.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "linear.json", 3 | "network": { 4 | "otype": "FullyFusedMLP", 5 | "activation": "ReLU", 6 | "output_activation": "None", 7 | "n_neurons": 64, 8 | "n_hidden_layers": 1 9 | }, 10 | "rgb_network": { 11 | "otype": "FullyFusedMLP", 12 | "n_neurons": 64, 13 | "n_hidden_layers": 3 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /configs/nerf/big.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "base.json", 3 | "encoding": { 4 | "log2_hashmap_size": 21 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /configs/nerf/densegrid.json: -------------------------------------------------------------------------------- 1 | { // multiresolution dense grid - 8 levels, from res 16 to 173. chosen to have less than half of 33m params 2 | "parent" : "base.json", 3 | "encoding": { 4 | "otype": "DenseGrid", 5 | "n_levels": 8, 6 | "base_resolution": 16, 7 | "per_level_scale": 1.405 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /configs/nerf/densegrid_1res.json: -------------------------------------------------------------------------------- 1 | { // a dense grid setup so that every level is the same res, 128^3, with 2 8-wide levels. ie a single res grid with 16 wide features 2 | "parent" : "base.json", 3 | "encoding": { 4 | "otype": "TiledGrid", 5 | "n_levels": 2, 6 | "n_features_per_level": 8, // Use 8-wide levels rather than the default for higher perf. 7 | "base_resolution": 128, 8 | "per_level_scale": 1.0 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /configs/nerf/frequency.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json", 3 | "optimizer": { 4 | "nested": { 5 | "nested": { 6 | "learning_rate": 1e-3 7 | } 8 | } 9 | }, 10 | "encoding": { 11 | "otype": "Frequency", 12 | "n_frequencies": 16 13 | }, 14 | "dir_encoding": { 15 | "otype": "Frequency", 16 | "n_frequencies": 4 17 | }, 18 | "network": { 19 | // The Cutlass MLP is actually faster than the fully 20 | // fused MLP in this configuration, so use it instead. 21 | "otype": "CutlassMLP", 22 | "activation": "ReLU", 23 | "output_activation": "None", 24 | "n_neurons": 256, 25 | "n_hidden_layers": 7 26 | }, 27 | "rgb_network": { 28 | "otype": "CutlassMLP", 29 | "activation": "ReLU", 30 | "output_activation": "None", 31 | "n_neurons": 256, 32 | "n_hidden_layers": 1 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /configs/nerf/hashgrid.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json" 3 | } 4 | -------------------------------------------------------------------------------- /configs/nerf/linear.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "base.json", 3 | "network": { 4 | "otype": "CutlassMLP", 5 | "n_hidden_layers": 0 6 | }, 7 | "rgb_network": { 8 | "otype": "CutlassMLP", 9 | "n_hidden_layers": 0 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /configs/nerf/none.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "frequency.json", 3 | "encoding": { 4 | "otype": "Identity" 5 | }, 6 | "dir_encoding": { 7 | "otype": "Identity" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /configs/nerf/small.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent": "base.json", 3 | "optimizer": { 4 | "nested": { 5 | "decay_start": 10000, 6 | "decay_interval": 5000 7 | } 8 | }, 9 | "encoding": { 10 | "log2_hashmap_size": 15 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /configs/nerf/tensor.json: -------------------------------------------------------------------------------- 1 | { 2 | "loss": { 3 | "otype": "Huber" 4 | }, 5 | "optimizer": { 6 | "otype": "Ema", 7 | "decay": 0.95, 8 | "nested": { 9 | "otype": "ExponentialDecay", 10 | "decay_start": 20000, 11 | "decay_interval": 10000, 12 | "decay_base": 0.33, 13 | "nested": { 14 | "otype": "Adam", 15 | "learning_rate": 1e-2, 16 | "beta1": 0.9, 17 | "beta2": 0.99, 18 | "epsilon": 1e-15, 19 | "l2_reg": 1e-6 20 | } 21 | } 22 | }, 23 | "encoding": { 24 | "otype": "Composite", 25 | "nested": [ 26 | { 27 | "dims_to_encode_begin": 0, 28 | "n_dims_to_encode": 2, 29 | "otype": "HashGrid", 30 | "n_levels": 16, 31 | "n_features_per_level": 2, 32 | "log2_hashmap_size": 17, 33 | "base_resolution": 16 34 | }, 35 | { 36 | "dims_to_encode_begin": 1, 37 | "n_dims_to_encode": 2, 38 | "otype": "HashGrid", 39 | "n_levels": 16, 40 | "n_features_per_level": 2, 41 | "log2_hashmap_size": 17, 42 | "base_resolution": 16 43 | }, 44 | { 45 | "dims_to_encode_begin": 2, 46 | "n_dims_to_encode": 2, 47 | "otype": "HashGrid", 48 | "n_levels": 16, 49 | "n_features_per_level": 2, 50 | "log2_hashmap_size": 17, 51 | "base_resolution": 16 52 | } 53 | ] 54 | }, 55 | "network": { 56 | "otype": "FullyFusedMLP", 57 | "activation": "ReLU", 58 | "output_activation": "None", 59 | "n_neurons": 64, 60 | "n_hidden_layers": 1 61 | }, 62 | "dir_encoding": { 63 | "otype": "Composite", 64 | "nested": [ 65 | { 66 | "n_dims_to_encode": 3, 67 | "otype": "SphericalHarmonics", 68 | "degree": 4 69 | }, 70 | { 71 | "otype": "SphericalHarmonics", 72 | "n_bins": 4, 73 | "degree": 4 74 | } 75 | ] 76 | }, 77 | "rgb_network": { 78 | "otype": "FullyFusedMLP", 79 | "activation": "ReLU", 80 | "output_activation": "None", 81 | "n_neurons": 64, 82 | "n_hidden_layers": 2 83 | }, 84 | "distortion_map": { 85 | "resolution": [32, 32], 86 | "optimizer": { 87 | "otype": "ExponentialDecay", 88 | "decay_start": 10000, 89 | "decay_interval": 5000, 90 | "decay_end": 25000, 91 | "decay_base": 0.33, 92 | "nested": { 93 | "otype": "Adam", 94 | "learning_rate": 1e-4, 95 | "beta1": 0.9, 96 | "beta2": 0.99, 97 | "epsilon": 1e-8 98 | } 99 | } 100 | }, 101 | "envmap": { 102 | "loss": { 103 | "otype": "RelativeL2" 104 | }, 105 | "optimizer": { 106 | "otype": "Ema", 107 | "decay": 0.99, 108 | "nested": { 109 | "otype": "ExponentialDecay", 110 | "decay_start": 10000, 111 | "decay_interval": 5000, 112 | "decay_base": 0.33, 113 | "nested": { 114 | "otype": "Adam", 115 | "learning_rate": 1e-2, 116 | "beta1": 0.9, 117 | "beta2": 0.99, 118 | "beta3": 0.9, 119 | "beta_shampoo": 0.0, 120 | "epsilon": 1e-10, 121 | "identity": 0.0001, 122 | "cg_on_momentum": false, 123 | "frobenius_normalization": true, 124 | "l2_reg": 1e-10 125 | } 126 | } 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /configs/sdf/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "loss": { 3 | "otype": "MAPE" 4 | }, 5 | "optimizer": { 6 | "otype": "Ema", 7 | "decay": 0.95, 8 | "nested": { 9 | "otype": "ExponentialDecay", 10 | "decay_start": 10000, 11 | "decay_interval": 5000, 12 | "decay_base": 0.33, 13 | "nested": { 14 | "otype": "Adam", 15 | "learning_rate": 1e-4, 16 | "beta1": 0.9, 17 | "beta2": 0.99, 18 | "epsilon": 1e-15, 19 | "l2_reg": 1e-6 20 | } 21 | } 22 | }, 23 | "encoding": { 24 | "otype": "HashGrid", 25 | "n_levels": 16, 26 | "n_features_per_level": 2, 27 | "log2_hashmap_size": 19, 28 | "base_resolution": 16 29 | }, 30 | "network": { 31 | "otype": "FullyFusedMLP", 32 | "activation": "ReLU", 33 | "output_activation": "None", 34 | "n_neurons": 64, 35 | "n_hidden_layers": 2 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /configs/sdf/frequency.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json", 3 | "encoding": { 4 | "otype": "Frequency", 5 | "n_frequencies": 10 6 | }, 7 | "loss": { 8 | "otype": "RelativeL2" 9 | }, 10 | "optimizer": { 11 | "nested": { 12 | "nested": { 13 | "learning_rate": 3e-4 14 | } 15 | } 16 | }, 17 | "network": { 18 | "otype": "FullyFusedMLP", 19 | "activation": "ReLU", 20 | "output_activation": "None", 21 | "n_neurons": 128, 22 | "n_hidden_layers": 8 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /configs/sdf/hashgrid.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json" 3 | } 4 | -------------------------------------------------------------------------------- /configs/sdf/oneblob.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json", 3 | "encoding": { 4 | "otype": "OneBlob", 5 | "n_bins": 32 6 | }, 7 | "optimizer": { 8 | "nested": { 9 | "nested": { 10 | "learning_rate": 3e-4 11 | } 12 | } 13 | }, 14 | "network": { 15 | "otype": "FullyFusedMLP", 16 | "activation": "ReLU", 17 | "output_activation": "None", 18 | "n_neurons": 128, 19 | "n_hidden_layers": 6 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /configs/sdf/takikawa.json: -------------------------------------------------------------------------------- 1 | { 2 | "parent" : "base.json", 3 | "encoding": { 4 | "otype": "Takikawa", 5 | "n_levels": 10, 6 | "starting_level": 4, 7 | "sum_instead_of_concat": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /configs/volume/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "loss": { 3 | "otype": "L2" 4 | }, 5 | "optimizer": { 6 | "otype": "Ema", 7 | "decay": 0.95, 8 | "nested": { 9 | "otype": "ExponentialDecay", 10 | "decay_start": 10000, 11 | "decay_interval": 5000, 12 | "decay_base": 0.33, 13 | "nested": { 14 | "otype": "Adam", 15 | "learning_rate": 1e-4, 16 | "beta1": 0.9, 17 | "beta2": 0.99, 18 | "epsilon": 1e-15, 19 | "l2_reg": 1e-6 20 | } 21 | } 22 | }, 23 | "encoding": { 24 | "otype": "HashGrid", 25 | "n_levels": 16, 26 | "n_features_per_level": 2, 27 | "log2_hashmap_size": 19, 28 | "base_resolution": 16 29 | }, 30 | "network": { 31 | "otype": "FullyFusedMLP", 32 | "activation": "ReLU", 33 | "output_activation": "ReLU", 34 | "n_neurons": 64, 35 | "n_hidden_layers": 2 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /data/image/LICENSE.txt: -------------------------------------------------------------------------------- 1 | albert.exr - Public domain photograph (see https://commons.wikimedia.org/wiki/File:Albert_Einstein_Head.jpg) 2 | -------------------------------------------------------------------------------- /data/image/albert.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/image/albert.exr -------------------------------------------------------------------------------- /data/nerf/fox/images/0001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0001.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0002.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0002.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0003.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0003.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0004.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0004.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0006.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0006.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0007.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0007.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0008.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0009.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0009.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0012.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0012.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0014.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0014.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0018.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0018.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0019.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0019.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0021.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0022.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0022.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0025.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0025.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0026.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0026.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0027.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0027.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0029.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0029.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0030.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0030.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0031.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0031.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0033.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0033.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0034.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0034.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0035.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0035.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0039.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0039.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0042.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0042.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0044.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0044.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0045.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0045.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0046.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0046.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0049.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0049.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0052.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0052.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0054.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0054.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0072.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0072.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0073.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0073.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0074.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0074.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0076.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0076.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0077.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0077.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0078.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0078.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0081.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0081.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0084.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0084.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0085.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0085.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0089.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0089.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0090.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0090.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0094.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0094.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0097.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0097.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0103.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0103.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0105.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0105.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0107.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0107.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0108.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0108.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0110.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0110.jpg -------------------------------------------------------------------------------- /data/nerf/fox/images/0115.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/data/nerf/fox/images/0115.jpg -------------------------------------------------------------------------------- /dependencies/cuda-cmake-github-actions/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Peter Heywood 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /dependencies/filesystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(path) 3 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") 4 | # Enable C++11 mode on GCC / Clang 5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 6 | endif() 7 | add_executable(path_demo path_demo.cpp filesystem/path.h filesystem/resolver.h) 8 | -------------------------------------------------------------------------------- /dependencies/filesystem/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Wenzel Jakob , All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | You are under no obligation whatsoever to provide any bug fixes, patches, or 29 | upgrades to the features, functionality or performance of the source code 30 | ("Enhancements") to anyone; however, if you choose to make your Enhancements 31 | available either publicly, or directly to the author of this software, without 32 | imposing a separate written license agreement for such Enhancements, then you 33 | hereby grant the following license: a non-exclusive, royalty-free perpetual 34 | license to install, use, modify, prepare derivative works, incorporate into 35 | other computer software, distribute, and sublicense such enhancements or 36 | derivative works thereof, in binary and source code form. 37 | -------------------------------------------------------------------------------- /dependencies/filesystem/README.md: -------------------------------------------------------------------------------- 1 | #### filesystem/path.h: A simple class for manipulating paths on Linux/Windows/Mac OS 2 | 3 | This class is just a temporary workaround to avoid the heavy boost dependency 4 | until `boost::filesystem` is integrated into the standard template library at 5 | some point in the future. 6 | -------------------------------------------------------------------------------- /dependencies/filesystem/filesystem/fwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | fwd.h -- Forward declarations for path.h and resolver.h 3 | 4 | Copyright (c) 2015 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #if !defined(NAMESPACE_BEGIN) 13 | #define NAMESPACE_BEGIN(name) namespace name { 14 | #endif 15 | #if !defined(NAMESPACE_END) 16 | #define NAMESPACE_END(name) } 17 | #endif 18 | 19 | NAMESPACE_BEGIN(filesystem) 20 | 21 | class path; 22 | class resolver; 23 | 24 | NAMESPACE_END(filesystem) 25 | -------------------------------------------------------------------------------- /dependencies/filesystem/filesystem/resolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | resolver.h -- A simple class for cross-platform path resolution 3 | 4 | Copyright (c) 2015 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "path.h" 13 | 14 | NAMESPACE_BEGIN(filesystem) 15 | 16 | /** 17 | * \brief Simple class for resolving paths on Linux/Windows/Mac OS 18 | * 19 | * This convenience class looks for a file or directory given its name 20 | * and a set of search paths. The implementation walks through the 21 | * search paths in order and stops once the file is found. 22 | */ 23 | class resolver { 24 | public: 25 | typedef std::vector::iterator iterator; 26 | typedef std::vector::const_iterator const_iterator; 27 | 28 | resolver() { 29 | m_paths.push_back(path::getcwd()); 30 | } 31 | 32 | size_t size() const { return m_paths.size(); } 33 | 34 | iterator begin() { return m_paths.begin(); } 35 | iterator end() { return m_paths.end(); } 36 | 37 | const_iterator begin() const { return m_paths.begin(); } 38 | const_iterator end() const { return m_paths.end(); } 39 | 40 | void erase(iterator it) { m_paths.erase(it); } 41 | 42 | void prepend(const path &path) { m_paths.insert(m_paths.begin(), path); } 43 | void append(const path &path) { m_paths.push_back(path); } 44 | const path &operator[](size_t index) const { return m_paths[index]; } 45 | path &operator[](size_t index) { return m_paths[index]; } 46 | 47 | path resolve(const path &value) const { 48 | for (const_iterator it = m_paths.begin(); it != m_paths.end(); ++it) { 49 | path combined = *it / value; 50 | if (combined.exists()) 51 | return combined; 52 | } 53 | return value; 54 | } 55 | 56 | friend std::ostream &operator<<(std::ostream &os, const resolver &r) { 57 | os << "resolver[" << std::endl; 58 | for (size_t i = 0; i < r.m_paths.size(); ++i) { 59 | os << " \"" << r.m_paths[i] << "\""; 60 | if (i + 1 < r.m_paths.size()) 61 | os << ","; 62 | os << std::endl; 63 | } 64 | os << "]"; 65 | return os; 66 | } 67 | 68 | private: 69 | std::vector m_paths; 70 | }; 71 | 72 | NAMESPACE_END(filesystem) 73 | -------------------------------------------------------------------------------- /dependencies/filesystem/path_demo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "filesystem/path.h" 3 | #include "filesystem/resolver.h" 4 | 5 | using namespace std; 6 | using namespace filesystem; 7 | 8 | int main(int argc, char **argv) { 9 | #if !defined(WIN32) 10 | path path1("/dir 1/dir 2/"); 11 | #else 12 | path path1("C:\\dir 1\\dir 2\\"); 13 | #endif 14 | path path2("dir 3"); 15 | 16 | cout << path1.exists() << endl; 17 | cout << path1 << endl; 18 | cout << (path1/path2) << endl; 19 | cout << (path1/path2).parent_path() << endl; 20 | cout << (path1/path2).parent_path().parent_path() << endl; 21 | cout << (path1/path2).parent_path().parent_path().parent_path() << endl; 22 | cout << (path1/path2).parent_path().parent_path().parent_path().parent_path() << endl; 23 | cout << path().parent_path() << endl; 24 | cout << "some/path.ext:operator==() = " << (path("some/path.ext") == path("some/path.ext")) << endl; 25 | cout << "some/path.ext:operator==() (unequal) = " << (path("some/path.ext") == path("another/path.ext")) << endl; 26 | 27 | cout << "nonexistant:exists = " << path("nonexistant").exists() << endl; 28 | cout << "nonexistant:is_file = " << path("nonexistant").is_file() << endl; 29 | cout << "nonexistant:is_directory = " << path("nonexistant").is_directory() << endl; 30 | cout << "nonexistant:filename = " << path("nonexistant").filename() << endl; 31 | cout << "nonexistant:extension = " << path("nonexistant").extension() << endl; 32 | cout << "filesystem/path.h:exists = " << path("filesystem/path.h").exists() << endl; 33 | cout << "filesystem/path.h:is_file = " << path("filesystem/path.h").is_file() << endl; 34 | cout << "filesystem/path.h:is_directory = " << path("filesystem/path.h").is_directory() << endl; 35 | cout << "filesystem/path.h:filename = " << path("filesystem/path.h").filename() << endl; 36 | cout << "filesystem/path.h:extension = " << path("filesystem/path.h").extension() << endl; 37 | cout << "filesystem/path.h:make_absolute = " << path("filesystem/path.h").make_absolute() << endl; 38 | cout << "../filesystem:exists = " << path("../filesystem").exists() << endl; 39 | cout << "../filesystem:is_file = " << path("../filesystem").is_file() << endl; 40 | cout << "../filesystem:is_directory = " << path("../filesystem").is_directory() << endl; 41 | cout << "../filesystem:extension = " << path("../filesystem").extension() << endl; 42 | cout << "../filesystem:filename = " << path("../filesystem").filename() << endl; 43 | cout << "../filesystem:make_absolute = " << path("../filesystem").make_absolute() << endl; 44 | 45 | cout << "resolve(filesystem/path.h) = " << resolver().resolve("filesystem/path.h") << endl; 46 | cout << "resolve(nonexistant) = " << resolver().resolve("nonexistant") << endl; 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /dependencies/nanovdb/README.md: -------------------------------------------------------------------------------- 1 | This project makes use of NanoVDB, which is part of the OpenVDB project. 2 | 3 | OpenVDB is released under the Mozilla Public License Version 2.0, which is a free, open source software license developed and maintained by the Mozilla Foundation. 4 | 5 | The full project can be found at https://github.com/AcademySoftwareFoundation/openvdb/tree/feature/nanovdb 6 | 7 | The only source file that is used (and included here along with LICENSE.txt) is https://github.com/AcademySoftwareFoundation/openvdb/blob/feature/nanovdb/nanovdb/nanovdb/nanovdb/NanoVDB.h 8 | 9 | 10 | -------------------------------------------------------------------------------- /dependencies/pybind11_json/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /dependencies/tinyexr/LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 - 2019, Syoyo Fujita and many contributors. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Syoyo Fujita nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // TinyEXR contains some OpenEXR code, which is licensed under ------------ 29 | 30 | /////////////////////////////////////////////////////////////////////////// 31 | // 32 | // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas 33 | // Digital Ltd. LLC 34 | // 35 | // All rights reserved. 36 | // 37 | // Redistribution and use in source and binary forms, with or without 38 | // modification, are permitted provided that the following conditions are 39 | // met: 40 | // * Redistributions of source code must retain the above copyright 41 | // notice, this list of conditions and the following disclaimer. 42 | // * Redistributions in binary form must reproduce the above 43 | // copyright notice, this list of conditions and the following disclaimer 44 | // in the documentation and/or other materials provided with the 45 | // distribution. 46 | // * Neither the name of Industrial Light & Magic nor the names of 47 | // its contributors may be used to endorse or promote products derived 48 | // from this software without specific prior written permission. 49 | // 50 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 51 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 52 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 53 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 54 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 55 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 56 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 58 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 59 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 60 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 | // 62 | /////////////////////////////////////////////////////////////////////////// 63 | 64 | // End of OpenEXR license ------------------------------------------------- 65 | -------------------------------------------------------------------------------- /dependencies/tinyexr/Makefile: -------------------------------------------------------------------------------- 1 | #CXX ?= clang++ 2 | #CXXFLAGS ?= -fsanitize=address -Werror -Wall -Wextra -g -O0 -DTINYEXR_USE_MINIZ=0 -DTINYEXR_USE_PIZ=0 3 | #LDFLAGS ?= -lz 4 | 5 | # ZFP 6 | #CXXFLAGS += -DTINYEXR_USE_ZFP=1 -I./deps/ZFP/inc 7 | #LDFLAGS += -L./deps/ZFP/lib -lzfp 8 | 9 | all: 10 | $(CXX) $(CXXFLAGS) -o test_tinyexr test_tinyexr.cc $(LDFLAGS) 11 | 12 | test: 13 | ./test_tinyexr asakusa.exr 14 | 15 | .PHONY: test 16 | -------------------------------------------------------------------------------- /dependencies/tinyexr/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.9.{build} 2 | 3 | platform: x64 4 | configuration: Release 5 | 6 | before_build: 7 | - echo running cmake... 8 | - cd test 9 | - cmake -G "Visual Studio 12 Win64" -Bbuild -H. 10 | 11 | build: 12 | parallel: true 13 | project: C:\projects\tinyexr\test\build\tinyexr.sln 14 | -------------------------------------------------------------------------------- /dependencies/tinyexr/config-msvc.py: -------------------------------------------------------------------------------- 1 | exe = "test_tinyexr.exe" 2 | 3 | # "gnu" or "msvc" are provided as predefined toolchain 4 | toolchain = "msvc" 5 | 6 | # optional 7 | link_pool_depth = 1 8 | 9 | # optional 10 | builddir = { 11 | "gnu" : "build" 12 | , "msvc" : "build" 13 | , "clang" : "build" 14 | } 15 | 16 | # required 17 | includes = { 18 | "gnu" : [ "-I." ] 19 | , "msvc" : [ "/I." ] 20 | , "clang" : [ "-I." ] 21 | } 22 | 23 | # required 24 | defines = { 25 | "gnu" : [ "-DEXAMPLE=1" ] 26 | , "msvc" : [ "/DEXAMPLE=1" ] 27 | , "clang" : [ "-DEXAMPLE=1" ] 28 | } 29 | 30 | # required 31 | cflags = { 32 | "gnu" : [ "-O2", "-g" ] 33 | , "msvc" : [ "/O2" ] 34 | , "clang" : [ "-O2", "-g" ] 35 | } 36 | 37 | # required 38 | cxxflags = { 39 | "gnu" : [ "-O2", "-g" ] 40 | , "msvc" : [ "/O2", "/W4" ] 41 | , "clang" : [ "-O2", "-g", "-fsanitize=address" ] 42 | } 43 | 44 | # required 45 | ldflags = { 46 | "gnu" : [ ] 47 | , "msvc" : [ ] 48 | , "clang" : [ "-fsanitize=address" ] 49 | } 50 | 51 | # optionsl 52 | cxx_files = [ "test_tinyexr.cc" ] 53 | c_files = [ ] 54 | 55 | # You can register your own toolchain through register_toolchain function 56 | def register_toolchain(ninja): 57 | pass 58 | 59 | #ninja.rule('clangcxx', description='CXX $out', 60 | # command='$clangcxx -MMD -MF $out.d $clangdefines $clangincludes $clangcxxflags -c $in -o $out', 61 | # depfile='$out.d', deps='gcc') 62 | #ninja.rule('clangcc', description='CC $out', 63 | # command='$clangcc -MMD -MF $out.d $clangdefines $clangincludes $clangcflags -c $in -o $out', 64 | # depfile='$out.d', deps='gcc') 65 | #ninja.rule('clanglink', description='LINK $out', pool='link_pool', 66 | # command='$clangld $clangldflags -o $out $in $libs') 67 | #ninja.rule('clangar', description='AR $out', pool='link_pool', 68 | # command='$clangar rsc $out $in') 69 | #ninja.rule('clangstamp', description='STAMP $out', command='touch $out') 70 | #ninja.newline() 71 | 72 | #ninja.variable('clangcxx', 'clang++') 73 | #ninja.variable('clangcc', 'clang') 74 | #ninja.variable('clangld', 'clang++') 75 | #ninja.variable('clangar', 'ar') 76 | #ninja.newline() 77 | 78 | 79 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/Config: -------------------------------------------------------------------------------- 1 | # compiler settings ----------------------------------------------------------- 2 | 3 | # GNU compiler 4 | CC = gcc 5 | CXX = g++ 6 | FLAGS = -O3 -fPIC -Wall -I../inc $(DEFS) 7 | CFLAGS = $(FLAGS) -std=c89 -Wno-unused-function 8 | #CFLAGS = $(FLAGS) -std=c99 9 | CXXFLAGS = $(FLAGS) -std=c++98 10 | 11 | # IBM compiler 12 | # CC = xlc 13 | # CXX = xlc++ 14 | # CFLAGS = -O2 -qmaxmem=-1 -qpic=large -I../inc $(DEFS) 15 | # CXXFLAGS= $(CFLAGS) 16 | 17 | # optional compiler macros ---------------------------------------------------- 18 | 19 | # use smaller bit stream word type for finer rate granularity 20 | # DEFS += -DBIT_STREAM_WORD_TYPE=uint8 21 | # DEFS += -DBIT_STREAM_WORD_TYPE=uint16 22 | # DEFS += -DBIT_STREAM_WORD_TYPE=uint32 23 | 24 | # enable strided access for progressive zfp streams 25 | # DEFS += -DBIT_STREAM_STRIDED 26 | 27 | # run regression test with medium sized arrays 28 | # DEFS += -DTESTZFP_MEDIUM_ARRAYS 29 | 30 | # run regression test with large arrays 31 | # DEFS += -DTESTZFP_LARGE_ARRAYS 32 | 33 | # run diffusion without compression 34 | # DEFS += -DWITHOUT_COMPRESSION 35 | 36 | # use aligned memory allocation 37 | # DEFS += -DALIGNED_ALLOC 38 | 39 | # use two-way skew-associative cache 40 | # DEFS += -DCACHE_TWOWAY 41 | 42 | # use faster but more collision prone hash function 43 | # DEFS += -DCACHE_FAST_HASH 44 | 45 | # count cache misses 46 | # DEFS += -DCACHE_PROFILE 47 | 48 | # for recent versions of MSVC 49 | # DEFS += -DHAVE_C99_MATH 50 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2016, Lawrence Livermore National Security, LLC. 2 | Produced at the Lawrence Livermore National Laboratory. 3 | Written by Peter Lindstrom. 4 | LLNL-CODE-663824. 5 | All rights reserved. 6 | 7 | This file is part of the zfp library. 8 | For details, see http://computation.llnl.gov/casc/zfp/. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | 1. Redistributions of source code must retain the above copyright notice, 14 | this list of conditions and the disclaimer below. 15 | 16 | 2. Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the disclaimer (as noted below) in the 18 | documentation and/or other materials provided with the distribution. 19 | 20 | 3. Neither the name of the LLNS/LLNL nor the names of its contributors may 21 | be used to endorse or promote products derived from this software without 22 | specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, 28 | LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 29 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 32 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | 36 | 37 | Additional BSD Notice 38 | 39 | 1. This notice is required to be provided under our contract with the U.S. 40 | Department of Energy (DOE). This work was produced at Lawrence Livermore 41 | National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE. 42 | 43 | 2. Neither the United States Government nor Lawrence Livermore National 44 | Security, LLC nor any of their employees, makes any warranty, express or 45 | implied, or assumes any liability or responsibility for the accuracy, 46 | completeness, or usefulness of any information, apparatus, product, or 47 | process disclosed, or represents that its use would not infringe 48 | privately-owned rights. 49 | 50 | 3. Also, reference herein to any specific commercial products, process, or 51 | services by trade name, trademark, manufacturer or otherwise does not 52 | necessarily constitute or imply its endorsement, recommendation, or 53 | favoring by the United States Government or Lawrence Livermore National 54 | Security, LLC. The views and opinions of authors expressed herein do not 55 | necessarily state or reflect those of the United States Government or 56 | Lawrence Livermore National Security, LLC, and shall not be used for 57 | advertising or product endorsement purposes. 58 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/Makefile: -------------------------------------------------------------------------------- 1 | MAKEFLAGS += --no-print-directory 2 | 3 | all: 4 | @cd src; $(MAKE) clean static 5 | @cd examples; $(MAKE) clean all 6 | 7 | shared: 8 | @cd src; $(MAKE) shared 9 | 10 | test: 11 | @cd examples; $(MAKE) test 12 | 13 | clean: 14 | @cd src; $(MAKE) clean 15 | @cd examples; $(MAKE) clean 16 | 17 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/array/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_H 2 | #define MEMORY_H 3 | 4 | #include 5 | #include "types.h" 6 | 7 | inline void* 8 | allocate(size_t size, size_t alignment = 0) 9 | { 10 | #if defined(__USE_XOPEN2K) && defined(ALIGNED_ALLOC) 11 | void* ptr; 12 | if (alignment > 1) 13 | posix_memalign(&ptr, alignment, size); 14 | else 15 | ptr = malloc(size); 16 | return ptr; 17 | #else 18 | return new uchar[size]; 19 | #endif 20 | } 21 | 22 | template 23 | inline void 24 | deallocate(T* ptr) 25 | { 26 | #if defined(__USE_XOPEN2K) && defined(ALIGNED_ALLOC) 27 | if (ptr) 28 | free(ptr); 29 | #else 30 | delete[] ptr; 31 | #endif 32 | } 33 | 34 | template 35 | inline void 36 | reallocate(T*& ptr, size_t size, size_t alignment = 0) 37 | { 38 | deallocate(ptr); 39 | ptr = static_cast(allocate(size, alignment)); 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/array/zfparray.h: -------------------------------------------------------------------------------- 1 | #ifndef ZFP_ARRAY_H 2 | #define ZFP_ARRAY_H 3 | 4 | #include 5 | #include 6 | #include "zfp.h" 7 | #include "memory.h" 8 | 9 | namespace zfp { 10 | 11 | // base class for compressed array of scalars 12 | class array { 13 | protected: 14 | array(uint dims, zfp_type type) : 15 | dims(dims), type(type), 16 | nx(0), ny(0), nz(0), 17 | bx(0), by(0), bz(0), 18 | blocks(0), blkvals(1u << (2 * dims)), blkbits(0), blksize(0), 19 | bytes(0), data(0), 20 | stream(zfp_stream_open(0)), 21 | shape(0) 22 | {} 23 | 24 | ~array() 25 | { 26 | free(); 27 | zfp_stream_close(stream); 28 | } 29 | 30 | public: 31 | // rate in bits per value 32 | double rate() const { return double(blkbits) / blkvals; } 33 | 34 | // set compression rate in bits per value 35 | double set_rate(double rate) 36 | { 37 | rate = zfp_stream_set_rate(stream, rate, type, dims, 1); 38 | blkbits = stream->maxbits; 39 | blksize = blkbits / CHAR_BIT; 40 | alloc(); 41 | return rate; 42 | } 43 | 44 | // empty cache without compressing modified cached blocks 45 | virtual void clear_cache() const = 0; 46 | 47 | // flush cache by compressing all modified cached blocks 48 | virtual void flush_cache() const = 0; 49 | 50 | // number of bytes of compressed data 51 | size_t compressed_size() const { return bytes; } 52 | 53 | // pointer to compressed data for read or write access 54 | uchar* compressed_data() const 55 | { 56 | // first write back any modified cached data 57 | flush_cache(); 58 | return data; 59 | } 60 | 61 | protected: 62 | // allocate memory for compressed data 63 | void alloc(bool clear = true) 64 | { 65 | bytes = blocks * blksize; 66 | reallocate(data, bytes, 0x100u); 67 | if (clear) 68 | std::fill(data, data + bytes, 0); 69 | stream_close(stream->stream); 70 | zfp_stream_set_bit_stream(stream, stream_open(data, bytes)); 71 | clear_cache(); 72 | } 73 | 74 | // free memory associated with compressed data 75 | void free() 76 | { 77 | nx = ny = nz = 0; 78 | bx = by = bz = 0; 79 | blocks = 0; 80 | stream_close(stream->stream); 81 | zfp_stream_set_bit_stream(stream, 0); 82 | bytes = 0; 83 | deallocate(data); 84 | data = 0; 85 | deallocate(shape); 86 | shape = 0; 87 | } 88 | 89 | uint dims; // array dimensionality (1, 2, or 3) 90 | zfp_type type; // scalar type 91 | uint nx, ny, nz; // array dimensions 92 | uint bx, by, bz; // array dimensions in number of blocks 93 | uint blocks; // number of blocks 94 | uint blkvals; // number of values per block 95 | size_t blkbits; // number of bits per compressed block 96 | size_t blksize; // byte size of single compressed block 97 | size_t bytes; // total bytes of compressed data 98 | mutable uchar* data; // pointer to compressed data 99 | zfp_stream* stream; // compressed stream 100 | uchar* shape; // precomputed block dimensions (or null if uniform) 101 | }; 102 | 103 | } 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/array/zfpcodec.h: -------------------------------------------------------------------------------- 1 | #ifndef ZFP_CODEC_H 2 | #define ZFP_CODEC_H 3 | 4 | #include "zfp.h" 5 | 6 | namespace zfp { 7 | 8 | // C++ wrappers around libzfp C functions 9 | template 10 | struct codec {}; 11 | 12 | #include "zfpcodecf.h" 13 | #include "zfpcodecd.h" 14 | 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/examples/Makefile: -------------------------------------------------------------------------------- 1 | include ../Config 2 | 3 | TARGETS = diffusion-raw diffusion-zfp pgm simple speed testzfp zfp 4 | 5 | all: $(TARGETS) 6 | 7 | diffusion-raw: diffusion.cpp ../lib/libzfp.a 8 | $(CXX) $(CXXFLAGS) -DWITHOUT_COMPRESSION -I../array diffusion.cpp -L../lib -lzfp -o diffusion-raw 9 | 10 | diffusion-zfp: diffusion.cpp ../lib/libzfp.a 11 | $(CXX) $(CXXFLAGS) -I../array diffusion.cpp -L../lib -lzfp -o diffusion-zfp 12 | 13 | pgm: pgm.c ../lib/libzfp.a 14 | $(CC) $(CFLAGS) pgm.c -L../lib -lzfp -lm -o pgm 15 | 16 | simple: simple.c ../lib/libzfp.a 17 | $(CC) $(CFLAGS) simple.c -L../lib -lzfp -lm -o simple 18 | 19 | speed: speed.c ../lib/libzfp.a 20 | $(CC) $(CFLAGS) speed.c -L../lib -lzfp -lm -o speed 21 | 22 | testzfp: testzfp.cpp fields.o ../lib/libzfp.a 23 | $(CXX) $(CXXFLAGS) -I../array testzfp.cpp fields.o -L../lib -lzfp -o testzfp 24 | 25 | fields.o: fields.c 26 | $(CC) $(CFLAGS) -c fields.c 27 | 28 | zfp: zfp.c ../lib/libzfp.a 29 | $(CC) $(CFLAGS) zfp.c -L../lib -lzfp -lm -o zfp 30 | 31 | test: testzfp 32 | ./testzfp 33 | 34 | clean: 35 | rm -f $(TARGETS) fields.o 36 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/examples/array2d.h: -------------------------------------------------------------------------------- 1 | #ifndef ARRAY2D_H 2 | #define ARRAY2D_H 3 | 4 | #include 5 | #include 6 | 7 | typedef unsigned int uint; 8 | 9 | // uncompressed 2D double-precision array (for comparison) 10 | class array2d { 11 | public: 12 | array2d(uint nx, uint ny, uint precision) : nx(nx), ny(ny), data(nx * ny, 0.0) {} 13 | size_t size() const { return data.size(); } 14 | double rate() const { return CHAR_BIT * sizeof(double); } 15 | double& operator()(uint x, uint y) { return data[x + nx * y]; } 16 | const double& operator()(uint x, uint y) const { return data[x + nx * y]; } 17 | double& operator[](uint i) { return data[i]; } 18 | const double& operator[](uint i) const { return data[i]; } 19 | protected: 20 | uint nx; 21 | uint ny; 22 | std::vector data; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/examples/diffusion.cpp: -------------------------------------------------------------------------------- 1 | // forward Euler finite difference solution to the heat equation on a 2D grid 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef WITHOUT_COMPRESSION 11 | #include "array2d.h" 12 | #else 13 | #include "zfparray2.h" 14 | using namespace zfp; 15 | #endif 16 | 17 | int main(int argc, char* argv[]) 18 | { 19 | int nx = 0; 20 | int ny = 0; 21 | int nt = 0; 22 | double rate = 64; 23 | 24 | // parse arguments 25 | switch (argc) { 26 | case 5: 27 | if (sscanf(argv[4], "%d", &nt) != 1) 28 | goto usage; 29 | // FALLTHROUGH 30 | case 4: 31 | if (sscanf(argv[2], "%d", &nx) != 1 || 32 | sscanf(argv[3], "%d", &ny) != 1) 33 | goto usage; 34 | // FALLTHROUGH 35 | case 2: 36 | if (sscanf(argv[1], "%lf", &rate) != 1) 37 | goto usage; 38 | // FALLTHROUGH 39 | case 1: 40 | break; 41 | default: 42 | usage: 43 | std::cerr << "Usage: diffusion [rate] [nx] [ny] [nt]" << std::endl; 44 | return EXIT_FAILURE; 45 | } 46 | 47 | // grid dimensions 48 | if (nx == 0) 49 | nx = 100; 50 | if (ny == 0) 51 | ny = nx; 52 | 53 | // location of point heat source 54 | int x0 = (nx - 1) / 2; 55 | int y0 = (ny - 1) / 2; 56 | 57 | // constants used in the solution 58 | const double k = 0.04; 59 | const double dx = 2.0 / (std::max(nx, ny) - 1); 60 | const double dy = 2.0 / (std::max(nx, ny) - 1); 61 | const double dt = 0.5 * (dx * dx + dy * dy) / (8 * k); 62 | const double tfinal = nt ? nt * dt : 1; 63 | const double pi = 3.14159265358979323846; 64 | 65 | // initialize u (constructor zero-initializes) 66 | array2d u(nx, ny, rate); 67 | rate = u.rate(); 68 | u(x0, y0) = 1; 69 | 70 | // iterate until final time 71 | std::cerr.precision(6); 72 | double t; 73 | for (t = 0; t < tfinal; t += dt) { 74 | std::cerr << "t=" << std::fixed << t << std::endl; 75 | // compute du/dt 76 | array2d du(nx, ny, rate); 77 | for (int y = 1; y < ny - 1; y++) { 78 | for (int x = 1; x < nx - 1; x++) { 79 | double uxx = (u(x - 1, y) - 2 * u(x, y) + u(x + 1, y)) / (dx * dx); 80 | double uyy = (u(x, y - 1) - 2 * u(x, y) + u(x, y + 1)) / (dy * dy); 81 | du(x, y) = dt * k * (uxx + uyy); 82 | } 83 | } 84 | // take forward Euler step 85 | for (uint i = 0; i < u.size(); i++) 86 | u[i] += du[i]; 87 | } 88 | 89 | // compute root mean square error with respect to exact solution 90 | double e = 0; 91 | double sum = 0; 92 | for (int y = 1; y < ny - 1; y++) { 93 | double py = dy * (y - y0); 94 | for (int x = 1; x < nx - 1; x++) { 95 | double px = dx * (x - x0); 96 | double f = u(x, y); 97 | double g = dx * dy * std::exp(-(px * px + py * py) / (4 * k * t)) / (4 * pi * k * t); 98 | e += (f - g) * (f - g); 99 | sum += f; 100 | } 101 | } 102 | e = std::sqrt(e / ((nx - 2) * (ny - 2))); 103 | std::cerr.unsetf(std::ios::fixed); 104 | std::cerr << "rate=" << rate << " sum=" << std::fixed << sum << " error=" << std::setprecision(6) << std::scientific << e << std::endl; 105 | 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/examples/fields.h: -------------------------------------------------------------------------------- 1 | #ifndef FIELDS_H 2 | #define FIELDS_H 3 | 4 | // single- and double-precision fields for regression testing 5 | 6 | extern const float array_float[3][4096]; 7 | extern const double array_double[3][4096]; 8 | 9 | template 10 | struct Field { 11 | static const Scalar (*array)[4096]; 12 | }; 13 | 14 | template <> 15 | const float (*Field::array)[4096] = array_float; 16 | 17 | template <> 18 | const double (*Field::array)[4096] = array_double; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/examples/pgm.c: -------------------------------------------------------------------------------- 1 | /* simple example that shows how zfp can be used to compress pgm images */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "zfp.h" 9 | 10 | int main(int argc, char* argv[]) 11 | { 12 | double rate = 0; 13 | uint nx, ny; 14 | uint x, y; 15 | char line[0x100]; 16 | uchar* image; 17 | zfp_field* field; 18 | zfp_stream* zfp; 19 | bitstream* stream; 20 | void* buffer; 21 | size_t bytes; 22 | size_t size; 23 | 24 | switch (argc) { 25 | case 2: 26 | if (sscanf(argv[1], "%lf", &rate) != 1) 27 | goto usage; 28 | break; 29 | default: 30 | usage: 31 | fprintf(stderr, "Usage: pgm output.pgm\n"); 32 | return EXIT_FAILURE; 33 | } 34 | 35 | /* read pgm header */ 36 | if (!fgets(line, sizeof(line), stdin) || strcmp(line, "P5\n") || 37 | !fgets(line, sizeof(line), stdin) || sscanf(line, "%u%u", &nx, &ny) != 2 || 38 | !fgets(line, sizeof(line), stdin) || strcmp(line, "255\n")) { 39 | fprintf(stderr, "error opening image\n"); 40 | return EXIT_FAILURE; 41 | } 42 | 43 | if ((nx & 3u) || (ny & 3u)) { 44 | fprintf(stderr, "image dimensions must be multiples of four\n"); 45 | return EXIT_FAILURE; 46 | } 47 | 48 | /* read image data */ 49 | image = malloc(nx * ny); 50 | if (fread(image, sizeof(*image), nx * ny, stdin) != nx * ny) { 51 | fprintf(stderr, "error reading image\n"); 52 | return EXIT_FAILURE; 53 | } 54 | 55 | /* create input array */ 56 | field = zfp_field_2d(image, zfp_type_int32, nx, ny); 57 | 58 | /* initialize compressed stream */ 59 | zfp = zfp_stream_open(NULL); 60 | if (rate < 0) 61 | zfp_stream_set_precision(zfp, (uint)floor(0.5 - rate), zfp_type_int32); 62 | else 63 | zfp_stream_set_rate(zfp, rate, zfp_type_int32, 2, 0); 64 | bytes = zfp_stream_maximum_size(zfp, field); 65 | buffer = malloc(bytes); 66 | stream = stream_open(buffer, bytes); 67 | zfp_stream_set_bit_stream(zfp, stream); 68 | zfp_field_free(field); 69 | 70 | /* compress */ 71 | for (y = 0; y < ny; y += 4) 72 | for (x = 0; x < nx; x += 4) { 73 | uchar ublock[16]; 74 | int32 iblock[16]; 75 | uint i, j; 76 | for (j = 0; j < 4; j++) 77 | for (i = 0; i < 4; i++) 78 | ublock[i + 4 * j] = image[x + i + nx * (y + j)]; 79 | zfp_promote_uint8_to_int32(iblock, ublock, 2); 80 | zfp_encode_block_int32_2(zfp, iblock); 81 | } 82 | 83 | zfp_stream_flush(zfp); 84 | size = zfp_stream_compressed_size(zfp); 85 | fprintf(stderr, "%u compressed bytes (%.2f bps)\n", (uint)size, (double)size * CHAR_BIT / (nx * ny)); 86 | 87 | /* decompress */ 88 | zfp_stream_rewind(zfp); 89 | for (y = 0; y < ny; y += 4) 90 | for (x = 0; x < nx; x += 4) { 91 | int32 iblock[16]; 92 | uchar ublock[16]; 93 | uint i, j; 94 | zfp_decode_block_int32_2(zfp, iblock); 95 | zfp_demote_int32_to_uint8(ublock, iblock, 2); 96 | for (j = 0; j < 4; j++) 97 | for (i = 0; i < 4; i++) 98 | image[x + i + nx * (y + j)] = ublock[i + 4 * j]; 99 | } 100 | zfp_stream_close(zfp); 101 | stream_close(stream); 102 | free(buffer); 103 | 104 | /* output reconstructed image */ 105 | printf("P5\n"); 106 | printf("%u %u\n", nx, ny); 107 | printf("255\n"); 108 | fwrite(image, sizeof(*image), nx * ny, stdout); 109 | free(image); 110 | 111 | return 0; 112 | } 113 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/examples/simple.c: -------------------------------------------------------------------------------- 1 | /* minimal code example showing how to call the zfp (de)compressor */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "zfp.h" 8 | 9 | /* compress or decompress array */ 10 | static int 11 | compress(double* array, int nx, int ny, int nz, double tolerance, int decompress) 12 | { 13 | int status = 0; /* return value: 0 = success */ 14 | zfp_type type; /* array scalar type */ 15 | zfp_field* field; /* array meta data */ 16 | zfp_stream* zfp; /* compressed stream */ 17 | void* buffer; /* storage for compressed stream */ 18 | size_t bufsize; /* byte size of compressed buffer */ 19 | bitstream* stream; /* bit stream to write to or read from */ 20 | size_t zfpsize; /* byte size of compressed stream */ 21 | 22 | /* allocate meta data for the 3D array a[nz][ny][nx] */ 23 | type = zfp_type_double; 24 | field = zfp_field_3d(array, type, nx, ny, nz); 25 | 26 | /* allocate meta data for a compressed stream */ 27 | zfp = zfp_stream_open(NULL); 28 | 29 | /* set compression mode and parameters via one of three functions */ 30 | /* zfp_stream_set_rate(zfp, rate, type, 3, 0); */ 31 | /* zfp_stream_set_precision(zfp, precision, type); */ 32 | zfp_stream_set_accuracy(zfp, tolerance, type); 33 | 34 | /* allocate buffer for compressed data */ 35 | bufsize = zfp_stream_maximum_size(zfp, field); 36 | buffer = malloc(bufsize); 37 | 38 | /* associate bit stream with allocated buffer */ 39 | stream = stream_open(buffer, bufsize); 40 | zfp_stream_set_bit_stream(zfp, stream); 41 | zfp_stream_rewind(zfp); 42 | 43 | /* compress or decompress entire array */ 44 | if (decompress) { 45 | /* read compressed stream and decompress array */ 46 | zfpsize = fread(buffer, 1, bufsize, stdin); 47 | if (!zfp_decompress(zfp, field)) { 48 | fprintf(stderr, "decompression failed\n"); 49 | status = 1; 50 | } 51 | } 52 | else { 53 | /* compress array and output compressed stream */ 54 | zfpsize = zfp_compress(zfp, field); 55 | if (!zfpsize) { 56 | fprintf(stderr, "compression failed\n"); 57 | status = 1; 58 | } 59 | else 60 | fwrite(buffer, 1, zfpsize, stdout); 61 | } 62 | 63 | /* clean up */ 64 | zfp_field_free(field); 65 | zfp_stream_close(zfp); 66 | stream_close(stream); 67 | free(buffer); 68 | free(array); 69 | 70 | return status; 71 | } 72 | 73 | int main(int argc, char* argv[]) 74 | { 75 | /* use -d to decompress rather than compress data */ 76 | int decompress = (argc == 2 && !strcmp(argv[1], "-d")); 77 | 78 | /* allocate 100x100x100 array of doubles */ 79 | int nx = 100; 80 | int ny = 100; 81 | int nz = 100; 82 | double* array = malloc(nx * ny * nz * sizeof(double)); 83 | 84 | if (!decompress) { 85 | /* initialize array to be compressed */ 86 | int i, j, k; 87 | for (k = 0; k < nz; k++) 88 | for (j = 0; j < ny; j++) 89 | for (i = 0; i < nx; i++) { 90 | double x = 2.0 * i / nx; 91 | double y = 2.0 * j / ny; 92 | double z = 2.0 * k / nz; 93 | array[i + nx * (j + ny * k)] = exp(-(x * x + y * y + z * z)); 94 | } 95 | } 96 | 97 | /* compress or decompress array */ 98 | return compress(array, nx, ny, nz, 1e-3, decompress); 99 | } 100 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/examples/speed.c: -------------------------------------------------------------------------------- 1 | /* measure the throughput of encoding and decoding 3D blocks of doubles */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "zfp.h" 8 | 9 | /* example 3D block of (reinterpreted) doubles */ 10 | static const uint64 block[] = { 11 | 0xbf7c3a7bb8495ca9ull, 12 | 0xbf79f9d9058ffdafull, 13 | 0xbf77c7abd0b61999ull, 14 | 0xbf75a42c806bd1daull, 15 | 0xbf738f8f740b8ea8ull, 16 | 0xbf718a050399fef8ull, 17 | 0xbf6f2772ff8c30feull, 18 | 0xbf6b59aa63d22f68ull, 19 | 0xbf67aaf8b80cff9eull, 20 | 0xbf641b9e71983592ull, 21 | 0xbf60abd3f723f2b7ull, 22 | 0xbf5ab7934169cc04ull, 23 | 0xbf54574f6f4897d3ull, 24 | 0xbf4c6e39da7fb99bull, 25 | 0xbf40ae5826a893d1ull, 26 | 0xbf25bce8e19d48e1ull, 27 | 0x3f253bfed65904d7ull, 28 | 0x3f3f18ab46a04cf3ull, 29 | 0x3f4948e7cb74278bull, 30 | 0x3f51427b51aeec2eull, 31 | 0x3f55a0716d8b4b6bull, 32 | 0x3f59be96aeaac56full, 33 | 0x3f5d9d3ba7bfd327ull, 34 | 0x3f609e608469e93eull, 35 | 0x3f624ecbcfa3832cull, 36 | 0x3f63e0202ae84b4dull, 37 | 0x3f6552a61a3f4812ull, 38 | 0x3f66a6ae305af268ull, 39 | 0x3f67dc910e9935bcull, 40 | 0x3f68f4af65036ff7ull, 41 | 0x3f69ef71f24e7182ull, 42 | 0x3f6acd4983da7d43ull, 43 | 0x3f6b8eaef5b348a0ull, 44 | 0x3f6c3423328ffb7aull, 45 | 0x3f6cbe2f33d33034ull, 46 | 0x3f6d2d64018af3acull, 47 | 0x3f6d825ab270c540ull, 48 | 0x3f6dbdb46be996ccull, 49 | 0x3f6de01a6205cca9ull, 50 | 0x3f6dea3dd7813dafull, 51 | 0x3f6ddcd81dc33335ull, 52 | 0x3f6db8aa94de690full, 53 | 0x3f6d7e7eab910d8full, 54 | 0x3f6d2f25df44c187ull, 55 | 0x3f6ccb79bc0e9844ull, 56 | 0x3f6c545bdcaf1795ull, 57 | 0x3f6bcab5ea9237c4ull, 58 | 0x3f6b2f799dcf639bull, 59 | 0x3f6a83a0bd297862ull, 60 | 0x3f69c82d1e0ec5deull, 61 | 0x3f68fe28a4990e53ull, 62 | 0x3f6826a5438d8685ull, 63 | 0x3f6742bcfc5cd5b2ull, 64 | 0x3f665391df231599ull, 65 | 0x3f655a4e0aa7d278ull, 66 | 0x3f645823ac5e0b09ull, 67 | 0x3f634e4d00643085ull, 68 | 0x3f623e0c518426a3ull, 69 | 0x3f6128abf933439aull, 70 | 0x3f600f7e5f92501cull, 71 | 0x3f5de7bbf6db0eb7ull, 72 | 0x3f5bae5aa4792e11ull, 73 | 0x3f5975adf0453ea2ull, 74 | 0x3f57409b1fdc65c4ull, 75 | }; 76 | 77 | int main(int argc, char* argv[]) 78 | { 79 | size_t n = 0x200000; 80 | double rate = 1; 81 | zfp_field* field; 82 | uint insize; 83 | zfp_stream* zfp; 84 | bitstream* stream; 85 | void* buffer; 86 | size_t bytes; 87 | clock_t c; 88 | double time; 89 | uint i; 90 | 91 | switch (argc) { 92 | case 3: 93 | sscanf(argv[2], "%zu", &n); 94 | /* FALLTHROUGH */ 95 | case 2: 96 | sscanf(argv[1], "%lf", &rate); 97 | break; 98 | } 99 | 100 | /* declare array to compress */ 101 | field = zfp_field_3d(NULL, zfp_type_double, 4, 4, 4 * n); 102 | insize = n * sizeof(block); 103 | 104 | /* allocate storage for compressed bit stream */ 105 | zfp = zfp_stream_open(NULL); 106 | zfp_stream_set_rate(zfp, rate, zfp_field_type(field), zfp_field_dimensionality(field), 0); 107 | bytes = zfp_stream_maximum_size(zfp, field); 108 | buffer = malloc(bytes); 109 | stream = stream_open(buffer, bytes); 110 | zfp_stream_set_bit_stream(zfp, stream); 111 | zfp_field_free(field); 112 | 113 | /* compress */ 114 | c = clock(); 115 | for (i = 0; i < n; i++) 116 | zfp_encode_block_double_3(zfp, (const double*)block); 117 | zfp_stream_flush(zfp); 118 | time = (double)(clock() - c) / CLOCKS_PER_SEC; 119 | printf("encode in=%u out=%u %.0f MB/s\n", insize, (uint)stream_size(stream), insize / (1024 * 1024 * time)); 120 | 121 | /* decompress */ 122 | zfp_stream_rewind(zfp); 123 | c = clock(); 124 | for (i = 0; i < n; i++) { 125 | double a[64]; 126 | zfp_decode_block_double_3(zfp, a); 127 | } 128 | time = (double)(clock() - c) / CLOCKS_PER_SEC; 129 | printf("decode in=%u out=%u %.0f MB/s\n", (uint)stream_size(stream), insize, insize / (1024 * 1024 * time)); 130 | 131 | zfp_stream_close(zfp); 132 | stream_close(stream); 133 | free(buffer); 134 | 135 | return 0; 136 | } 137 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/inc/bitstream.h: -------------------------------------------------------------------------------- 1 | #ifndef BITSTREAM_H 2 | #define BITSTREAM_H 3 | 4 | #include 5 | #include "types.h" 6 | 7 | /* forward declaration of opaque type */ 8 | typedef struct bitstream bitstream; 9 | 10 | extern const size_t stream_word_bits; /* bit stream granularity */ 11 | 12 | #ifndef _inline 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* allocate and initialize bit stream */ 18 | bitstream* stream_open(void* buffer, size_t bytes); 19 | 20 | /* close and deallocate bit stream */ 21 | void stream_close(bitstream* stream); 22 | 23 | /* pointer to beginning of stream */ 24 | void* stream_data(const bitstream* stream); 25 | 26 | /* current byte size of stream (if flushed) */ 27 | size_t stream_size(const bitstream* stream); 28 | 29 | /* byte capacity of stream */ 30 | size_t stream_capacity(const bitstream* stream); 31 | 32 | /* number of words per block */ 33 | size_t stream_block(const bitstream* stream); 34 | 35 | /* number of blocks between consecutive blocks */ 36 | int stream_delta(const bitstream* stream); 37 | 38 | /* read single bit (0 or 1) */ 39 | uint stream_read_bit(bitstream* stream); 40 | 41 | /* write single bit */ 42 | uint stream_write_bit(bitstream* stream, uint bit); 43 | 44 | /* read 0 <= n <= 64 bits */ 45 | uint64 stream_read_bits(bitstream* stream, uint n); 46 | 47 | /* write 0 <= n <= 64 low bits of value and return remaining bits */ 48 | uint64 stream_write_bits(bitstream* stream, uint64 value, uint n); 49 | 50 | /* return bit offset to next bit to be read */ 51 | size_t stream_rtell(const bitstream* stream); 52 | 53 | /* return bit offset to next bit to be written */ 54 | size_t stream_wtell(const bitstream* stream); 55 | 56 | /* rewind stream to beginning */ 57 | void stream_rewind(bitstream* stream); 58 | 59 | /* position stream for reading at given bit offset */ 60 | void stream_rseek(bitstream* stream, size_t offset); 61 | 62 | /* position stream for writing at given bit offset */ 63 | void stream_wseek(bitstream* stream, size_t offset); 64 | 65 | /* skip over the next n bits */ 66 | void stream_skip(bitstream* stream, uint n); 67 | 68 | /* append n zero bits to stream */ 69 | void stream_pad(bitstream* stream, uint n); 70 | 71 | /* align stream on next word boundary */ 72 | void stream_align(bitstream* stream); 73 | 74 | /* flush out any remaining buffered bits */ 75 | void stream_flush(bitstream* stream); 76 | 77 | #ifdef BITSTREAM_STRIDED 78 | /* set block size in number of words and spacing in number of blocks */ 79 | int stream_set_stride(bitstream* stream, uint block, int delta); 80 | #endif 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | #endif /* !_inline */ 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/inc/macros.h: -------------------------------------------------------------------------------- 1 | #ifndef MACROS_H 2 | #define MACROS_H 3 | 4 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) 5 | #define MAX(x, y) ((x) > (y) ? (x) : (y)) 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/inc/system.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEM_H 2 | #define SYSTEM_H 3 | 4 | #if __STDC_VERSION__ >= 199901L 5 | #define _restrict restrict 6 | #else 7 | #define _restrict 8 | #endif 9 | 10 | #ifdef __GNUC__ 11 | #ifndef CACHE_LINE_SIZE 12 | #define CACHE_LINE_SIZE 0x100 13 | #endif 14 | #define _align(n) __attribute__((aligned(n))) 15 | #define _cache_align(x) x _align(CACHE_LINE_SIZE) 16 | #else 17 | #define _cache_align(x) x 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/inc/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | typedef unsigned char uchar; 5 | typedef unsigned short ushort; 6 | typedef unsigned int uint; 7 | 8 | #if __STDC_VERSION__ >= 199901L 9 | #include 10 | typedef int8_t int8; 11 | typedef uint8_t uint8; 12 | typedef int16_t int16; 13 | typedef uint16_t uint16; 14 | typedef int32_t int32; 15 | typedef uint32_t uint32; 16 | typedef int64_t int64; 17 | typedef uint64_t uint64; 18 | #else 19 | /* assume common integer types in C89 */ 20 | typedef signed char int8; 21 | typedef unsigned char uint8; 22 | typedef signed short int16; 23 | typedef unsigned short uint16; 24 | typedef signed int int32; 25 | typedef unsigned int uint32; 26 | typedef signed long long int64; /* not ANSI C89 compliant */ 27 | typedef unsigned long long uint64; /* not ANSI C89 compliant */ 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/Makefile: -------------------------------------------------------------------------------- 1 | include ../Config 2 | 3 | TARGETS = ../lib/libzfp.a ../lib/libzfp.so 4 | OBJECTS = bitstream.o decode1f.o decode1d.o encode1f.o encode1d.o decode2f.o decode2d.o encode2f.o encode2d.o decode3f.o decode3d.o encode3f.o encode3d.o zfp.o 5 | 6 | ../lib/libzfp.a: $(OBJECTS) 7 | rm -f $@ 8 | ar rc $@ $^ 9 | 10 | ../lib/libzfp.so: $(OBJECTS) 11 | $(CC) $(CFLAGS) -shared $^ -o $@ 12 | 13 | .c.o: 14 | $(CC) $(CFLAGS) -c $< 15 | 16 | static: ../lib/libzfp.a 17 | 18 | shared: ../lib/libzfp.so 19 | 20 | clean: 21 | rm -f $(TARGETS) $(OBJECTS) 22 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/bitstream.c: -------------------------------------------------------------------------------- 1 | #include "bitstream.h" 2 | #include "inline/bitstream.c" 3 | 4 | const size_t stream_word_bits = wsize; 5 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/block1.h: -------------------------------------------------------------------------------- 1 | #define DIMS 1 2 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/block2.h: -------------------------------------------------------------------------------- 1 | #define DIMS 2 2 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/block3.h: -------------------------------------------------------------------------------- 1 | #define DIMS 3 2 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/decode1d.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block1.h" 5 | #include "traitsd.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec1.c" 9 | #include "template/decode1.c" 10 | #include "template/decode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/decode1f.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block1.h" 5 | #include "traitsf.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec1.c" 9 | #include "template/decode1.c" 10 | #include "template/decode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/decode2d.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block2.h" 5 | #include "traitsd.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec2.c" 9 | #include "template/decode2.c" 10 | #include "template/decode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/decode2f.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block2.h" 5 | #include "traitsf.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec2.c" 9 | #include "template/decode2.c" 10 | #include "template/decode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/decode3d.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block3.h" 5 | #include "traitsd.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec3.c" 9 | #include "template/decode3.c" 10 | #include "template/decode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/decode3f.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block3.h" 5 | #include "traitsf.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec3.c" 9 | #include "template/decode3.c" 10 | #include "template/decode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/encode1d.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block1.h" 5 | #include "traitsd.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec1.c" 9 | #include "template/encode1.c" 10 | #include "template/encode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/encode1f.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block1.h" 5 | #include "traitsf.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec1.c" 9 | #include "template/encode1.c" 10 | #include "template/encode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/encode2d.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block2.h" 5 | #include "traitsd.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec2.c" 9 | #include "template/encode2.c" 10 | #include "template/encode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/encode2f.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block2.h" 5 | #include "traitsf.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec2.c" 9 | #include "template/encode2.c" 10 | #include "template/encode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/encode3d.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block3.h" 5 | #include "traitsd.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec3.c" 9 | #include "template/encode3.c" 10 | #include "template/encode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/encode3f.c: -------------------------------------------------------------------------------- 1 | #include "inline/inline.h" 2 | #include "zfp.h" 3 | #include "macros.h" 4 | #include "block3.h" 5 | #include "traitsf.h" 6 | #include "template/template.h" 7 | #include "template/codec.h" 8 | #include "template/codec3.c" 9 | #include "template/encode3.c" 10 | #include "template/encode.c" 11 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/inline/inline.h: -------------------------------------------------------------------------------- 1 | #ifndef INLINE_H 2 | #define INLINE_H 3 | 4 | #ifndef _inline 5 | #if __STDC_VERSION__ >= 199901L 6 | #define _inline static inline 7 | #else 8 | #define _inline static 9 | #endif 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/codec.h: -------------------------------------------------------------------------------- 1 | #define PERM _t1(perm, DIMS) /* coefficient order */ 2 | #define BLOCK_SIZE (1 << (2 * DIMS)) /* values per block */ 3 | #define EBIAS ((1 << (EBITS - 1)) - 1) /* exponent bias */ 4 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/codec1.c: -------------------------------------------------------------------------------- 1 | /* order coefficients by polynomial degree/frequency */ 2 | _cache_align(static const uchar perm_1[4]) = { 3 | 0, 1, 2, 3 4 | }; 5 | 6 | /* maximum number of bit planes to encode */ 7 | static uint 8 | _t2(precision, Scalar, 1)(int maxexp, uint maxprec, int minexp) 9 | { 10 | return MIN(maxprec, MAX(0, maxexp - minexp + 4)); 11 | } 12 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/codec2.c: -------------------------------------------------------------------------------- 1 | #define index(i, j) ((i) + 4 * (j)) 2 | 3 | /* order coefficients (i, j) by i + j, then i^2 + j^2 */ 4 | _cache_align(static const uchar perm_2[16]) = { 5 | index(0, 0), /* 0 : 0 */ 6 | 7 | index(1, 0), /* 1 : 1 */ 8 | index(0, 1), /* 2 : 1 */ 9 | 10 | index(1, 1), /* 3 : 2 */ 11 | 12 | index(2, 0), /* 4 : 2 */ 13 | index(0, 2), /* 5 : 2 */ 14 | 15 | index(2, 1), /* 6 : 3 */ 16 | index(1, 2), /* 7 : 3 */ 17 | 18 | index(3, 0), /* 8 : 3 */ 19 | index(0, 3), /* 9 : 3 */ 20 | 21 | index(2, 2), /* 10 : 4 */ 22 | 23 | index(3, 1), /* 11 : 4 */ 24 | index(1, 3), /* 12 : 4 */ 25 | 26 | index(3, 2), /* 13 : 5 */ 27 | index(2, 3), /* 14 : 5 */ 28 | 29 | index(3, 3), /* 15 : 6 */ 30 | }; 31 | 32 | #undef index 33 | 34 | /* maximum number of bit planes to encode */ 35 | static uint 36 | _t2(precision, Scalar, 2)(int maxexp, uint maxprec, int minexp) 37 | { 38 | return MIN(maxprec, MAX(0, maxexp - minexp + 6)); 39 | } 40 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/codec3.c: -------------------------------------------------------------------------------- 1 | #define index(i, j, k) ((i) + 4 * ((j) + 4 * (k))) 2 | 3 | /* order coefficients (i, j, k) by i + j + k, then i^2 + j^2 + k^2 */ 4 | _cache_align(static const uchar perm_3[64]) = { 5 | index(0, 0, 0), /* 0 : 0 */ 6 | 7 | index(1, 0, 0), /* 1 : 1 */ 8 | index(0, 1, 0), /* 2 : 1 */ 9 | index(0, 0, 1), /* 3 : 1 */ 10 | 11 | index(0, 1, 1), /* 4 : 2 */ 12 | index(1, 0, 1), /* 5 : 2 */ 13 | index(1, 1, 0), /* 6 : 2 */ 14 | 15 | index(2, 0, 0), /* 7 : 2 */ 16 | index(0, 2, 0), /* 8 : 2 */ 17 | index(0, 0, 2), /* 9 : 2 */ 18 | 19 | index(1, 1, 1), /* 10 : 3 */ 20 | 21 | index(2, 1, 0), /* 11 : 3 */ 22 | index(2, 0, 1), /* 12 : 3 */ 23 | index(0, 2, 1), /* 13 : 3 */ 24 | index(1, 2, 0), /* 14 : 3 */ 25 | index(1, 0, 2), /* 15 : 3 */ 26 | index(0, 1, 2), /* 16 : 3 */ 27 | 28 | index(3, 0, 0), /* 17 : 3 */ 29 | index(0, 3, 0), /* 18 : 3 */ 30 | index(0, 0, 3), /* 19 : 3 */ 31 | 32 | index(2, 1, 1), /* 20 : 4 */ 33 | index(1, 2, 1), /* 21 : 4 */ 34 | index(1, 1, 2), /* 22 : 4 */ 35 | 36 | index(0, 2, 2), /* 23 : 4 */ 37 | index(2, 0, 2), /* 24 : 4 */ 38 | index(2, 2, 0), /* 25 : 4 */ 39 | 40 | index(3, 1, 0), /* 26 : 4 */ 41 | index(3, 0, 1), /* 27 : 4 */ 42 | index(0, 3, 1), /* 28 : 4 */ 43 | index(1, 3, 0), /* 29 : 4 */ 44 | index(1, 0, 3), /* 30 : 4 */ 45 | index(0, 1, 3), /* 31 : 4 */ 46 | 47 | index(1, 2, 2), /* 32 : 5 */ 48 | index(2, 1, 2), /* 33 : 5 */ 49 | index(2, 2, 1), /* 34 : 5 */ 50 | 51 | index(3, 1, 1), /* 35 : 5 */ 52 | index(1, 3, 1), /* 36 : 5 */ 53 | index(1, 1, 3), /* 37 : 5 */ 54 | 55 | index(3, 2, 0), /* 38 : 5 */ 56 | index(3, 0, 2), /* 39 : 5 */ 57 | index(0, 3, 2), /* 40 : 5 */ 58 | index(2, 3, 0), /* 41 : 5 */ 59 | index(2, 0, 3), /* 42 : 5 */ 60 | index(0, 2, 3), /* 43 : 5 */ 61 | 62 | index(2, 2, 2), /* 44 : 6 */ 63 | 64 | index(3, 2, 1), /* 45 : 6 */ 65 | index(3, 1, 2), /* 46 : 6 */ 66 | index(1, 3, 2), /* 47 : 6 */ 67 | index(2, 3, 1), /* 48 : 6 */ 68 | index(2, 1, 3), /* 49 : 6 */ 69 | index(1, 2, 3), /* 50 : 6 */ 70 | 71 | index(0, 3, 3), /* 51 : 6 */ 72 | index(3, 0, 3), /* 52 : 6 */ 73 | index(3, 3, 0), /* 53 : 6 */ 74 | 75 | index(3, 2, 2), /* 54 : 7 */ 76 | index(2, 3, 2), /* 55 : 7 */ 77 | index(2, 2, 3), /* 56 : 7 */ 78 | 79 | index(1, 3, 3), /* 57 : 7 */ 80 | index(3, 1, 3), /* 58 : 7 */ 81 | index(3, 3, 1), /* 59 : 7 */ 82 | 83 | index(2, 3, 3), /* 60 : 8 */ 84 | index(3, 2, 3), /* 61 : 8 */ 85 | index(3, 3, 2), /* 62 : 8 */ 86 | 87 | index(3, 3, 3), /* 63 : 9 */ 88 | }; 89 | 90 | #undef index 91 | 92 | /* maximum number of bit planes to encode */ 93 | static uint 94 | _t2(precision, Scalar, 3)(int maxexp, uint maxprec, int minexp) 95 | { 96 | return MIN(maxprec, MAX(0, maxexp - minexp + 8)); 97 | } 98 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/decode1.c: -------------------------------------------------------------------------------- 1 | static void _t1(inv_lift, Int)(Int* p, uint s); 2 | 3 | /* private functions ------------------------------------------------------- */ 4 | 5 | /* scatter 4-value block to strided array */ 6 | static void 7 | _t2(scatter, Scalar, 1)(const Scalar* q, Scalar* p, int sx) 8 | { 9 | uint x; 10 | for (x = 0; x < 4; x++, p += sx) 11 | *p = *q++; 12 | } 13 | 14 | /* scatter nx-value block to strided array */ 15 | static void 16 | _t2(scatter_partial, Scalar, 1)(const Scalar* q, Scalar* p, uint nx, int sx) 17 | { 18 | uint x; 19 | for (x = 0; x < nx; x++, p += sx) 20 | *p = *q++; 21 | } 22 | 23 | /* inverse decorrelating 1D transform */ 24 | static void 25 | _t2(inv_xform, Int, 1)(Int* p) 26 | { 27 | /* transform along x */ 28 | _t1(inv_lift, Int)(p, 1); 29 | } 30 | 31 | /* public functions -------------------------------------------------------- */ 32 | 33 | /* decode 4-value floating-point block and store at p using stride sx */ 34 | uint 35 | _t2(zfp_decode_block_strided, Scalar, 1)(zfp_stream* stream, Scalar* p, int sx) 36 | { 37 | /* decode contiguous block */ 38 | _cache_align(Scalar fblock[4]); 39 | uint bits = _t2(zfp_decode_block, Scalar, 1)(stream, fblock); 40 | /* scatter block to strided array */ 41 | _t2(scatter, Scalar, 1)(fblock, p, sx); 42 | return bits; 43 | } 44 | 45 | /* decode nx-value floating-point block and store at p using stride sx */ 46 | uint 47 | _t2(zfp_decode_partial_block_strided, Scalar, 1)(zfp_stream* stream, Scalar* p, uint nx, int sx) 48 | { 49 | /* decode contiguous block */ 50 | _cache_align(Scalar fblock[4]); 51 | uint bits = _t2(zfp_decode_block, Scalar, 1)(stream, fblock); 52 | /* scatter block to strided array */ 53 | _t2(scatter_partial, Scalar, 1)(fblock, p, nx, sx); 54 | return bits; 55 | } 56 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/decode2.c: -------------------------------------------------------------------------------- 1 | static void _t1(inv_lift, Int)(Int* p, uint s); 2 | 3 | /* private functions ------------------------------------------------------- */ 4 | 5 | /* scatter 4*4 block to strided array */ 6 | static void 7 | _t2(scatter, Scalar, 2)(const Scalar* q, Scalar* p, int sx, int sy) 8 | { 9 | uint x, y; 10 | for (y = 0; y < 4; y++, p += sy - 4 * sx) 11 | for (x = 0; x < 4; x++, p += sx) 12 | *p = *q++; 13 | } 14 | 15 | /* scatter nx*ny block to strided array */ 16 | static void 17 | _t2(scatter_partial, Scalar, 2)(const Scalar* q, Scalar* p, uint nx, uint ny, int sx, int sy) 18 | { 19 | uint x, y; 20 | for (y = 0; y < ny; y++, p += sy - nx * sx, q += 4 - nx) 21 | for (x = 0; x < nx; x++, p += sx, q++) 22 | *p = *q; 23 | } 24 | 25 | /* inverse decorrelating 2D transform */ 26 | static void 27 | _t2(inv_xform, Int, 2)(Int* p) 28 | { 29 | uint x, y; 30 | /* transform along y */ 31 | for (x = 0; x < 4; x++) 32 | _t1(inv_lift, Int)(p + 1 * x, 4); 33 | /* transform along x */ 34 | for (y = 0; y < 4; y++) 35 | _t1(inv_lift, Int)(p + 4 * y, 1); 36 | } 37 | 38 | /* public functions -------------------------------------------------------- */ 39 | 40 | /* decode 4*4 floating-point block and store at p using strides (sx, sy) */ 41 | uint 42 | _t2(zfp_decode_block_strided, Scalar, 2)(zfp_stream* stream, Scalar* p, int sx, int sy) 43 | { 44 | /* decode contiguous block */ 45 | _cache_align(Scalar fblock[16]); 46 | uint bits = _t2(zfp_decode_block, Scalar, 2)(stream, fblock); 47 | /* scatter block to strided array */ 48 | _t2(scatter, Scalar, 2)(fblock, p, sx, sy); 49 | return bits; 50 | } 51 | 52 | /* decode nx*ny floating-point block and store at p using strides (sx, sy) */ 53 | uint 54 | _t2(zfp_decode_partial_block_strided, Scalar, 2)(zfp_stream* stream, Scalar* p, uint nx, uint ny, int sx, int sy) 55 | { 56 | /* decode contiguous block */ 57 | _cache_align(Scalar fblock[16]); 58 | uint bits = _t2(zfp_decode_block, Scalar, 2)(stream, fblock); 59 | /* scatter block to strided array */ 60 | _t2(scatter_partial, Scalar, 2)(fblock, p, nx, ny, sx, sy); 61 | return bits; 62 | } 63 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/decode3.c: -------------------------------------------------------------------------------- 1 | static void _t1(inv_lift, Int)(Int* p, uint s); 2 | 3 | /* private functions ------------------------------------------------------- */ 4 | 5 | /* scatter 4*4*4 block to strided array */ 6 | static void 7 | _t2(scatter, Scalar, 3)(const Scalar* q, Scalar* p, int sx, int sy, int sz) 8 | { 9 | uint x, y, z; 10 | for (z = 0; z < 4; z++, p += sz - 4 * sy) 11 | for (y = 0; y < 4; y++, p += sy - 4 * sx) 12 | for (x = 0; x < 4; x++, p += sx) 13 | *p = *q++; 14 | } 15 | 16 | /* scatter nx*ny*nz block to strided array */ 17 | static void 18 | _t2(scatter_partial, Scalar, 3)(const Scalar* q, Scalar* p, uint nx, uint ny, uint nz, int sx, int sy, int sz) 19 | { 20 | uint x, y, z; 21 | for (z = 0; z < nz; z++, p += sz - ny * sy, q += 4 * (4 - ny)) 22 | for (y = 0; y < ny; y++, p += sy - nx * sx, q += 4 - nx) 23 | for (x = 0; x < nx; x++, p += sx, q++) 24 | *p = *q; 25 | } 26 | 27 | /* inverse decorrelating 3D transform */ 28 | static void 29 | _t2(inv_xform, Int, 3)(Int* p) 30 | { 31 | uint x, y, z; 32 | /* transform along z */ 33 | for (y = 0; y < 4; y++) 34 | for (x = 0; x < 4; x++) 35 | _t1(inv_lift, Int)(p + 1 * x + 4 * y, 16); 36 | /* transform along y */ 37 | for (x = 0; x < 4; x++) 38 | for (z = 0; z < 4; z++) 39 | _t1(inv_lift, Int)(p + 16 * z + 1 * x, 4); 40 | /* transform along x */ 41 | for (z = 0; z < 4; z++) 42 | for (y = 0; y < 4; y++) 43 | _t1(inv_lift, Int)(p + 4 * y + 16 * z, 1); 44 | } 45 | 46 | /* public functions -------------------------------------------------------- */ 47 | 48 | /* decode 4*4*4 floating-point block and store at p using strides (sx, sy, sz) */ 49 | uint 50 | _t2(zfp_decode_block_strided, Scalar, 3)(zfp_stream* stream, Scalar* p, int sx, int sy, int sz) 51 | { 52 | /* decode contiguous block */ 53 | _cache_align(Scalar fblock[64]); 54 | uint bits = _t2(zfp_decode_block, Scalar, 3)(stream, fblock); 55 | /* scatter block to strided array */ 56 | _t2(scatter, Scalar, 3)(fblock, p, sx, sy, sz); 57 | return bits; 58 | } 59 | 60 | /* decode nx*ny*nz floating-point block and store at p using strides (sx, sy, sz) */ 61 | uint 62 | _t2(zfp_decode_partial_block_strided, Scalar, 3)(zfp_stream* stream, Scalar* p, uint nx, uint ny, uint nz, int sx, int sy, int sz) 63 | { 64 | /* decode contiguous block */ 65 | _cache_align(Scalar fblock[64]); 66 | uint bits = _t2(zfp_decode_block, Scalar, 3)(stream, fblock); 67 | /* scatter block to strided array */ 68 | _t2(scatter_partial, Scalar, 3)(fblock, p, nx, ny, nz, sx, sy, sz); 69 | return bits; 70 | } 71 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/decompress.c: -------------------------------------------------------------------------------- 1 | /* decompress 1d contiguous array */ 2 | static void 3 | _t2(decompress, Scalar, 1)(zfp_stream* stream, zfp_field* field) 4 | { 5 | Scalar* data = field->data; 6 | uint nx = field->nx; 7 | uint mx = nx & ~3u; 8 | uint x; 9 | 10 | for (x = 0; x < mx; x += 4, data += 4) 11 | _t2(zfp_decode_block, Scalar, 1)(stream, data); 12 | if (x < nx) 13 | _t2(zfp_decode_partial_block_strided, Scalar, 1)(stream, data, nx - x, 1); 14 | } 15 | 16 | /* decompress 1d strided array */ 17 | static void 18 | _t2(decompress_strided, Scalar, 1)(zfp_stream* stream, zfp_field* field) 19 | { 20 | Scalar* data = field->data; 21 | uint nx = field->nx; 22 | uint mx = nx & ~3u; 23 | int sx = field->sx; 24 | uint x; 25 | 26 | for (x = 0; x < mx; x += 4, data += 4 * sx) 27 | _t2(zfp_decode_block_strided, Scalar, 1)(stream, data, sx); 28 | if (x < nx) 29 | _t2(zfp_decode_partial_block_strided, Scalar, 1)(stream, data, nx - x, sx); 30 | } 31 | 32 | /* decompress 2d strided array */ 33 | static void 34 | _t2(decompress_strided, Scalar, 2)(zfp_stream* stream, zfp_field* field) 35 | { 36 | Scalar* data = field->data; 37 | uint nx = field->nx; 38 | uint ny = field->ny; 39 | uint mx = nx & ~3u; 40 | uint my = ny & ~3u; 41 | int sx = field->sx ? field->sx : 1; 42 | int sy = field->sy ? field->sy : nx; 43 | uint x, y; 44 | 45 | for (y = 0; y < my; y += 4, data += 4 * sy - mx * sx) { 46 | for (x = 0; x < mx; x += 4, data += 4 * sx) 47 | _t2(zfp_decode_block_strided, Scalar, 2)(stream, data, sx, sy); 48 | if (x < nx) 49 | _t2(zfp_decode_partial_block_strided, Scalar, 2)(stream, data, nx - x, 4, sx, sy); 50 | } 51 | if (y < ny) { 52 | for (x = 0; x < mx; x += 4, data += 4 * sx) 53 | _t2(zfp_decode_partial_block_strided, Scalar, 2)(stream, data, 4, ny - y, sx, sy); 54 | if (x < nx) 55 | _t2(zfp_decode_partial_block_strided, Scalar, 2)(stream, data, nx - x, ny - y, sx, sy); 56 | } 57 | } 58 | 59 | /* decompress 3d strided array */ 60 | static void 61 | _t2(decompress_strided, Scalar, 3)(zfp_stream* stream, zfp_field* field) 62 | { 63 | Scalar* data = field->data; 64 | uint nx = field->nx; 65 | uint ny = field->ny; 66 | uint nz = field->nz; 67 | uint mx = nx & ~3u; 68 | uint my = ny & ~3u; 69 | uint mz = nz & ~3u; 70 | int sx = field->sx ? field->sx : 1; 71 | int sy = field->sy ? field->sy : nx; 72 | int sz = field->sz ? field->sz : nx * ny; 73 | uint x, y, z; 74 | 75 | for (z = 0; z < mz; z += 4, data += 4 * sz - my * sy) { 76 | for (y = 0; y < my; y += 4, data += 4 * sy - mx * sx) { 77 | for (x = 0; x < mx; x += 4, data += 4 * sx) 78 | _t2(zfp_decode_block_strided, Scalar, 3)(stream, data, sx, sy, sz); 79 | if (x < nx) 80 | _t2(zfp_decode_partial_block_strided, Scalar, 3)(stream, data, nx - x, 4, 4, sx, sy, sz); 81 | } 82 | if (y < ny) { 83 | for (x = 0; x < mx; x += 4, data += 4 * sx) 84 | _t2(zfp_decode_partial_block_strided, Scalar, 3)(stream, data, 4, ny - y, 4, sx, sy, sz); 85 | if (x < nx) 86 | _t2(zfp_decode_partial_block_strided, Scalar, 3)(stream, data, nx - x, ny - y, 4, sx, sy, sz); 87 | data -= mx * sx; 88 | } 89 | } 90 | if (z < nz) { 91 | for (y = 0; y < my; y += 4, data += 4 * sy - mx * sx) { 92 | for (x = 0; x < mx; x += 4, data += 4 * sx) 93 | _t2(zfp_decode_partial_block_strided, Scalar, 3)(stream, data, 4, 4, nz - z, sx, sy, sz); 94 | if (x < nx) 95 | _t2(zfp_decode_partial_block_strided, Scalar, 3)(stream, data, nx - x, 4, nz - z, sx, sy, sz); 96 | } 97 | if (y < ny) { 98 | for (x = 0; x < mx; x += 4, data += 4 * sx) 99 | _t2(zfp_decode_partial_block_strided, Scalar, 3)(stream, data, 4, ny - y, nz - z, sx, sy, sz); 100 | if (x < nx) 101 | _t2(zfp_decode_partial_block_strided, Scalar, 3)(stream, data, nx - x, ny - y, nz - z, sx, sy, sz); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/encode1.c: -------------------------------------------------------------------------------- 1 | static void _t1(pad_block, Scalar)(Scalar* p, uint n, uint s); 2 | static void _t1(fwd_lift, Int)(Int* p, uint s); 3 | 4 | /* private functions ------------------------------------------------------- */ 5 | 6 | /* gather 4-value block from strided array */ 7 | static void 8 | _t2(gather, Scalar, 1)(Scalar* q, const Scalar* p, int sx) 9 | { 10 | uint x; 11 | for (x = 0; x < 4; x++, p += sx) 12 | *q++ = *p; 13 | } 14 | 15 | /* gather nx-value block from strided array */ 16 | static void 17 | _t2(gather_partial, Scalar, 1)(Scalar* q, const Scalar* p, uint nx, int sx) 18 | { 19 | uint x; 20 | for (x = 0; x < nx; x++, p += sx) 21 | q[x] = *p; 22 | _t1(pad_block, Scalar)(q, nx, 1); 23 | } 24 | 25 | /* forward decorrelating 1D transform */ 26 | static void 27 | _t2(fwd_xform, Int, 1)(Int* p) 28 | { 29 | /* transform along x */ 30 | _t1(fwd_lift, Int)(p, 1); 31 | } 32 | 33 | /* public functions -------------------------------------------------------- */ 34 | 35 | /* encode 4-value floating-point block stored at p using stride sx */ 36 | uint 37 | _t2(zfp_encode_block_strided, Scalar, 1)(zfp_stream* stream, const Scalar* p, int sx) 38 | { 39 | /* gather block from strided array */ 40 | _cache_align(Scalar fblock[4]); 41 | _t2(gather, Scalar, 1)(fblock, p, sx); 42 | /* encode floating-point block */ 43 | return _t2(zfp_encode_block, Scalar, 1)(stream, fblock); 44 | } 45 | 46 | /* encode nx-value floating-point block stored at p using stride sx */ 47 | uint 48 | _t2(zfp_encode_partial_block_strided, Scalar, 1)(zfp_stream* stream, const Scalar* p, uint nx, int sx) 49 | { 50 | /* gather block from strided array */ 51 | _cache_align(Scalar fblock[4]); 52 | _t2(gather_partial, Scalar, 1)(fblock, p, nx, sx); 53 | /* encode floating-point block */ 54 | return _t2(zfp_encode_block, Scalar, 1)(stream, fblock); 55 | } 56 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/encode2.c: -------------------------------------------------------------------------------- 1 | static void _t1(pad_block, Scalar)(Scalar* p, uint n, uint s); 2 | static void _t1(fwd_lift, Int)(Int* p, uint s); 3 | 4 | /* private functions ------------------------------------------------------- */ 5 | 6 | /* gather 4*4 block from strided array */ 7 | static void 8 | _t2(gather, Scalar, 2)(Scalar* q, const Scalar* p, int sx, int sy) 9 | { 10 | uint x, y; 11 | for (y = 0; y < 4; y++, p += sy - 4 * sx) 12 | for (x = 0; x < 4; x++, p += sx) 13 | *q++ = *p; 14 | } 15 | 16 | /* gather nx*ny block from strided array */ 17 | static void 18 | _t2(gather_partial, Scalar, 2)(Scalar* q, const Scalar* p, uint nx, uint ny, int sx, int sy) 19 | { 20 | uint x, y; 21 | for (y = 0; y < ny; y++, p += sy - nx * sx) { 22 | for (x = 0; x < nx; x++, p += sx) 23 | q[4 * y + x] = *p; 24 | _t1(pad_block, Scalar)(q + 4 * y, nx, 1); 25 | } 26 | for (x = 0; x < 4; x++) 27 | _t1(pad_block, Scalar)(q + x, ny, 4); 28 | } 29 | 30 | /* forward decorrelating 2D transform */ 31 | static void 32 | _t2(fwd_xform, Int, 2)(Int* p) 33 | { 34 | uint x, y; 35 | /* transform along x */ 36 | for (y = 0; y < 4; y++) 37 | _t1(fwd_lift, Int)(p + 4 * y, 1); 38 | /* transform along y */ 39 | for (x = 0; x < 4; x++) 40 | _t1(fwd_lift, Int)(p + 1 * x, 4); 41 | } 42 | 43 | /* public functions -------------------------------------------------------- */ 44 | 45 | /* encode 4*4 floating-point block stored at p using strides (sx, sy) */ 46 | uint 47 | _t2(zfp_encode_block_strided, Scalar, 2)(zfp_stream* stream, const Scalar* p, int sx, int sy) 48 | { 49 | /* gather block from strided array */ 50 | _cache_align(Scalar fblock[16]); 51 | _t2(gather, Scalar, 2)(fblock, p, sx, sy); 52 | /* encode floating-point block */ 53 | return _t2(zfp_encode_block, Scalar, 2)(stream, fblock); 54 | } 55 | 56 | /* encode nx*ny floating-point block stored at p using strides (sx, sy) */ 57 | uint 58 | _t2(zfp_encode_partial_block_strided, Scalar, 2)(zfp_stream* stream, const Scalar* p, uint nx, uint ny, int sx, int sy) 59 | { 60 | /* gather block from strided array */ 61 | _cache_align(Scalar fblock[16]); 62 | _t2(gather_partial, Scalar, 2)(fblock, p, nx, ny, sx, sy); 63 | /* encode floating-point block */ 64 | return _t2(zfp_encode_block, Scalar, 2)(stream, fblock); 65 | } 66 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/encode3.c: -------------------------------------------------------------------------------- 1 | static void _t1(pad_block, Scalar)(Scalar* p, uint n, uint s); 2 | static void _t1(fwd_lift, Int)(Int* p, uint s); 3 | 4 | /* private functions ------------------------------------------------------- */ 5 | 6 | /* gather 4*4*4 block from strided array */ 7 | static void 8 | _t2(gather, Scalar, 3)(Scalar* q, const Scalar* p, int sx, int sy, int sz) 9 | { 10 | uint x, y, z; 11 | for (z = 0; z < 4; z++, p += sz - 4 * sy) 12 | for (y = 0; y < 4; y++, p += sy - 4 * sx) 13 | for (x = 0; x < 4; x++, p += sx) 14 | *q++ = *p; 15 | } 16 | 17 | /* gather nx*ny*nz block from strided array */ 18 | static void 19 | _t2(gather_partial, Scalar, 3)(Scalar* q, const Scalar* p, uint nx, uint ny, uint nz, int sx, int sy, int sz) 20 | { 21 | uint x, y, z; 22 | for (z = 0; z < nz; z++, p += sz - ny * sy) { 23 | for (y = 0; y < ny; y++, p += sy - nx * sx) { 24 | for (x = 0; x < nx; x++, p += sx) 25 | q[16 * z + 4 * y + x] = *p; 26 | _t1(pad_block, Scalar)(q + 16 * z + 4 * y, nx, 1); 27 | } 28 | for (x = 0; x < 4; x++) 29 | _t1(pad_block, Scalar)(q + 16 * z + x, ny, 4); 30 | } 31 | for (y = 0; y < 4; y++) 32 | for (x = 0; x < 4; x++) 33 | _t1(pad_block, Scalar)(q + 4 * y + x, nz, 16); 34 | } 35 | 36 | /* forward decorrelating 3D transform */ 37 | static void 38 | _t2(fwd_xform, Int, 3)(Int* p) 39 | { 40 | uint x, y, z; 41 | /* transform along x */ 42 | for (z = 0; z < 4; z++) 43 | for (y = 0; y < 4; y++) 44 | _t1(fwd_lift, Int)(p + 4 * y + 16 * z, 1); 45 | /* transform along y */ 46 | for (x = 0; x < 4; x++) 47 | for (z = 0; z < 4; z++) 48 | _t1(fwd_lift, Int)(p + 16 * z + 1 * x, 4); 49 | /* transform along z */ 50 | for (y = 0; y < 4; y++) 51 | for (x = 0; x < 4; x++) 52 | _t1(fwd_lift, Int)(p + 1 * x + 4 * y, 16); 53 | } 54 | 55 | /* public functions -------------------------------------------------------- */ 56 | 57 | /* encode 4*4*4 floating-point block stored at p using strides (sx, sy, sz) */ 58 | uint 59 | _t2(zfp_encode_block_strided, Scalar, 3)(zfp_stream* stream, const Scalar* p, int sx, int sy, int sz) 60 | { 61 | /* gather block from strided array */ 62 | _cache_align(Scalar fblock[64]); 63 | _t2(gather, Scalar, 3)(fblock, p, sx, sy, sz); 64 | /* encode floating-point block */ 65 | return _t2(zfp_encode_block, Scalar, 3)(stream, fblock); 66 | } 67 | 68 | /* encode nx*ny*nz floating-point block stored at p using strides (sx, sy, sz) */ 69 | uint 70 | _t2(zfp_encode_partial_block_strided, Scalar, 3)(zfp_stream* stream, const Scalar* p, uint nx, uint ny, uint nz, int sx, int sy, int sz) 71 | { 72 | /* gather block from strided array */ 73 | _cache_align(Scalar fblock[64]); 74 | _t2(gather_partial, Scalar, 3)(fblock, p, nx, ny, nz, sx, sy, sz); 75 | /* encode floating-point block */ 76 | return _t2(zfp_encode_block, Scalar, 3)(stream, fblock); 77 | } 78 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/template/template.h: -------------------------------------------------------------------------------- 1 | #ifndef TEMPLATE_H 2 | #define TEMPLATE_H 3 | 4 | /* concatenation */ 5 | #define _cat2(x, y) x ## _ ## y 6 | #define _cat3(x, y, z) x ## _ ## y ## _ ## z 7 | 8 | /* 1- and 2-argument function templates */ 9 | #define _t1(function, arg) _cat2(function, arg) 10 | #define _t2(function, type, dims) _cat3(function, type, dims) 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/traitsd.h: -------------------------------------------------------------------------------- 1 | /* double-precision floating-point traits */ 2 | 3 | #define Scalar double /* floating-point type */ 4 | #define Int int64 /* corresponding signed integer type */ 5 | #define UInt uint64 /* corresponding unsigned integer type */ 6 | #define EBITS 11 /* number of exponent bits */ 7 | #define NBMASK 0xaaaaaaaaaaaaaaaaull /* negabinary mask */ 8 | 9 | #define FABS(x) fabs(x) 10 | #define FREXP(x, e) frexp(x, e) 11 | #define LDEXP(x, e) ldexp(x, e) 12 | -------------------------------------------------------------------------------- /dependencies/tinyexr/deps/ZFP/src/traitsf.h: -------------------------------------------------------------------------------- 1 | /* single-precision floating-point traits */ 2 | 3 | #define Scalar float /* floating-point type */ 4 | #define Int int32 /* corresponding signed integer type */ 5 | #define UInt uint32 /* corresponding unsigned integer type */ 6 | #define EBITS 8 /* number of exponent bits */ 7 | #define NBMASK 0xaaaaaaaau /* negabinary mask */ 8 | 9 | #if __STDC_VERSION__ >= 199901L 10 | #define FABS(x) fabsf(x) 11 | #define FREXP(x, e) frexpf(x, e) 12 | #define LDEXP(x, e) ldexpf(x, e) 13 | #else 14 | #define FABS(x) (float)fabs(x) 15 | #define FREXP(x, e) (void)frexp(x, e) 16 | #define LDEXP(x, e) (float)ldexp(x, e) 17 | #endif 18 | -------------------------------------------------------------------------------- /dependencies/tinyexr/experimental/js/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | ./compile_to_js.sh 3 | -------------------------------------------------------------------------------- /dependencies/tinyexr/experimental/js/README.md: -------------------------------------------------------------------------------- 1 | # Experimental JavaScript port of TinyEXR 2 | 3 | Using Emscripten. 4 | 5 | ## How to compile 6 | 7 | edit `compile_to_js.sh`, then 8 | 9 | ``` 10 | ./compile_to_js.sh 11 | ``` 12 | 13 | ## How to run test 14 | 15 | Requires node.js 16 | 17 | ``` 18 | $ node test.js 19 | ``` 20 | 21 | ## How to run a browser example 22 | 23 | Edit EXR file in `index.html` 24 | Copy a EXR file to this directory(default = asakusa.exr). 25 | (NOTE: Chrome does not allow reading a file from parent path(e.g. `../../asakusa.exr`). 26 | 27 | Launch http server, e.g., 28 | 29 | ``` 30 | $ python3 -m http.server 31 | ``` 32 | 33 | Open `http://localhost:8000` with an browser. 34 | 35 | ## TODO 36 | 37 | * [x] Write HTML5 Canvas drawing JS code from Float32Array( 38 | * [ ] Pollish JS API. 39 | -------------------------------------------------------------------------------- /dependencies/tinyexr/experimental/js/binding.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #define TINYEXR_IMPLEMENTATION 6 | #include "tinyexr.h" 7 | 8 | using namespace emscripten; 9 | 10 | /// 11 | /// Simple C++ wrapper class for Emscripten 12 | /// 13 | class EXRLoader { 14 | public: 15 | /// 16 | /// `binary` is the buffer for EXR binary(e.g. buffer read by fs.readFileSync) 17 | /// std::string can be used as UInt8Array in JS layer. 18 | /// 19 | EXRLoader(const std::string &binary) { 20 | const float *ptr = reinterpret_cast(binary.data()); 21 | 22 | float *rgba = nullptr; 23 | width_ = -1; 24 | height_ = -1; 25 | const char *err = nullptr; 26 | 27 | error_.clear(); 28 | 29 | result_ = LoadEXRFromMemory( 30 | &rgba, &width_, &height_, 31 | reinterpret_cast(binary.data()), binary.size(), 32 | &err); 33 | 34 | if (TINYEXR_SUCCESS == result_) { 35 | image_.resize(size_t(width_ * height_ * 4)); 36 | memcpy(image_.data(), rgba, sizeof(float) * size_t(width_ * height_ * 4)); 37 | free(rgba); 38 | } else { 39 | if (err) { 40 | error_ = std::string(err); 41 | } 42 | } 43 | } 44 | ~EXRLoader() {} 45 | 46 | // Return as memory views 47 | emscripten::val getBytes() const { 48 | return emscripten::val( 49 | emscripten::typed_memory_view(image_.size(), image_.data())); 50 | } 51 | 52 | bool ok() const { return (TINYEXR_SUCCESS == result_); } 53 | 54 | const std::string error() const { return error_; } 55 | 56 | int width() const { return width_; } 57 | 58 | int height() const { return height_; } 59 | 60 | private: 61 | std::vector image_; // RGBA 62 | int width_; 63 | int height_; 64 | int result_; 65 | std::string error_; 66 | }; 67 | 68 | // Register STL 69 | EMSCRIPTEN_BINDINGS(stl_wrappters) { register_vector("VectorFloat"); } 70 | 71 | EMSCRIPTEN_BINDINGS(tinyexr_module) { 72 | class_("EXRLoader") 73 | .constructor() 74 | .function("getBytes", &EXRLoader::getBytes) 75 | .function("ok", &EXRLoader::ok) 76 | .function("error", &EXRLoader::error) 77 | .function("width", &EXRLoader::width) 78 | .function("height", &EXRLoader::height); 79 | } 80 | -------------------------------------------------------------------------------- /dependencies/tinyexr/experimental/js/compile_to_js.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | EMCC=em++ 4 | 5 | # Export EXR loader/saver function to JS. 6 | # TODO: export more functions 7 | # DEMANGLE_SUPPORT=1 8 | #${EMCC} -std=c++11 --bind -O2 -I../../ binding.cc --memory-init-file 0 -s TOTAL_MEMORY=67108864 -s DEMANGLE_SUPPORT=1 -s EXPORTED_FUNCTIONS="['_ParseEXRHeaderFromMemory', '_LoadEXRFromMemory']" -o tinyexr.js 9 | ${EMCC} --bind -Os -I../../ binding.cc --memory-init-file 0 -s TOTAL_MEMORY=67108864 -o tinyexr.js 10 | -------------------------------------------------------------------------------- /dependencies/tinyexr/experimental/js/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | TinyEXR to Canvas 8 | 9 | 11 | 12 | 13 | 14 | 15 | 41 | 42 | -------------------------------------------------------------------------------- /dependencies/tinyexr/experimental/js/test.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var tinyexr = require('./tinyexr.js') 3 | 4 | var data = new Uint8Array(fs.readFileSync("../../asakusa.exr")) 5 | console.log(data.length) 6 | 7 | var instance = new tinyexr.EXRLoader(data); 8 | 9 | console.log(instance.ok()) 10 | console.log(instance.width()) 11 | console.log(instance.height()) 12 | 13 | var image = instance.getBytes() 14 | console.log(image[0]) 15 | console.log(image[1]) 16 | console.log(image[2]) 17 | console.log(image[3]) 18 | console.log(image[4]) 19 | console.log(image[5]) 20 | console.log(image[6]) 21 | console.log(image[7]) 22 | -------------------------------------------------------------------------------- /dependencies/tinyexr/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # A simple test for the minimal standard C++ library 2 | # 3 | 4 | LOCAL_PATH := $(call my-dir) 5 | 6 | include $(CLEAR_VARS) 7 | LOCAL_MODULE := tinyexr 8 | LOCAL_SRC_FILES := ../tinyexr.cc 9 | 10 | LOCAL_C_INCLUDES := ../ 11 | 12 | include $(BUILD_SHARED_LIBRARY) 13 | -------------------------------------------------------------------------------- /dependencies/tinyexr/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := all 2 | APP_STL := stlport_static 3 | -------------------------------------------------------------------------------- /dependencies/tinyexr/jni/Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(ANDROID_HOME),) 2 | NDK ?= $(ANDROID_NDK) 3 | else 4 | NDK ?= $(lastword $(sort $(wildcard $(dir $(ANDROID_HOME))/android-ndk*))) 5 | endif 6 | 7 | all: 8 | $(NDK)/ndk-build V=1 9 | -------------------------------------------------------------------------------- /dependencies/tinyexr/jni/README.md: -------------------------------------------------------------------------------- 1 | # Android NDK 2 | 3 | Test script to build `tinyexr` with Android NDK r10. 4 | Just checks compilation on Android NDK. 5 | -------------------------------------------------------------------------------- /dependencies/tinyexr/premake4.lua: -------------------------------------------------------------------------------- 1 | newoption { 2 | trigger = "with-zfp", 3 | description = "Build with ZFP support." 4 | } 5 | 6 | sources = { 7 | "tinyexr.h", 8 | "test_tinyexr.cc", 9 | } 10 | 11 | zfp_sources = { 12 | "./deps/ZFP/src/*.c" 13 | } 14 | 15 | -- premake4.lua 16 | solution "TinyEXRSolution" 17 | configurations { "Release", "Debug" } 18 | 19 | if (os.is("windows")) then 20 | platforms { "x32", "x64" } 21 | else 22 | platforms { "native", "x32", "x64" } 23 | end 24 | 25 | if _OPTIONS["with-zfp"] then 26 | includedirs { "./deps/ZFP/inc" } 27 | defines { "TINYEXR_USE_ZFP=1" } 28 | files { zfp_sources } 29 | end 30 | 31 | -- A project defines one build target 32 | project "tinyexrtest" 33 | kind "ConsoleApp" 34 | language "C++" 35 | files { sources } 36 | 37 | configuration "Debug" 38 | defines { "DEBUG" } -- -DDEBUG 39 | flags { "Symbols" } 40 | targetname "test_tinyexr_debug" 41 | 42 | configuration "Release" 43 | -- defines { "NDEBUG" } -- -NDEBUG 44 | flags { "Symbols", "Optimize" } 45 | targetname "test_tinyexr" 46 | -------------------------------------------------------------------------------- /dependencies/tinyexr/tinyexr.cc: -------------------------------------------------------------------------------- 1 | #define TINYEXR_IMPLEMENTATION 2 | #include "tinyexr.h" 3 | -------------------------------------------------------------------------------- /dependencies/tinyexr/vcbuild.bat: -------------------------------------------------------------------------------- 1 | rem Run 2 | rem 3 | rem > python.py kuroga.py config-msvc.py 4 | rem 5 | rem before to generate build.ninja 6 | rem 7 | 8 | chcp 437 9 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64 10 | ninja 11 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2012-2019 Syoyo Fujita and many contributors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | ---------------------------------- 24 | 25 | mapbox/earcut.hpp 26 | 27 | ISC License 28 | 29 | Copyright (c) 2015, Mapbox 30 | 31 | Permission to use, copy, modify, and/or distribute this software for any purpose 32 | with or without fee is hereby granted, provided that the above copyright notice 33 | and this permission notice appear in all copies. 34 | 35 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 36 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 37 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 38 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 39 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 40 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 41 | THIS SOFTWARE. 42 | 43 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | 3 | platform: x64 4 | 5 | install: 6 | ####################################################################################### 7 | # All external dependencies are installed in C:\projects\deps 8 | ####################################################################################### 9 | - mkdir C:\projects\deps 10 | 11 | ####################################################################################### 12 | # Install Ninja 13 | ####################################################################################### 14 | - set NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.10.0/ninja-win.zip" 15 | - appveyor DownloadFile %NINJA_URL% -FileName ninja.zip 16 | - 7z x ninja.zip -oC:\projects\deps\ninja > nul 17 | - set PATH=C:\projects\deps\ninja;%PATH% 18 | - ninja --version 19 | 20 | build_script: 21 | - cd tests 22 | - vcbuild.bat 23 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/build.ninja: -------------------------------------------------------------------------------- 1 | ninja_required_version = 1.4 2 | 3 | gnubuilddir = build 4 | gnudefines = 5 | gnuincludes = -I. 6 | gnucflags = -O2 -g 7 | gnucxxflags = -O2 -g -pedantic -Wall -Wextra -Wcast-align -Wcast-qual $ 8 | -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self $ 9 | -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast $ 10 | -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion $ 11 | -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror $ 12 | -Wno-unused -fsanitize=address 13 | gnuldflags = -fsanitize=address 14 | 15 | pool link_pool 16 | depth = 1 17 | 18 | rule gnucxx 19 | command = $gnucxx -MMD -MF $out.d $gnudefines $gnuincludes $gnucxxflags $ 20 | -c $in -o $out 21 | description = CXX $out 22 | depfile = $out.d 23 | deps = gcc 24 | rule gnucc 25 | command = $gnucc -MMD -MF $out.d $gnudefines $gnuincludes $gnucflags -c $ 26 | $in -o $out 27 | description = CC $out 28 | depfile = $out.d 29 | deps = gcc 30 | rule gnulink 31 | command = $gnuld -o $out $in $libs $gnuldflags 32 | description = LINK $out 33 | pool = link_pool 34 | rule gnuar 35 | command = $gnuar rsc $out $in 36 | description = AR $out 37 | pool = link_pool 38 | rule gnustamp 39 | command = touch $out 40 | description = STAMP $out 41 | 42 | gnucxx = g++ 43 | gnucc = gcc 44 | gnuld = $gnucxx 45 | gnuar = ar 46 | 47 | build loader_example.o: gnucxx loader_example.cc 48 | 49 | 50 | build loader_example: gnulink loader_example.o 51 | build all: phony loader_example 52 | 53 | default all 54 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif(NOT "${rm_retval}" STREQUAL 0) 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | endforeach(file) 22 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/premake4.lua: -------------------------------------------------------------------------------- 1 | sources = { 2 | "loader_example.cc", 3 | } 4 | 5 | -- premake4.lua 6 | solution "TinyObjLoaderSolution" 7 | configurations { "Release", "Debug" } 8 | 9 | if (os.is("windows")) then 10 | platforms { "x32", "x64" } 11 | else 12 | platforms { "native", "x32", "x64" } 13 | end 14 | 15 | -- A project defines one build target 16 | project "tinyobjloader" 17 | kind "ConsoleApp" 18 | language "C++" 19 | files { sources } 20 | 21 | configuration "Debug" 22 | defines { "DEBUG" } -- -DDEBUG 23 | flags { "Symbols" } 24 | targetname "loader_example_debug" 25 | 26 | configuration "Release" 27 | -- defines { "NDEBUG" } -- -NDEBUG 28 | flags { "Symbols", "Optimize" } 29 | targetname "loader_example" 30 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/python/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2012-2019 Syoyo Fujita and many contributors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/python/MANIFEST.in: -------------------------------------------------------------------------------- 1 | # Copy the header file into the python/ folder. 2 | include ../tiny_obj_loader.h 3 | # Include it in the source distribution. 4 | include tiny_obj_loader.h 5 | 6 | include pyproject.toml 7 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/python/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | python setup.py build 3 | 4 | t: 5 | python sample.py 6 | 7 | .PHONY: t 8 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/python/README.md: -------------------------------------------------------------------------------- 1 | # tinyobjloader, Wavefront .obj loader 2 | 3 | `tinyobjloader` is a python wrapper for C++ wavefront .obj loader. 4 | `tinyobjloader` is rather fast and feature rich than other pure python version of .obj loader. 5 | 6 | ## Requirements 7 | 8 | * python 3.x(3.6+ recommended) 9 | * python 2.7 may work, but not officially supported. 10 | 11 | ## Install 12 | 13 | You can install `tinyobjloader` with pip. 14 | 15 | ``` 16 | $ pip install tinyobjloader 17 | ``` 18 | 19 | ## Quick tutorial 20 | 21 | ```py 22 | import sys 23 | import tinyobjloader 24 | 25 | # Create reader. 26 | reader = tinyobjloader.ObjReader() 27 | 28 | filename = "cornellbox.obj" 29 | 30 | # Load .obj(and .mtl) using default configuration 31 | ret = reader.ParseFromFile(filename) 32 | 33 | if ret == False: 34 | print("Warn:", reader.Warning()) 35 | pint("Err:", reader.Error()) 36 | print("Failed to load : ", filename) 37 | 38 | sys.exit(-1) 39 | 40 | if reader.Warning(): 41 | print("Warn:", reader.Warning()) 42 | 43 | attrib = reader.GetAttrib() 44 | print("attrib.vertices = ", len(attrib.vertices)) 45 | print("attrib.normals = ", len(attrib.normals)) 46 | print("attrib.texcoords = ", len(attrib.texcoords)) 47 | 48 | materials = reader.GetMaterials() 49 | print("Num materials: ", len(materials)) 50 | for m in materials: 51 | print(m.name) 52 | print(m.diffuse) 53 | 54 | shapes = reader.GetShapes() 55 | print("Num shapes: ", len(shapes)) 56 | for shape in shapes: 57 | print(shape.name) 58 | print("num_indices = {}".format(len(shape.mesh.indices))) 59 | 60 | ``` 61 | 62 | ## More detailed usage 63 | 64 | Please take a look at `python/sample.py` file in tinyobjloader git repo. 65 | 66 | https://github.com/syoyo/tinyobjloader/blob/master/python/sample.py 67 | 68 | ## How to build 69 | 70 | Using `cibuildwheel` is an recommended way to build a python module. 71 | See $tinyobjloader/azure-pipelines.yml for details. 72 | 73 | ### Developer build 74 | 75 | Edit `setup.py` and uncomment `Developer option` lines 76 | 77 | Assume pip is installed. 78 | 79 | ``` 80 | $ pip install pybind11 81 | $ python setup.py build 82 | ``` 83 | 84 | ## License 85 | 86 | MIT(tinyobjloader) and ISC(mapbox earcut) license. 87 | 88 | ## TODO 89 | * [ ] Writer saver 90 | 91 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/python/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "wheel", "pybind11>=2.3"] 3 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/python/sample.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import tinyobjloader 3 | 4 | filename = "../models/cornell_box.obj" 5 | 6 | 7 | reader = tinyobjloader.ObjReader() 8 | 9 | # Load .obj(and .mtl) using default configuration 10 | ret = reader.ParseFromFile(filename) 11 | 12 | # Optionally you can set custom `config` 13 | # config = tinyobj.ObjReaderConfig() 14 | # config.triangulate = False 15 | # ret = reader.ParseFromFile(filename, config) 16 | 17 | if ret == False: 18 | print("Failed to load : ", filename) 19 | print("Warn:", reader.Warning()) 20 | print("Err:", reader.Error()) 21 | sys.exit(-1) 22 | 23 | if reader.Warning(): 24 | print("Warn:", reader.Warning()) 25 | 26 | attrib = reader.GetAttrib() 27 | print("attrib.vertices = ", len(attrib.vertices)) 28 | print("attrib.normals = ", len(attrib.normals)) 29 | print("attrib.texcoords = ", len(attrib.texcoords)) 30 | 31 | # vertex data must be `xyzxyzxyz...` 32 | assert len(attrib.vertices) % 3 == 0 33 | 34 | # normal data must be `xyzxyzxyz...` 35 | assert len(attrib.normals) % 3 == 0 36 | 37 | # texcoords data must be `uvuvuv...` 38 | assert len(attrib.texcoords) % 2 == 0 39 | 40 | for (i, v) in enumerate(attrib.vertices): 41 | print("v[{}] = {}".format(i, v)) 42 | 43 | for (i, v) in enumerate(attrib.normals): 44 | print("vn[{}] = {}".format(i, v)) 45 | 46 | for (i, v) in enumerate(attrib.texcoords): 47 | print("vt[{}] = {}".format(i, t)) 48 | 49 | print("numpy_vertices = {}".format(attrib.numpy_vertices())) 50 | 51 | materials = reader.GetMaterials() 52 | print("Num materials: ", len(materials)) 53 | for m in materials: 54 | print(m.name) 55 | print(m.diffuse) 56 | print(m.diffuse_texname) 57 | # Partial update(array indexing) does not work 58 | # m.diffuse[1] = 1.0 59 | 60 | # Update with full object assignment works 61 | m.diffuse = [1, 2, 3] 62 | print(m.diffuse) 63 | 64 | # print(m.shininess) 65 | # print(m.illum) 66 | 67 | shapes = reader.GetShapes() 68 | print("Num shapes: ", len(shapes)) 69 | for shape in shapes: 70 | print(shape.name) 71 | print("len(num_indices) = {}".format(len(shape.mesh.indices))) 72 | for (i, idx) in enumerate(shape.mesh.indices): 73 | print("[{}] v_idx {}".format(i, idx.vertex_index)) 74 | print("[{}] vn_idx {}".format(i, idx.normal_index)) 75 | print("[{}] vt_idx {}".format(i, idx.texcoord_index)) 76 | print("numpy_indices = {}".format(shape.mesh.numpy_indices())) 77 | print("numpy_num_face_vertices = {}".format(shape.mesh.numpy_num_face_vertices())) 78 | print("numpy_material_ids = {}".format(shape.mesh.numpy_material_ids())) 79 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/python/tiny_obj_loader.cc: -------------------------------------------------------------------------------- 1 | // Use double precision for better python integration. 2 | // Need also define this in `binding.cc`(and all compilation units) 3 | #define TINYOBJLOADER_USE_DOUBLE 4 | 5 | // Use robust triangulation by using Mapbox earcut. 6 | #define TINYOBJLOADER_USE_MAPBOX_EARCUT 7 | 8 | #define TINYOBJLOADER_IMPLEMENTATION 9 | #include "tiny_obj_loader.h" 10 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/tiny_obj_loader.cc: -------------------------------------------------------------------------------- 1 | #define TINYOBJLOADER_IMPLEMENTATION 2 | #include "tiny_obj_loader.h" 3 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/tinyobjloader-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | set(TINYOBJLOADER_VERSION "@TINYOBJLOADER_VERSION@") 4 | 5 | set_and_check(TINYOBJLOADER_INCLUDE_DIRS "@PACKAGE_TINYOBJLOADER_INCLUDE_DIR@") 6 | set_and_check(TINYOBJLOADER_LIBRARY_DIRS "@PACKAGE_TINYOBJLOADER_LIBRARY_DIR@") 7 | set(TINYOBJLOADER_LIBRARIES @LIBRARY_NAME@) 8 | 9 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") 10 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/tinyobjloader.pc.in: -------------------------------------------------------------------------------- 1 | # Generated by CMake @CMAKE_VERSION@ for @PROJECT_NAME@. Any changes to this 2 | # file will be overwritten by the next CMake run. The input file was 3 | # tinyobjloader.pc.in. 4 | 5 | prefix=@CMAKE_INSTALL_PREFIX@ 6 | exec_prefix=${prefix} 7 | libdir=${prefix}/@TINYOBJLOADER_LIBRARY_DIR@ 8 | includedir=${prefix}/@TINYOBJLOADER_INCLUDE_DIR@ 9 | 10 | Name: @PROJECT_NAME@ 11 | Description: Tiny but powerful single file wavefront obj loader 12 | URL: https://syoyo.github.io/tinyobjloader/ 13 | Version: @TINYOBJLOADER_VERSION@ 14 | Libs: -L${libdir} -l@LIBRARY_NAME@ 15 | Cflags: -I${includedir} 16 | -------------------------------------------------------------------------------- /dependencies/tinyobjloader/vcsetup.bat: -------------------------------------------------------------------------------- 1 | .\\tools\\windows\\premake5.exe vs2013 2 | -------------------------------------------------------------------------------- /docs/assets/cloud_training.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/cloud_training.mp4 -------------------------------------------------------------------------------- /docs/assets/gargoyle_loop_base.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/gargoyle_loop_base.mp4 -------------------------------------------------------------------------------- /docs/assets/gargoyle_loop_base_14.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/gargoyle_loop_base_14.mp4 -------------------------------------------------------------------------------- /docs/assets/gargoyle_loop_densegrid.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/gargoyle_loop_densegrid.mp4 -------------------------------------------------------------------------------- /docs/assets/gargoyle_loop_densegrid_1res.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/gargoyle_loop_densegrid_1res.mp4 -------------------------------------------------------------------------------- /docs/assets/gargoyle_loop_frequency.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/gargoyle_loop_frequency.mp4 -------------------------------------------------------------------------------- /docs/assets/gargoyle_loop_none.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/gargoyle_loop_none.mp4 -------------------------------------------------------------------------------- /docs/assets/modsynth.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/modsynth.mp4 -------------------------------------------------------------------------------- /docs/assets/mueller2022instant.bib: -------------------------------------------------------------------------------- 1 | @article{mueller2022instant, 2 | author = {Thomas M\"uller and Alex Evans and Christoph Schied and Alexander Keller}, 3 | title = {Instant Neural Graphics Primitives with a Multiresolution Hash Encoding}, 4 | journal = {ACM Trans. Graph.}, 5 | issue_date = {July 2022}, 6 | volume = {41}, 7 | number = {4}, 8 | month = jul, 9 | year = {2022}, 10 | pages = {102:1--102:15}, 11 | articleno = {102}, 12 | numpages = {15}, 13 | url = {https://doi.org/10.1145/3528223.3530127}, 14 | doi = {10.1145/3528223.3530127}, 15 | publisher = {ACM}, 16 | address = {New York, NY, USA}, 17 | keywords = {real-time, rendering, deep learning, neural networks, path tracing, radiance caching, hashing, gpu, parallel computation, function approximation, encodings, image synthesis} 18 | } 19 | -------------------------------------------------------------------------------- /docs/assets/mueller2022instant.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/mueller2022instant.mp4 -------------------------------------------------------------------------------- /docs/assets/mueller2022instant.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/mueller2022instant.pdf -------------------------------------------------------------------------------- /docs/assets/nerf_grid_lq.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/nerf_grid_lq.mp4 -------------------------------------------------------------------------------- /docs/assets/nerfbox.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/nerfbox.jpg -------------------------------------------------------------------------------- /docs/assets/nerfboxrobot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/nerfboxrobot.jpg -------------------------------------------------------------------------------- /docs/assets/nrc_new_vs_old.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/nrc_new_vs_old.mp4 -------------------------------------------------------------------------------- /docs/assets/paper-thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/paper-thumbnail.png -------------------------------------------------------------------------------- /docs/assets/robot.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/robot.mp4 -------------------------------------------------------------------------------- /docs/assets/sdf_grid_lq.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/sdf_grid_lq.mp4 -------------------------------------------------------------------------------- /docs/assets/teaser.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/teaser.mp4 -------------------------------------------------------------------------------- /docs/assets/teaser_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/teaser_small.jpg -------------------------------------------------------------------------------- /docs/assets/tokyo_online_training_counter.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/tokyo_online_training_counter.mp4 -------------------------------------------------------------------------------- /docs/assets/twitter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets/twitter.jpg -------------------------------------------------------------------------------- /docs/assets_readme/albert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets_readme/albert.png -------------------------------------------------------------------------------- /docs/assets_readme/armadillo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets_readme/armadillo.png -------------------------------------------------------------------------------- /docs/assets_readme/cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets_readme/cloud.png -------------------------------------------------------------------------------- /docs/assets_readme/fox-representative.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets_readme/fox-representative.png -------------------------------------------------------------------------------- /docs/assets_readme/fox.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets_readme/fox.gif -------------------------------------------------------------------------------- /docs/assets_readme/fox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets_readme/fox.png -------------------------------------------------------------------------------- /docs/assets_readme/robot5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets_readme/robot5.gif -------------------------------------------------------------------------------- /docs/assets_readme/testbed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/docs/assets_readme/testbed.png -------------------------------------------------------------------------------- /include/neural-graphics-primitives/discrete_distribution.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file discrete_distribution.h 12 | * @author Thomas Müller, NVIDIA 13 | */ 14 | 15 | #pragma once 16 | 17 | NGP_NAMESPACE_BEGIN 18 | 19 | struct DiscreteDistribution { 20 | void build(std::vector weights) { 21 | float total_weight = 0; 22 | for (float w : weights) { 23 | total_weight += w; 24 | } 25 | float inv_total_weight = 1 / total_weight; 26 | 27 | float cdf_accum = 0; 28 | cdf.clear(); 29 | for (float w : weights) { 30 | float norm = w * inv_total_weight; 31 | cdf_accum += norm; 32 | pmf.emplace_back(norm); 33 | cdf.emplace_back(cdf_accum); 34 | } 35 | cdf.back() = 1.0f; // Prevent precision problems from causing overruns in the end 36 | } 37 | 38 | uint32_t sample(float val) { 39 | return std::min(binary_search(val, cdf.data(), (uint32_t)cdf.size()), (uint32_t)cdf.size()-1); 40 | } 41 | 42 | std::vector pmf; 43 | std::vector cdf; 44 | }; 45 | 46 | NGP_NAMESPACE_END 47 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/dlss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file dlss.h 12 | * @author Thomas Müller, NVIDIA 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | NGP_NAMESPACE_BEGIN 24 | 25 | class IDlss { 26 | public: 27 | virtual ~IDlss() {} 28 | 29 | virtual void run( 30 | const Eigen::Vector2i& in_resolution, 31 | bool is_hdr, 32 | float sharpening, 33 | const Eigen::Vector2f& jitter_offset, 34 | bool shall_reset 35 | ) = 0; 36 | 37 | virtual cudaSurfaceObject_t frame() = 0; 38 | virtual cudaSurfaceObject_t depth() = 0; 39 | virtual cudaSurfaceObject_t mvec() = 0; 40 | virtual cudaSurfaceObject_t exposure() = 0; 41 | virtual cudaSurfaceObject_t output() = 0; 42 | 43 | virtual Eigen::Vector2i clamp_resolution(const Eigen::Vector2i& resolution) const = 0; 44 | virtual Eigen::Vector2i out_resolution() const = 0; 45 | 46 | virtual bool is_hdr() const = 0; 47 | virtual EDlssQuality quality() const = 0; 48 | }; 49 | 50 | #ifdef NGP_VULKAN 51 | std::shared_ptr dlss_init(const Eigen::Vector2i& out_resolution); 52 | 53 | void vulkan_and_ngx_init(); 54 | size_t dlss_allocated_bytes(); 55 | void vulkan_and_ngx_destroy(); 56 | #else 57 | inline size_t dlss_allocated_bytes() { 58 | return 0; 59 | } 60 | #endif 61 | 62 | NGP_NAMESPACE_END 63 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/marching_cubes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file marching_cubes.h 12 | * @author Thomas Müller & Alex Evans, NVIDIA 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include 20 | 21 | NGP_NAMESPACE_BEGIN 22 | 23 | Eigen::Vector3i get_marching_cubes_res(uint32_t res_1d, const BoundingBox& render_aabb); 24 | 25 | void marching_cubes_gpu(cudaStream_t stream, BoundingBox render_aabb, Eigen::Matrix3f render_aabb_to_local, Eigen::Vector3i res_3d, float thresh, const tcnn::GPUMemory& density, tcnn::GPUMemory& vert_out, tcnn::GPUMemory& indices_out); 26 | 27 | // computes the average of the 1ring of all verts, as homogenous coordinates 28 | void compute_mesh_1ring(const tcnn::GPUMemory& verts, const tcnn::GPUMemory& indices, tcnn::GPUMemory& output_pos, tcnn::GPUMemory& output_normals); 29 | 30 | void compute_mesh_opt_gradients( 31 | float thresh, 32 | const tcnn::GPUMemory& verts, 33 | const tcnn::GPUMemory& vert_normals, 34 | const tcnn::GPUMemory& verts_smoothed, 35 | const tcnn::network_precision_t* densities, 36 | uint32_t input_gradient_width, 37 | const float* input_gradients, 38 | tcnn::GPUMemory& verts_gradient_out, 39 | float k_smooth_amount, 40 | float k_density_amount, 41 | float k_inflate_amount 42 | ); 43 | 44 | void save_mesh( 45 | tcnn::GPUMemory& verts, 46 | tcnn::GPUMemory& normals, 47 | tcnn::GPUMemory& colors, 48 | tcnn::GPUMemory& indices, 49 | const char* outputname, 50 | bool unwrap_it, 51 | float nerf_scale, 52 | Eigen::Vector3f nerf_offset 53 | ); 54 | 55 | #ifdef NGP_GUI 56 | void draw_mesh_gl( 57 | const tcnn::GPUMemory& verts, 58 | const tcnn::GPUMemory& normals, 59 | const tcnn::GPUMemory& cols, 60 | const tcnn::GPUMemory& indices, 61 | const Eigen::Vector2i& resolution, 62 | const Eigen::Vector2f& focal_length, 63 | const Eigen::Matrix& camera_matrix, 64 | const Eigen::Vector2f& screen_center, 65 | int mesh_render_mode 66 | ); 67 | 68 | void glCheckError(const char* file, unsigned int line); 69 | uint32_t compile_shader(bool pixel, const char* code); 70 | bool check_shader(uint32_t handle, const char* desc, bool program); 71 | #endif 72 | 73 | void save_density_grid_to_png(const tcnn::GPUMemory& density, const char* filename, Eigen::Vector3i res3d, float thresh, bool swap_y_z = true, float density_range = 4.f); 74 | 75 | void save_rgba_grid_to_png_sequence(const tcnn::GPUMemory& rgba, const char *path, Eigen::Vector3i res3d, bool swap_y_z = true); 76 | 77 | void save_rgba_grid_to_raw_file(const tcnn::GPUMemory& rgba, const char* path, Eigen::Vector3i res3d, bool swap_y_z, int cascade); 78 | 79 | NGP_NAMESPACE_END 80 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/nerf/nerf_descriptor.cuh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | NGP_NAMESPACE_BEGIN 13 | 14 | // NerfDescriptor is passed in externally and is just a lightweight reference to a NeuralRadianceField 15 | struct NerfDescriptor { 16 | ::filesystem::path snapshot_path; 17 | BoundingBox aabb; 18 | Eigen::Matrix4f transform; 19 | RenderModifiersDescriptor modifiers; 20 | float opacity; 21 | 22 | NerfDescriptor( 23 | const std::string& snapshot_path_str, 24 | const BoundingBox& aabb, 25 | const Eigen::Matrix4f& transform, 26 | const RenderModifiersDescriptor& modifiers, 27 | const float& opacity 28 | ) 29 | : snapshot_path(snapshot_path_str) 30 | , aabb(aabb) 31 | , modifiers(modifiers) 32 | , transform(transform) 33 | , opacity(opacity) 34 | {}; 35 | }; 36 | 37 | NGP_NAMESPACE_END 38 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/nerf/nerf_props.cuh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | NGP_NAMESPACE_BEGIN 13 | 14 | struct NerfProps { 15 | 16 | Eigen::Matrix4f transform; 17 | Eigen::Matrix4f itransform; 18 | uint8_t* density_grid_bitfield; 19 | uint32_t grid_size; 20 | uint32_t grid_volume; 21 | BoundingBox render_aabb; 22 | BoundingBox train_aabb; 23 | Mask3D* masks; 24 | uint32_t n_masks; 25 | float cone_angle; 26 | float min_cone_stepsize; 27 | float max_cone_stepsize; 28 | uint32_t nerf_cascades; 29 | float opacity; 30 | 31 | NerfProps(const NerfRenderProxy& nerf) 32 | : transform(nerf.transform) 33 | , itransform(nerf.itransform) 34 | , density_grid_bitfield(nerf.field.density_grid_bitfield.data()) 35 | , grid_size(nerf.field.grid_size) 36 | , grid_volume(nerf.field.get_grid_volume()) 37 | , render_aabb(nerf.aabb) 38 | , train_aabb(nerf.field.train_aabb) 39 | , masks(nerf.modifiers.masks.data()) 40 | , n_masks(nerf.modifiers.masks.size()) 41 | , cone_angle(nerf.field.cone_angle_constant) 42 | , min_cone_stepsize(nerf.field.get_min_cone_step_size()) 43 | , max_cone_stepsize(nerf.field.get_max_cone_step_size()) 44 | , nerf_cascades(nerf.field.num_cascades) 45 | , opacity(nerf.opacity) 46 | {}; 47 | 48 | }; 49 | 50 | NGP_NAMESPACE_END 51 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/nerf/nerf_render_proxy.cuh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | NGP_NAMESPACE_BEGIN 15 | 16 | // NerfRenderProxy is a reference to a neural radiance field and can be rendered multiple times in the same scene 17 | struct NerfRenderProxy { 18 | NeuralRadianceField& field; 19 | BoundingBox aabb; 20 | Eigen::Matrix4f transform; 21 | RenderModifiers modifiers; 22 | Eigen::Matrix4f itransform; 23 | float opacity; 24 | 25 | NerfRenderProxy( 26 | const NerfDescriptor& descriptor, 27 | NeuralRadianceField& nerf, 28 | const RenderModifiersDescriptor& global_modifiers 29 | ) 30 | : field(nerf) 31 | , aabb(descriptor.aabb) 32 | , transform(descriptor.transform) 33 | , itransform(descriptor.transform.inverse()) 34 | , modifiers(descriptor.modifiers, global_modifiers, itransform) 35 | , opacity(descriptor.opacity) 36 | {}; 37 | }; 38 | 39 | NGP_NAMESPACE_END 40 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/nerf/nerf_renderer.cuh: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | NGP_NAMESPACE_BEGIN 10 | 11 | struct NerfRenderer { 12 | private: 13 | RenderData m_render_data; 14 | 15 | public: 16 | 17 | void render( 18 | CudaRenderBuffer& render_buffer, 19 | RenderRequest& render_request, 20 | cudaStream_t stream 21 | ); 22 | 23 | void init_rays_from_camera( 24 | Eigen::Array4f* frame_buffer, 25 | float* depth_buffer, 26 | RenderData& render_data, 27 | cudaStream_t stream 28 | ); 29 | 30 | // returns number of rays hit 31 | uint32_t march_rays_and_accumulate_colors( 32 | RenderData& render_data, 33 | cudaStream_t stream 34 | ); 35 | 36 | }; 37 | 38 | NGP_NAMESPACE_END 39 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/nerf/nerf_utils.cuh: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | NGP_NAMESPACE_BEGIN 10 | 11 | __host__ __device__ uint32_t get_grid_mip_offset(uint32_t mip, uint32_t grid_volume); 12 | 13 | __device__ float get_distance_to_next_voxel(const Eigen::Vector3f& pos, const Eigen::Vector3f& dir, const Eigen::Vector3f& idir, uint32_t res); 14 | 15 | __host__ __device__ float get_dt(float t, float cone_angle, float min_cone_stepsize, float max_cone_stepsize); 16 | 17 | __device__ float get_t_advanced_to_next_voxel(float t, float cone_angle, const Eigen::Vector3f& pos, const Eigen::Vector3f& dir, const Eigen::Vector3f& idir, uint32_t res, float min_cone_stepsize, float max_cone_stepsize); 18 | 19 | __device__ float get_network_rgb(float val, ENerfActivation activation); 20 | 21 | __device__ float get_network_rgb_derivative(float val, ENerfActivation activation); 22 | 23 | __device__ float get_network_density(float val, ENerfActivation activation); 24 | 25 | __device__ float get_network_density_derivative(float val, ENerfActivation activation); 26 | 27 | __device__ Eigen::Array3f get_network_rgb(const tcnn::vector_t& local_network_output, ENerfActivation activation); 28 | 29 | __device__ Eigen::Vector3f get_warped_pos(const Eigen::Vector3f& pos, const BoundingBox& aabb); 30 | 31 | __device__ Eigen::Vector3f get_unwarped_pos(const Eigen::Vector3f& pos, const BoundingBox& aabb); 32 | 33 | __device__ Eigen::Vector3f get_unwarped_pos_derivative(const Eigen::Vector3f& pos, const BoundingBox& aabb); 34 | 35 | __device__ Eigen::Vector3f get_warped_pos_derivative(const Eigen::Vector3f& pos, const BoundingBox& aabb); 36 | 37 | __host__ __device__ Eigen::Vector3f get_warped_dir(const Eigen::Vector3f& dir); 38 | 39 | __device__ Eigen::Vector3f get_unwarped_dir(const Eigen::Vector3f& dir); 40 | 41 | __device__ Eigen::Vector3f get_warped_dir_derivative(const Eigen::Vector3f& dir); 42 | 43 | __device__ Eigen::Vector3f get_unwarped_dir_derivative(const Eigen::Vector3f& dir); 44 | 45 | __device__ int get_mip_from_pos(const Eigen::Vector3f& pos, uint32_t max_cascade); 46 | 47 | __device__ int get_mip_from_dt(float dt, const Eigen::Vector3f& pos, uint32_t grid_size, uint32_t max_cascade); 48 | 49 | __device__ float get_warped_dt(float dt, float min_cone_stepsize, uint32_t nerf_cascades); 50 | 51 | __device__ float get_unwarped_dt(float dt, float min_cone_stepsize, uint32_t nerf_cascades); 52 | 53 | __device__ uint32_t get_cascaded_grid_idx_at(Eigen::Vector3f pos, uint32_t mip, uint32_t grid_size); 54 | 55 | __device__ bool get_is_density_grid_occupied_at(const Eigen::Vector3f& pos, const uint8_t* density_grid_bitfield, uint32_t mip, uint32_t grid_size, uint32_t grid_volume); 56 | 57 | __device__ float get_cascaded_grid_at(Eigen::Vector3f pos, const float* cascaded_grid, uint32_t mip, uint32_t grid_volume); 58 | 59 | __device__ float& get_cascaded_grid_at(Eigen::Vector3f pos, float* cascaded_grid, uint32_t mip, uint32_t grid_volume); 60 | 61 | NGP_NAMESPACE_END 62 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/nerf/render_data.cuh: -------------------------------------------------------------------------------- 1 | /** @file render_data.cuh 2 | * 3 | * @author James Perlman, avid instant-ngp fan 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | NGP_NAMESPACE_BEGIN 22 | 23 | struct RenderData { 24 | private: 25 | 26 | std::vector _nerfs; 27 | std::vector _proxies; 28 | 29 | public: 30 | 31 | RenderOutputProperties output; 32 | RenderCameraProperties camera; 33 | RenderDataWorkspace workspace; 34 | tcnn::GPUMemory nerf_props; 35 | 36 | RenderData() {}; 37 | 38 | void update(const RenderRequest& request) { 39 | output = request.output; 40 | camera = request.camera; 41 | update_nerfs(request.nerfs, request.modifiers); 42 | } 43 | 44 | void update_nerfs(const std::vector& descriptors, const RenderModifiersDescriptor& global_modifiers) { 45 | // delete if nerf has no matching descriptor 46 | static_cast( // discard result from remove_if iterator 47 | std::remove_if(_nerfs.begin(), _nerfs.end(), [&](const NeuralRadianceField& nerf) { 48 | auto result = std::find_if(descriptors.begin(), descriptors.end(), [&](const NerfDescriptor& descriptor) { 49 | return descriptor.snapshot_path == nerf.snapshot_path; 50 | }); 51 | // if result was not found, remove this nerf 52 | return result == descriptors.end(); 53 | }) 54 | ); 55 | 56 | // add new nerfs 57 | for (const NerfDescriptor& desc : descriptors) { 58 | auto result = std::find_if(_nerfs.begin(), _nerfs.end(), [&](const NeuralRadianceField& nerf) { 59 | return nerf.snapshot_path == desc.snapshot_path; 60 | }); 61 | if (result == _nerfs.end()) { 62 | _nerfs.emplace_back(desc); 63 | } 64 | } 65 | 66 | // update render proxies 67 | _proxies.clear(); 68 | 69 | 70 | for (const NerfDescriptor& desc : descriptors) { 71 | auto nerf = std::find_if(_nerfs.begin(), _nerfs.end(), [&](const NeuralRadianceField& nerf) { 72 | return nerf.snapshot_path == desc.snapshot_path; 73 | }); 74 | 75 | if (nerf == _nerfs.end()) { 76 | printf("Somehow a nerf was not found for this descriptor. Something is very, very wrong.\n"); 77 | continue; 78 | } 79 | 80 | _proxies.emplace_back(desc, *nerf, global_modifiers); 81 | } 82 | } 83 | 84 | void copy_from_host() { 85 | std::vector _nerf_props; 86 | _nerf_props.reserve(_nerfs.size()); 87 | for (NerfRenderProxy& proxy : _proxies) { 88 | proxy.field.load_snapshot(); 89 | proxy.modifiers.copy_from_host(); 90 | _nerf_props.emplace_back(proxy); 91 | } 92 | nerf_props.resize_and_copy_from_host(_nerf_props); 93 | } 94 | 95 | std::vector& get_renderables() { 96 | return _proxies; 97 | } 98 | }; 99 | 100 | NGP_NAMESPACE_END 101 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/nerf/render_modifiers_descriptor.cuh: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | NGP_NAMESPACE_BEGIN 10 | 11 | struct RenderModifiersDescriptor { 12 | std::vector masks; 13 | // todo: 14 | // std::vector distortion_fields; 15 | }; 16 | 17 | NGP_NAMESPACE_END -------------------------------------------------------------------------------- /include/neural-graphics-primitives/nerf_kernels.cuh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/include/neural-graphics-primitives/nerf_kernels.cuh -------------------------------------------------------------------------------- /include/neural-graphics-primitives/sdf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file sdf.h 12 | * @author Thomas Müller & Alex Evans, NVIDIA 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include 20 | 21 | NGP_NAMESPACE_BEGIN 22 | 23 | struct SdfPayload { 24 | Eigen::Vector3f dir; 25 | uint32_t idx; 26 | uint16_t n_steps; 27 | bool alive; 28 | }; 29 | 30 | struct RaysSdfSoa { 31 | #ifdef __NVCC__ 32 | void enlarge(size_t n_elements) { 33 | pos.enlarge(n_elements); 34 | normal.enlarge(n_elements); 35 | distance.enlarge(n_elements); 36 | prev_distance.enlarge(n_elements); 37 | total_distance.enlarge(n_elements); 38 | min_visibility.enlarge(n_elements); 39 | payload.enlarge(n_elements); 40 | } 41 | 42 | void copy_from_other_async(uint32_t n_elements, const RaysSdfSoa& other, cudaStream_t stream) { 43 | CUDA_CHECK_THROW(cudaMemcpyAsync(pos.data(), other.pos.data(), n_elements * sizeof(Eigen::Vector3f), cudaMemcpyDeviceToDevice, stream)); 44 | CUDA_CHECK_THROW(cudaMemcpyAsync(normal.data(), other.normal.data(), n_elements * sizeof(Eigen::Vector3f), cudaMemcpyDeviceToDevice, stream)); 45 | CUDA_CHECK_THROW(cudaMemcpyAsync(distance.data(), other.distance.data(), n_elements * sizeof(float), cudaMemcpyDeviceToDevice, stream)); 46 | CUDA_CHECK_THROW(cudaMemcpyAsync(prev_distance.data(), other.prev_distance.data(), n_elements * sizeof(float), cudaMemcpyDeviceToDevice, stream)); 47 | CUDA_CHECK_THROW(cudaMemcpyAsync(total_distance.data(), other.total_distance.data(), n_elements * sizeof(float), cudaMemcpyDeviceToDevice, stream)); 48 | CUDA_CHECK_THROW(cudaMemcpyAsync(min_visibility.data(), other.min_visibility.data(), n_elements * sizeof(float), cudaMemcpyDeviceToDevice, stream)); 49 | CUDA_CHECK_THROW(cudaMemcpyAsync(payload.data(), other.payload.data(), n_elements * sizeof(SdfPayload), cudaMemcpyDeviceToDevice, stream)); 50 | } 51 | #endif 52 | tcnn::GPUMemory pos; 53 | tcnn::GPUMemory normal; 54 | tcnn::GPUMemory distance; 55 | tcnn::GPUMemory prev_distance; 56 | tcnn::GPUMemory total_distance; 57 | tcnn::GPUMemory min_visibility; 58 | tcnn::GPUMemory payload; 59 | }; 60 | 61 | struct BRDFParams { 62 | float metallic=0.f; 63 | float subsurface=0.f; 64 | float specular=1.f; 65 | float roughness=0.5f; 66 | float sheen=0.f; 67 | float clearcoat=0.f; 68 | float clearcoat_gloss=0.f; 69 | Eigen::Vector3f basecolor=Eigen::Vector3f(0.8f,0.8f,0.8f); 70 | Eigen::Vector3f ambientcolor=Eigen::Vector3f(0.f,0.f,0.f); 71 | }; 72 | 73 | NGP_NAMESPACE_END 74 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/shared_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | // This file was taken from the tev image viewer and is re-released here 12 | // under the NVIDIA Source Code License with permission from the author. 13 | 14 | #pragma once 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | NGP_NAMESPACE_BEGIN 21 | 22 | class ICallable { 23 | public: 24 | virtual ~ICallable() {} 25 | virtual void operator()() = 0; 26 | }; 27 | 28 | template 29 | class Callable : public ICallable { 30 | public: 31 | Callable() = default; 32 | Callable(const T& callable) : m_callable{callable} {} 33 | Callable(T&& callable) : m_callable{std::forward(callable)} {} 34 | Callable(const Callable& other) = delete; 35 | Callable& operator=(Callable&& other) { std::swap(m_callable, other.m_callable); return *this; } 36 | Callable(Callable&& other) { *this = std::move(other); } 37 | 38 | void operator()() override { 39 | m_callable(); 40 | } 41 | private: 42 | T m_callable; 43 | }; 44 | 45 | template 46 | std::unique_ptr callable(T&& callable) { 47 | return std::make_unique>(std::forward(callable)); 48 | } 49 | 50 | class SharedQueueEmptyException {}; 51 | 52 | template 53 | class SharedQueue { 54 | public: 55 | bool empty() const { 56 | std::lock_guard lock{mMutex}; 57 | return mRawQueue.empty(); 58 | } 59 | 60 | size_t size() const { 61 | std::lock_guard lock{mMutex}; 62 | return mRawQueue.size(); 63 | } 64 | 65 | void push(T&& newElem) { 66 | std::lock_guard lock{mMutex}; 67 | mRawQueue.emplace_back(std::forward(newElem)); 68 | mDataCondition.notify_one(); 69 | } 70 | 71 | void clear() { 72 | std::lock_guard lock{mMutex}; 73 | mRawQueue.clear(); 74 | } 75 | 76 | void clearAndPush(T&& newElem) { 77 | std::lock_guard lock{mMutex}; 78 | mRawQueue.clear(); 79 | mRawQueue.emplace_back(std::forward(newElem)); 80 | mDataCondition.notify_one(); 81 | } 82 | 83 | T waitAndPop() { 84 | std::unique_lock lock{mMutex}; 85 | 86 | while (mRawQueue.empty()) { 87 | mDataCondition.wait(lock); 88 | } 89 | 90 | T result = std::move(mRawQueue.front()); 91 | mRawQueue.pop_front(); 92 | 93 | return result; 94 | } 95 | 96 | T tryPop(bool back = false) { 97 | std::unique_lock lock{mMutex}; 98 | 99 | if (mRawQueue.empty()) { 100 | throw SharedQueueEmptyException{}; 101 | } 102 | 103 | if (back) { 104 | T result = std::move(mRawQueue.back()); 105 | mRawQueue.pop_back(); 106 | return result; 107 | } else { 108 | T result = std::move(mRawQueue.front()); 109 | mRawQueue.pop_front(); 110 | return result; 111 | } 112 | } 113 | 114 | private: 115 | std::deque mRawQueue; 116 | mutable std::mutex mMutex; 117 | std::condition_variable mDataCondition; 118 | }; 119 | 120 | NGP_NAMESPACE_END 121 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/tinyexr_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file tinyexr_wrapper.h 12 | * @author Thomas Müller, NVIDIA 13 | * @brief Wrapper around the tinyexr library, providing a simple interface 14 | * to load and store EXR images. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | NGP_NAMESPACE_BEGIN 22 | 23 | void save_exr(const float* data, int width, int height, int nChannels, int channelStride, const char* outfilename); 24 | void load_exr(float** data, int* width, int* height, const char* filename); 25 | __half* load_exr_to_gpu(int* width, int* height, const char* filename, bool fix_premult); 26 | 27 | NGP_NAMESPACE_END 28 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/tinyobj_loader_wrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file tinyobj_loader_wrapper.h 12 | * @author Thomas Müller, NVIDIA 13 | * @brief Wrapper around the tinyobj_loader library, providing a simple 14 | * interface to load OBJ-based meshes. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | NGP_NAMESPACE_BEGIN 25 | 26 | std::vector load_obj(const std::string& filename); 27 | 28 | NGP_NAMESPACE_END 29 | -------------------------------------------------------------------------------- /include/neural-graphics-primitives/triangle_bvh.cuh: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file triangle_bvh.cuh 12 | * @author Thomas Müller & Alex Evans, NVIDIA 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | 26 | NGP_NAMESPACE_BEGIN 27 | 28 | struct TriangleBvhNode { 29 | BoundingBox bb; 30 | int left_idx; // negative values indicate leaves 31 | int right_idx; 32 | }; 33 | 34 | template 35 | class FixedStack { 36 | public: 37 | __host__ __device__ void push(T val) { 38 | if (m_count >= MAX_SIZE-1) { 39 | printf("WARNING TOO BIG\n"); 40 | } 41 | m_elems[m_count++] = val; 42 | } 43 | 44 | __host__ __device__ T pop() { 45 | return m_elems[--m_count]; 46 | } 47 | 48 | __host__ __device__ bool empty() const { 49 | return m_count <= 0; 50 | } 51 | 52 | private: 53 | T m_elems[MAX_SIZE]; 54 | int m_count = 0; 55 | }; 56 | 57 | using FixedIntStack = FixedStack; 58 | 59 | 60 | __host__ __device__ std::pair trianglebvh_ray_intersect(const Eigen::Vector3f& ro, const Eigen::Vector3f& rd, const TriangleBvhNode* __restrict__ bvhnodes, const Triangle* __restrict__ triangles); 61 | 62 | class TriangleBvh { 63 | public: 64 | virtual void signed_distance_gpu(uint32_t n_elements, EMeshSdfMode mode, const Eigen::Vector3f* gpu_positions, float* gpu_distances, const Triangle* gpu_triangles, bool use_existing_distances_as_upper_bounds, cudaStream_t stream) = 0; 65 | virtual void ray_trace_gpu(uint32_t n_elements, Eigen::Vector3f* gpu_positions, Eigen::Vector3f* gpu_directions, const Triangle* gpu_triangles, cudaStream_t stream) = 0; 66 | virtual bool touches_triangle(const BoundingBox& bb, const Triangle* __restrict__ triangles) const = 0; 67 | virtual void build(std::vector& triangles, uint32_t n_primitives_per_leaf) = 0; 68 | virtual void build_optix(const tcnn::GPUMemory& triangles, cudaStream_t stream) = 0; 69 | 70 | static std::unique_ptr make(); 71 | 72 | TriangleBvhNode* nodes_gpu() const { 73 | return m_nodes_gpu.data(); 74 | } 75 | 76 | protected: 77 | std::vector m_nodes; 78 | tcnn::GPUMemory m_nodes_gpu; 79 | TriangleBvh() {}; 80 | }; 81 | 82 | NGP_NAMESPACE_END 83 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | commentjson~=0.9.0 2 | imageio~=2.16.0 3 | numpy~=1.21.2 4 | pybind11~=2.7.1 5 | scipy~=1.7.1 6 | tqdm~=4.62.2 7 | opencv-python~=4.5.5.62 8 | -------------------------------------------------------------------------------- /scripts/convert_image.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. 4 | # 5 | # NVIDIA CORPORATION and its licensors retain all intellectual property 6 | # and proprietary rights in and to this software, related documentation 7 | # and any modifications thereto. Any use, reproduction, disclosure or 8 | # distribution of this software and related documentation without an express 9 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 10 | 11 | import argparse 12 | import common 13 | import numpy as np 14 | import os 15 | import PIL 16 | 17 | def parse_args(): 18 | parser = argparse.ArgumentParser(description="Convert image into a different format. By default, converts to our binary fp16 '.bin' format, which helps quickly load large images.") 19 | parser.add_argument("--input", default="", help="Path to the image to convert.") 20 | parser.add_argument("--output", default="", help="Path to the output. Defaults to .bin") 21 | args = parser.parse_args() 22 | return args 23 | 24 | if __name__ == "__main__": 25 | args = parse_args() 26 | PIL.Image.MAX_IMAGE_PIXELS = 10000000000 27 | print(f"Loading {args.input}") 28 | img = common.read_image(args.input) 29 | print(f"{img.shape[1]}x{img.shape[0]} pixels, {img.shape[2]} channels") 30 | 31 | if not args.output: 32 | output = os.path.splitext(args.input)[0] + ".bin" 33 | else: 34 | output = args.output 35 | 36 | print(f"Writing {output}") 37 | common.write_image(output, img.astype(np.float16)) 38 | -------------------------------------------------------------------------------- /scripts/flip/main.py: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # * Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # * Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in the 11 | # documentation and/or other materials provided with the distribution. 12 | # * Neither the name of NVIDIA CORPORATION nor the names of its 13 | # contributors may be used to endorse or promote products derived 14 | # from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 17 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | ######################################################################### 28 | 29 | # FLIP: A Difference Evaluator for Alternating Images 30 | # High Performance Graphics, 2020. 31 | # by Pontus Andersson, Jim Nilsson, Tomas Akenine-Moller, Magnus Oskarsson, Kalle Astrom, and Mark D. Fairchild 32 | # 33 | # Pointer to our paper: https://research.nvidia.com/publication/2020-07_FLIP 34 | # code by Pontus Andersson, Jim Nilsson, and Tomas Akenine-Moller 35 | 36 | import numpy as np 37 | 38 | from flip import compute_flip 39 | from utils import * 40 | 41 | if __name__ == '__main__': 42 | # Set viewing conditions 43 | monitor_distance = 0.7 44 | monitor_width = 0.7 45 | monitor_resolution_x = 3840 46 | 47 | # Compute number of pixels per degree of visual angle 48 | pixels_per_degree = monitor_distance * (monitor_resolution_x / monitor_width) * (np.pi / 180) 49 | 50 | # Load sRGB images 51 | reference = load_image_array('../images/reference.png') 52 | test = load_image_array('../images/test.png') 53 | 54 | # Compute FLIP map 55 | deltaE = compute_flip(reference, test, pixels_per_degree) 56 | 57 | # Save error map 58 | index_map = np.floor(255.0 * deltaE.squeeze(0)) 59 | 60 | use_color_map = True 61 | if use_color_map: 62 | result = CHWtoHWC(index2color(index_map, get_magma_map())) 63 | else: 64 | result = index_map / 255.0 65 | save_image("../images/flip.png", result) 66 | print("Done") 67 | -------------------------------------------------------------------------------- /src/common_device.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file common_device.cu 12 | * @author Thomas Müller, NVIDIA 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | 22 | using namespace Eigen; 23 | using namespace tcnn; 24 | 25 | NGP_NAMESPACE_BEGIN 26 | 27 | 28 | Matrix log_space_lerp(const Matrix& begin, const Matrix& end, float t) { 29 | Matrix4f A = Matrix4f::Identity(); 30 | A.block<3,4>(0,0) = begin; 31 | Matrix4f B = Matrix4f::Identity(); 32 | B.block<3,4>(0,0) = end; 33 | 34 | Matrix4f log_space_a_to_b = (B * A.inverse()).log(); 35 | 36 | return ((log_space_a_to_b * t).exp() * A).block<3,4>(0,0); 37 | } 38 | 39 | GPUMemory load_exr(const std::string& filename, int& width, int& height) { 40 | float* out; // width * height * RGBA 41 | load_exr(&out, &width, &height, filename.c_str()); 42 | ScopeGuard mem_guard{[&]() { free(out); }}; 43 | 44 | GPUMemory result(width * height * 4); 45 | result.copy_from_host(out); 46 | return result; 47 | } 48 | 49 | GPUMemory load_stbi(const std::string& filename, int& width, int& height) { 50 | bool is_hdr = stbi_is_hdr(filename.c_str()); 51 | 52 | void* data; // width * height * RGBA 53 | int comp; 54 | if (is_hdr) { 55 | data = stbi_loadf(filename.c_str(), &width, &height, &comp, 4); 56 | } else { 57 | data = stbi_load(filename.c_str(), &width, &height, &comp, 4); 58 | } 59 | 60 | if (!data) { 61 | throw std::runtime_error{std::string{stbi_failure_reason()}}; 62 | } 63 | 64 | ScopeGuard mem_guard{[&]() { stbi_image_free(data); }}; 65 | 66 | if (width == 0 || height == 0) { 67 | throw std::runtime_error{"Image has zero pixels."}; 68 | } 69 | 70 | GPUMemory result(width * height * 4); 71 | if (is_hdr) { 72 | result.copy_from_host((float*)data); 73 | } else { 74 | GPUMemory bytes(width * height * 4); 75 | bytes.copy_from_host((uint8_t*)data); 76 | linear_kernel(from_rgba32, 0, nullptr, width * height, bytes.data(), result.data(), false, false, 0); 77 | } 78 | 79 | return result; 80 | } 81 | 82 | NGP_NAMESPACE_END 83 | -------------------------------------------------------------------------------- /src/nerf_data.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | NGP_NAMESPACE_BEGIN 8 | 9 | __global__ void nerf_grid_to_bitfield( 10 | const uint32_t n_elements, 11 | const uint32_t n_nonzero_elements, 12 | const float* __restrict__ grid, 13 | uint8_t* __restrict__ grid_bitfield, 14 | const float* __restrict__ mean_density_ptr, 15 | const float min_optical_thickness 16 | ) { 17 | const uint32_t i = threadIdx.x + blockIdx.x * blockDim.x; 18 | if (i >= n_elements) return; 19 | if (i >= n_nonzero_elements) { 20 | grid_bitfield[i] = 0; 21 | return; 22 | } 23 | 24 | uint8_t bits = 0; 25 | 26 | float thresh = std::min(min_optical_thickness, *mean_density_ptr); 27 | 28 | NGP_PRAGMA_UNROLL 29 | for (uint8_t j = 0; j < 8; ++j) { 30 | bits |= grid[i*8+j] > thresh ? ((uint8_t)1 << j) : 0; 31 | } 32 | 33 | grid_bitfield[i] = bits; 34 | } 35 | 36 | __global__ void nerf_bitfield_max_pool( 37 | const uint32_t n_elements, 38 | const uint32_t grid_size, 39 | const uint8_t* __restrict__ prev_level, 40 | uint8_t* __restrict__ next_level 41 | ) { 42 | const uint32_t i = threadIdx.x + blockIdx.x * blockDim.x; 43 | if (i >= n_elements) return; 44 | 45 | uint8_t bits = 0; 46 | 47 | NGP_PRAGMA_UNROLL 48 | for (uint8_t j = 0; j < 8; ++j) { 49 | // If any bit is set in the previous level, set this 50 | // level's bit. (Max pooling.) 51 | bits |= prev_level[i*8+j] > 0 ? ((uint8_t)1 << j) : 0; 52 | } 53 | 54 | uint32_t x = tcnn::morton3D_invert(i>>0) + grid_size/8; 55 | uint32_t y = tcnn::morton3D_invert(i>>1) + grid_size/8; 56 | uint32_t z = tcnn::morton3D_invert(i>>2) + grid_size/8; 57 | 58 | next_level[tcnn::morton3D(x, y, z)] |= bits; 59 | } 60 | 61 | void NeuralRadianceField::update_density_grid_mean_and_bitfield(cudaStream_t stream) { 62 | const uint32_t n_elements = get_grid_volume(); 63 | 64 | size_t size_including_mips = grid_mip_offset(num_cascades) / 8; 65 | density_grid_bitfield.enlarge(size_including_mips); 66 | density_grid_mean.enlarge(tcnn::reduce_sum_workspace_size(n_elements)); 67 | 68 | CUDA_CHECK_THROW(cudaMemsetAsync(density_grid_mean.data(), 0, sizeof(float), stream)); 69 | tcnn::reduce_sum(density_grid.data(), [n_elements] __device__ (float val) { return fmaxf(val, 0.f) / (n_elements); }, density_grid_mean.data(), n_elements, stream); 70 | 71 | tcnn::linear_kernel(nerf_grid_to_bitfield, 0, stream, 72 | n_elements/8 * num_cascades, 73 | n_elements/8 * (max_cascade + 1), 74 | density_grid.data(), 75 | density_grid_bitfield.data(), 76 | density_grid_mean.data(), 77 | min_optical_thickness 78 | ); 79 | 80 | for (uint32_t level = 1; level < num_cascades; ++level) { 81 | tcnn::linear_kernel(nerf_bitfield_max_pool, 0, stream, 82 | n_elements/64, 83 | grid_size, 84 | get_density_grid_bitfield_mip(level-1), 85 | get_density_grid_bitfield_mip(level) 86 | ); 87 | } 88 | } 89 | 90 | NGP_NAMESPACE_END 91 | -------------------------------------------------------------------------------- /src/nerf_trainer.cu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JamesPerlman/blender-ngp/e2e0000ba95aa5f4e5bdfb5ed249bebf6528f33a/src/nerf_trainer.cu -------------------------------------------------------------------------------- /src/optix/pathescape.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file pathescape.h 12 | * @author Thomas Müller, NVIDIA 13 | * @brief Minimal optix program. 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | NGP_NAMESPACE_BEGIN 24 | 25 | struct PathEscape { 26 | struct Params { 27 | const Eigen::Vector3f* ray_origins; 28 | const Triangle* triangles; 29 | float* distances; 30 | OptixTraversableHandle handle; 31 | }; 32 | 33 | struct RayGenData {}; 34 | struct MissData {}; 35 | struct HitGroupData {}; 36 | }; 37 | 38 | NGP_NAMESPACE_END 39 | -------------------------------------------------------------------------------- /src/optix/raystab.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file raystab.cu 12 | * @author Thomas Müller, NVIDIA 13 | * @brief Minimal optix program. 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #include "raystab.h" 22 | 23 | using namespace Eigen; 24 | using namespace tcnn; 25 | 26 | NGP_NAMESPACE_BEGIN 27 | 28 | extern "C" { 29 | __constant__ Raystab::Params params; 30 | } 31 | 32 | extern "C" __global__ void __raygen__rg() { 33 | const uint3 idx = optixGetLaunchIndex(); 34 | const uint3 dim = optixGetLaunchDimensions(); 35 | 36 | Vector3f ray_origin = params.ray_origins[idx.x]; 37 | 38 | default_rng_t rng; 39 | rng.advance(idx.x * 2); 40 | Vector2f offset = random_val_2d(rng); 41 | 42 | static constexpr uint32_t N_STAB_RAYS = 32; 43 | for (uint32_t i = 0; i < N_STAB_RAYS; ++i) { 44 | // Use a Fibonacci lattice (with random offset) to regularly 45 | // distribute the stab rays over the sphere. 46 | Vector3f ray_direction = fibonacci_dir(i, offset); 47 | 48 | // Trace the stab ray against our scene hierarchy 49 | unsigned int p0; 50 | optixTrace( 51 | params.handle, 52 | to_float3(ray_origin), 53 | to_float3(ray_direction), 54 | 0.0f, // Min intersection distance 55 | 1e16f, // Max intersection distance 56 | 0.0f, // rayTime 57 | OptixVisibilityMask(255), // Specify always visible 58 | OPTIX_RAY_FLAG_TERMINATE_ON_FIRST_HIT | OPTIX_RAY_FLAG_DISABLE_ANYHIT, 59 | 0, // SBT offset 60 | 1, // SBT stride 61 | 0, // missSBTIndex 62 | p0 63 | ); 64 | 65 | if (p0 == 0) { 66 | // One ray escaped. We are outside. Distance doesn't need to be signed. 67 | return; 68 | } 69 | } 70 | 71 | params.distances[idx.x] = -params.distances[idx.x]; 72 | } 73 | 74 | extern "C" __global__ void __miss__ms() { 75 | optixSetPayload_0(0); 76 | } 77 | 78 | extern "C" __global__ void __closesthit__ch() { 79 | optixSetPayload_0(1); 80 | } 81 | 82 | NGP_NAMESPACE_END 83 | -------------------------------------------------------------------------------- /src/optix/raystab.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file raystab.h 12 | * @author Thomas Müller, NVIDIA 13 | * @brief Minimal optix program. 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | #include 21 | 22 | NGP_NAMESPACE_BEGIN 23 | 24 | struct Raystab { 25 | struct Params { 26 | const Eigen::Vector3f* ray_origins; 27 | float* distances; 28 | OptixTraversableHandle handle; 29 | }; 30 | 31 | struct RayGenData {}; 32 | struct MissData {}; 33 | struct HitGroupData {}; 34 | }; 35 | 36 | NGP_NAMESPACE_END 37 | -------------------------------------------------------------------------------- /src/optix/raytrace.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file raytrace.cu 12 | * @author Thomas Müller, NVIDIA 13 | * @brief Minimal optix program. 14 | */ 15 | 16 | #include 17 | 18 | #include "raytrace.h" 19 | #include 20 | 21 | using namespace Eigen; 22 | 23 | NGP_NAMESPACE_BEGIN 24 | 25 | extern "C" { 26 | __constant__ Raytrace::Params params; 27 | } 28 | 29 | extern "C" __global__ void __raygen__rg() { 30 | const uint3 idx = optixGetLaunchIndex(); 31 | const uint3 dim = optixGetLaunchDimensions(); 32 | 33 | Vector3f ray_origin = params.ray_origins[idx.x]; 34 | Vector3f ray_direction = params.ray_directions[idx.x]; 35 | 36 | unsigned int p0, p1; 37 | optixTrace( 38 | params.handle, 39 | to_float3(ray_origin), 40 | to_float3(ray_direction), 41 | 0.0f, // Min intersection distance 42 | 1e16f, // Max intersection distance 43 | 0.0f, // rayTime -- used for motion blur 44 | OptixVisibilityMask(255), // Specify always visible 45 | OPTIX_RAY_FLAG_DISABLE_ANYHIT, 46 | 0, // SBT offset 47 | 1, // SBT stride 48 | 0, // missSBTIndex 49 | p0, p1 50 | ); 51 | 52 | // Hit position 53 | float t = __int_as_float(p1); 54 | params.ray_origins[idx.x] = ray_origin + t * ray_direction; 55 | 56 | // If a triangle was hit, p0 is its index, otherwise p0 is -1. 57 | // Write out the triangle's normal if it (abuse the direction buffer). 58 | if ((int)p0 == -1) { 59 | return; 60 | } 61 | 62 | params.ray_directions[idx.x] = params.triangles[p0].normal(); 63 | } 64 | 65 | extern "C" __global__ void __miss__ms() { 66 | optixSetPayload_0((uint32_t)-1); 67 | optixSetPayload_1(__float_as_int(optixGetRayTmax())); 68 | } 69 | 70 | extern "C" __global__ void __closesthit__ch() { 71 | optixSetPayload_0(optixGetPrimitiveIndex()); 72 | optixSetPayload_1(__float_as_int(optixGetRayTmax())); 73 | } 74 | 75 | NGP_NAMESPACE_END 76 | -------------------------------------------------------------------------------- /src/optix/raytrace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file raytrace.h 12 | * @author Thomas Müller, NVIDIA 13 | * @brief Minimal optix program. 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | NGP_NAMESPACE_BEGIN 24 | 25 | struct Raytrace { 26 | struct Params { 27 | Eigen::Vector3f* ray_origins; 28 | Eigen::Vector3f* ray_directions; 29 | const Triangle* triangles; 30 | OptixTraversableHandle handle; 31 | }; 32 | 33 | struct RayGenData {}; 34 | struct MissData {}; 35 | struct HitGroupData {}; 36 | }; 37 | 38 | NGP_NAMESPACE_END 39 | -------------------------------------------------------------------------------- /src/thread_pool.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | // This file was taken from the tev image viewer and is re-released here 12 | // under the NVIDIA Source Code License with permission from the author. 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | NGP_NAMESPACE_BEGIN 20 | 21 | using namespace std; 22 | 23 | ThreadPool::ThreadPool() 24 | : ThreadPool{thread::hardware_concurrency()} {} 25 | 26 | ThreadPool::ThreadPool(size_t maxNumThreads, bool force) { 27 | if (!force) { 28 | maxNumThreads = min((size_t)thread::hardware_concurrency(), maxNumThreads); 29 | } 30 | startThreads(maxNumThreads); 31 | mNumTasksInSystem.store(0); 32 | } 33 | 34 | ThreadPool::~ThreadPool() { 35 | shutdownThreads(mThreads.size()); 36 | } 37 | 38 | void ThreadPool::startThreads(size_t num) { 39 | mNumThreads += num; 40 | for (size_t i = mThreads.size(); i < mNumThreads; ++i) { 41 | mThreads.emplace_back([this, i] { 42 | while (true) { 43 | unique_lock lock{mTaskQueueMutex}; 44 | 45 | // look for a work item 46 | while (i < mNumThreads && mTaskQueue.empty()) { 47 | // if there are none wait for notification 48 | mWorkerCondition.wait(lock); 49 | } 50 | 51 | if (i >= mNumThreads) { 52 | break; 53 | } 54 | 55 | function task{move(mTaskQueue.front())}; 56 | mTaskQueue.pop_front(); 57 | 58 | // Unlock the lock, so we can process the task without blocking other threads 59 | lock.unlock(); 60 | 61 | task(); 62 | 63 | mNumTasksInSystem--; 64 | 65 | { 66 | unique_lock localLock{mSystemBusyMutex}; 67 | 68 | if (mNumTasksInSystem == 0) { 69 | mSystemBusyCondition.notify_all(); 70 | } 71 | } 72 | } 73 | }); 74 | } 75 | } 76 | 77 | void ThreadPool::shutdownThreads(size_t num) { 78 | auto numToClose = min(num, mNumThreads); 79 | 80 | { 81 | lock_guard lock{mTaskQueueMutex}; 82 | mNumThreads -= numToClose; 83 | } 84 | 85 | // Wake up all the threads to have them quit 86 | mWorkerCondition.notify_all(); 87 | for (auto i = 0u; i < numToClose; ++i) { 88 | mThreads.back().join(); 89 | mThreads.pop_back(); 90 | } 91 | } 92 | 93 | void ThreadPool::waitUntilFinished() { 94 | unique_lock lock{mSystemBusyMutex}; 95 | 96 | if (mNumTasksInSystem == 0) { 97 | return; 98 | } 99 | 100 | mSystemBusyCondition.wait(lock); 101 | } 102 | 103 | void ThreadPool::waitUntilFinishedFor(const chrono::microseconds Duration) { 104 | unique_lock lock{mSystemBusyMutex}; 105 | 106 | if (mNumTasksInSystem == 0) { 107 | return; 108 | } 109 | 110 | mSystemBusyCondition.wait_for(lock, Duration); 111 | } 112 | 113 | void ThreadPool::flushQueue() { 114 | lock_guard lock{mTaskQueueMutex}; 115 | 116 | mNumTasksInSystem -= mTaskQueue.size(); 117 | mTaskQueue.clear(); 118 | } 119 | 120 | NGP_NAMESPACE_END 121 | -------------------------------------------------------------------------------- /src/tinyobj_loader_wrapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved. 3 | * 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property 5 | * and proprietary rights in and to this software, related documentation 6 | * and any modifications thereto. Any use, reproduction, disclosure or 7 | * distribution of this software and related documentation without an express 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. 9 | */ 10 | 11 | /** @file tinyobj_loader_wrapper.cpp 12 | * @author Thomas Müller, NVIDIA 13 | * @brief Wrapper around the tinyobj_loader library, providing a simple 14 | * interface to load OBJ-based meshes. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #define TINYOBJLOADER_IMPLEMENTATION 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | using namespace Eigen; 29 | 30 | NGP_NAMESPACE_BEGIN 31 | 32 | std::vector load_obj(const std::string& filename) { 33 | tinyobj::attrib_t attrib; 34 | std::vector shapes; 35 | std::vector materials; 36 | 37 | std::string warn; 38 | std::string err; 39 | 40 | bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, filename.c_str()); 41 | 42 | if (!warn.empty()) { 43 | tlog::warning() << "Obj: " << warn; 44 | } 45 | 46 | if (!err.empty()) { 47 | throw std::runtime_error{fmt::format("Error loading obj: {}", err)}; 48 | } 49 | 50 | std::vector result; 51 | 52 | tlog::success() << "Loaded mesh \"" << filename << "\" file with " << shapes.size() << " shapes."; 53 | 54 | // Loop over shapes 55 | for (size_t s = 0; s < shapes.size(); s++) { 56 | // Loop over faces 57 | size_t index_offset = 0; 58 | for (size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++) { 59 | size_t fv = size_t(shapes[s].mesh.num_face_vertices[f]); 60 | 61 | if (shapes[s].mesh.num_face_vertices[f] != 3) { 62 | tlog::warning() << "Non-triangle face found in " << filename; 63 | index_offset += fv; 64 | continue; 65 | } 66 | 67 | // Loop over vertices in the face. 68 | for (size_t v = 0; v < 3; v++) { 69 | tinyobj::index_t idx = shapes[s].mesh.indices[index_offset + v]; 70 | 71 | const tinyobj::real_t vx = attrib.vertices[3*idx.vertex_index+0]; 72 | const tinyobj::real_t vy = attrib.vertices[3*idx.vertex_index+1]; 73 | const tinyobj::real_t vz = attrib.vertices[3*idx.vertex_index+2]; 74 | 75 | result.emplace_back(vx, vy, vz); 76 | } 77 | 78 | index_offset += fv; 79 | } 80 | } 81 | 82 | return result; 83 | } 84 | 85 | NGP_NAMESPACE_END 86 | --------------------------------------------------------------------------------