Data visualisation and ray tracing in Python based on NVIDIA OptiX framework.
Join us on Patreon for news, release plans and hi-res content.
PlotOptiX is a 3D ray tracing package for Python, aimed at easy and aesthetic visualization of large datasets (and small as well). Data features can be represented in images as a position, size/thickness and color of primitives of several basic shapes, or projected onto surfaces of objects in form of a color textures and displacement maps. Triangular meshes, generated in the code or loaded from a file, are supported as well. All is finished with a photorealistic lighting, depth of field, and many other physically based effects simulated with a high quality.
No need to write shaders, intersection algorithms, handle 3D scene technicalities. Basic usage is even more simple than with matplotlib:
import numpy as np from plotoptix import TkOptiX n = 1000000 # 1M points, better not try this with matplotlib xyz = 3 * (np.random.random((n, 3)) - 0.5) # random 3D positions r = 0.02 * np.random.random(n) + 0.002 # random radii plot = TkOptiX() plot.set_data("my plot", xyz, r=r) plot.show()
… but PlotOptiX is much faster on large data, and, with all the raytraced shades and DoF, more readable and eye catching.
You can quickly display data in a simple plot:
or prepare complex scenes, combining your generated data with meshes modeled elsewhere:
progressive path tracing with explicit light sampling
cameras: orthographic, pinhole, thin-lens and fisheye with depth of field and chromatic aberration simulation, panoramic camera for making 360 deg environment maps, user-defined projection for shooting rays at any angle, and from any origin
geometries: particles (spheres), parallelepipeds, parallelograms, tetrahedrons, linear segments, bezier curves, b-splines; meshes: shaded surface or wireframe, automatically generated from a parametric surface or f(x,y) data, or defined with vertices and faces, e.g. created with pygmsh, or loaded from a file, e.g. supported by trimesh, or loaded from a Wavefront .obj file with a native loader
materials: flat, diffuse, reflective, refractive; including: light dispersion, surface roughness and metalness, volume scattering, and nested volumes
light sources: spherical and parallelogram, light emission in volumes, uniform environmental light or environment map
post-processing: tonal correction curves, levels adjustment, apply mask/overlay, AI denoiser
callbacks: at the scene initialization, start and end of each frame raytracing, end of progressive accumulation
8/16/32bps(hdr) image output to numpy array, or save to popular image file formats
zero-copy access to GPU buffers wrapped in ndarrays: 8/32bps image, hit and object info, albedo, normals
GPU acceleration using RT Cores and everything else what comes with OptiX
hardware accelerated video output to MP4 file format using NVENC 9.0
Tkinter based simple GUI window or a headless raytracer
configurable multi-GPU support
- a CUDA-enabled GPU with compute capability 5.0 (Maxwell) to latest (Ampere);
NVIDIA driver >= r515;
Python 3 64-bit
.NET Framework >= 4.6.1 (present in normally updated Windows)
RnD.SharpOptiX and RnD.SharpEncoder libraries
all other supporting 3’rd party libraries: FFmpeg (Windows only), LibTiff, Newtonsoft.Json
Note, at this point, PlotOptiX binaries are tested in: Windows 10/11, Ubuntu 18.04, CentOS 7.
PlotOptiX was also successfully tested on the Google Cloud Platform, using Compute Engine instance with 2x V100 GPU’s and Ubuntu 18.04 image. Here are the installation steps so you can save some precious seconds (FFmpeg not included).
Windows should be ready to go in most cases. You need to do some more typing in Linux.
Most likely you already got the right version with your Windows installation. Just in case, here is the command verifying this:
C:\>reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\full" /v version HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\full version REG_SZ 4.7.03056
If the number in your output is < 4.6.1, visit download page and install the most recent release.
Check if / which Mono release is present in your system:
mono -V Mono JIT compiler version 126.96.36.199 (tarball Tue Apr 9 16:16:30 UTC 2019) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread ... (output cropped for clarity) ...
mono command is not available, or the reported version is < 5.2, visit Mono download page and follow instructions related to your Linux distribution. You want to install mono-complete package.
Note, current pythonnet release supports Python up to 3.8.
apt update apt install clang libglib2.0-dev python-dev
You may also need to install development tools, if not already present in your system, e.g. in Ubuntu:
apt install build-essential
or in CentOS:
yum group install "Development Tools"
Then, update required packages and install
pip install -U setuptools wheel pycparser pip install -U pythonnet
After successful installation you should be able to do python’s import:
import clr print(clr.__version__)
FFmpeg shared libraries >= 4.1 are required to enable video encoding features in PlotOptiX. Uninstall older version first. Visit FFmpeg site and download the most recent release sources. Unpack it to a new folder, cd to it. Configure, compile and install as below:
./configure --enable-shared make sudo make install
Add FFmpeg’s shared library path to your config:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib sudo ldconfig
pip install -U plotoptix
From GitHub sources:
git clone https://github.com/rnd-team-dev/plotoptix.git cd plotoptix python setup.py install
Then, try running code from the top of this readme, or one of the examples. You may also need to install
PyQt packages, if not shipped with your Python environment.
This is still an early version. There are some important features not available yet, eg. ticks and labels on plot axes.
PlotOptiX is basically an interface to RnD.SharpOptiX library which we are developing and using in our Studio. RnD.SharpOptiX offers much more functionality than it is now available through PlotOptiX. We’ll progressively add more to PlotOptiX if there is interest in this project (download, star, and become our Patron if you like it!).
The idea for development is:
Binaries for Linux (done in v0.3.0).
Migrate to OptiX 7.0 (done in v0.7.0).
Complete the plot layout / cover more raytracing features.
Convenience functions for various plot styles. Other GUI’s.
Here, the community input is possible and warmly welcome!
Looking at examples is the best way to get started and explore PlotOptiX features. Have a look at the readme and sample codes here.
Examples in the repository head may use features not yet available in the PyPI release. In order to download examples compatible with PyPI release install the package:
python -m plotoptix.install examples
This will create a folder with examples in the current directory.
- NpOptiX - base, headless raytracer
- TkOptiX - Tkinter based GUI
- Enumerations and flags
- Predefined materials
- Utility functions
- R&D Team Design Studio
- GitHub Sources
- PyPI Releases
- Release history
- v0.14.3 - 2022-08-13
- v0.14.2 - 2021-10-10
- v0.14.1 - 2021-07-23
- v0.14.0 - 2021-07-03
- v0.13.3 - 2021-03-08
- v0.13.2 - 2020-12-21
- v0.13.1 - 2020-12-21
- v0.13.0 - 2020-12-21
- v0.12.0 - 2020-11-17
- v0.11.1 - 2020-10-21
- v0.11.0 - 2020-09-27
- v0.10.1 - 2020-08-30
- v0.10.0 - 2020-08-17
- v0.9.0 - 2020-07-20
- v0.8.2 - 2020-07-12
- v0.8.1 - 2020-06-14
- v0.8.0 - 2020-06-04
- v0.7.2 - 2020-05-13
- v0.7.1 - 2020-04-11
- v0.7.0 - 2020-03-27
- v0.5.2 - 2019-10-15
- v0.5.1 - 2019-09-27
- v0.5.0 - 2019-09-20
- v0.4.8 - 2019-09-07
- v0.4.7 - 2019-08-28
- v0.4.6 - 2019-08-19
- v0.4.5 - 2019-08-11
- v0.4.2 - 2019-07-23
- v0.4.1 - 2019-07-14
- v0.4.0 - 2019-07-06
- v0.3.1 - 2019-06-26
- v0.3.0 - 2019-06-09
- v0.2.2 - 2019-05-26
- v0.2.1 - 2019-05-19
- v0.2.0 - 2019-05-12
- v0.1.4 - 2019-04-25
- v0.1.3 - 2019-04-19