Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

nanort

> DevOps
Open source

NanoRT, single header only modern ray tracing kernel.

1.1K stars0 likes2 views
WebsiteGitHub

About

NanoRT, single header only modern ray tracing kernel.

NanoRT, single header only modern ray tracing kernel.

Path tracing example contributed by https://github.com/daseyb

NanoRT is simple single header only ray tracing kernel.

Features

  • Portable C++
    • Only use C++-03 features by default.
    • C++11 feature(threads) is also available
    • There is experimental C89 port of NanoRT in c89 branch https://github.com/lighttransport/nanort/tree/c89
  • BVH spatial data structure for efficient ray intersection finding.
    • Should be able to handle ~10M triangles scene efficiently with moderate memory consumption
  • Custom geometry & intersection
    • Built-in triangle mesh gemetry & intersector is provided.
  • Cross platform
    • MacOSX, Linux, Windows, iOS, Android, ARM, x86, SPARC, (maybe) MIPS, (will be) RISC-V, etc.
    • For example, NanoRT works finely on Raspberry Pi 2 (arm 32bit) and Raspberrry Pi 3!(AARCH64 kernel)
  • GPU efficient data structure
    • Built BVH tree from NanoRT is a linear array and does not have pointers, thus it is suited for GPU raytracing (GPU ray traversal).
  • OpenMP multithreaded BVH build.
  • Robust intersection calculation.
    • Robust BVH Ray Traversal (using up to 4 ulp version): http://jcgt.org/published/0002/02/02/
    • Watertight Ray/Triangle Intesection: http://jcgt.org/published/0002/01/05/
  • Double precision support
    • Beneficial for HPC and scientific visualization.

Applications

  • Test renderer for your light transport algorithm development.
  • Test renderer for your shader language development.
  • Collision detection (ray casting).
  • BVH builder for GPU/Accelerator ray traversal.
  • Add 2D/3D rendering feature for non-GPU system.
    • ImGui backend? https://github.com/syoyo/imgui/tree/nanort
    • Nano SVG backend? https://github.com/syoyo/nanovg-nanort

Projects using NanoRT

  • lightmetrica https://github.com/hi2p-perim/lightmetrica-v2
  • OSPRay NanoRT module https://github.com/jeffamstutz/module_nanort/
  • Your project here!

Projects similar/related to NanoRT

  • bvh: C++17 BVH Construction and Traversal Library https://github.com/madmann91/bvh
  • BlazeRT: double precision ray tracer for scientific or engineering applications https://github.com/cstatz/blazert

API

nanort::Ray represents ray. The origin org, the direction dir (not necessarily normalized), the minimum hit distance min_t(usually 0.0) and the maximum hit distance max_t (usually too far, e.g. 1.0e+30) must be filled before shooting ray.

nanort::BVHAccel builds BVH data structure from geometry, and provides the function to find intersection point for a given ray.

nanort::BVHBuildOptions specifies parameters for BVH build. Usually default parameters should work well.

nanort::BVHTraceOptions specifies ray traverse/intersection options.

…

Application must prepare geometric information and store it in linear array.

For a builtin Triangle intersector,

  • vertices : The array of triangle vertices (e.g. xyz * numVertices)
  • faces : The array of triangle face indices (3 * numFaces)
  • stride : Byte stride of each vertex data

are required attributes.

Usage

…

Defines

NANORT_USE_CPP11_FEATURE : Enable C++11 feature
NANORT_ENABLE_PARALLEL_BUILD : Enable parallel BVH build(OpenMP version is not yet fully tested).

More example

See examples directory for example renderer using NanoRT.

  • examples/path_tracer Path tracer example by https://github.com/daseyb
    • Better ortho basis generation: Building an Orthonormal Basis, Revisited http://jcgt.org/published/0006/01/01/
  • examples/bidir_path_tracer Bi-directional path tracer example by https://github.com/tatsy
  • examples/gui Simple renderer with GUI(using ImGui)
  • examples/vrcamera Stereo VR Camera
  • examples/objrender Render wavefront .obj model using NanoRT.
  • examples/par_msquare Render heightfield by converting it to meshes using par_msquare(marching squares)
  • examples/las Visualize LiDAR(LAS) point cloud as sphere geometry.
  • examples/double_precision Double precision triangle geometry and BVH.
  • examples/embree-api NanoRT implementation of Embree API.
  • examples/ptex Ptex texturing.

Custom geometry

Here is an example of custom geometry.

  • Spheres(particles) examples/particle_primitive/
  • Cubic Bezier Curves
    • Approximate as lines examples/curves_primitive/
    • Recursive Ray-Bezier intersection.
  • Cylinders examples/cylinder_primitive/

And plesae see API at wiki: https://github.com/lighttransport/nanort/wiki/API

License

nanort.h is licensed under MIT license.

NanoRT uses stack_container.h which is licensed under:

// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

NanoRT examples use some external third party libraries. Licenses for such third party libraries obey their own license.

Lucy statue model is from The Stanford 3D Scanning Repository http://graphics.stanford.edu/data/3Dscanrep/

TODO

PR are always welcome!

  • Optimize ray tracing kernel
    • Efficient Ray Tracing Kernels for Modern CPU Architectures http://jcgt.org/published/0004/04/05/
    • ARM NEON SIMD
    • Intel SSE SIMD
  • Better cmake build.
  • Implement more Embree compatible API.
  • Scene graph support.
    • NanoSG, Minimal scene graph library. examples/nanosg
    • Instancing support.
  • Fix multi-hit ray traversal.
  • Optimize Multi-hit ray traversal for BVH.
    • http://jcgt.org/published/0004/04/04/
  • Ray traversal option.
    • FaceID range.
    • Double sided on/off.
    • Ray offset.
    • Avoid self-intersection(BVHTraceOptions.skip_prim_id).
    • Custom intersection filter through C++ template.
  • Fast BVH build
    • Bonsai: Rapid Bounding Volume Hierarchy Generation using Mini Trees http://jcgt.org/published/0004/03/02/
  • Efficient BVH build
    • Spatial split BVH
  • Motion blur
    • STBVH: A Spatial-Temporal BVH for Efficient Multi-Segment Motion Blur http://www.highperformancegraphics.org/2017/program/
  • Fast, Accurate ray curve intersection
    • Phantom Ray-Hair Intersector
  • Example bi-directional path tracing renderer by @tatsy.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++bdptbvhpathtracingray

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理