Skip to content

Commit

Permalink
Updating readme
Browse files Browse the repository at this point in the history
  • Loading branch information
loliverhennigh committed Nov 20, 2023
1 parent 38438a1 commit c368639
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 14 deletions.
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
# PhantomGaze
Simple GPU rendering of scientific data with Pytorch, Jax, CuPy, and Warp backends.
# PhantomGaze: A GPU-Accelerated Rendering Engine for Scientific Visualization

## Introduction

PhantomGaze is a Python package that provides a basic rendering engine optimized for scientific computing visualizations. Utilizing the power of Numba, it enables efficient operations directly on the GPU, enhancing the visualization of complex scientific data. This package is particularly useful for rendering volumetric data, geometric shapes, and contour visualizations with ease.

## Features

- GPU-accelerated rendering engine
- Volumetric rendering
- Geometric rendering
- Contour rendering
- Customizable color maps
- Integration with GPU libraries such as CuPy, JAX, PyTorch, and Warp.

## Installation

PhantomGaze can be installed using pip:

```bash
pip install .
```

(TODO: Make package available on PyPI)

## Usage

There are several examples in the `examples` directory. A minimal example of a contour plot is shown below:

```python
import cupy as cp
import matplotlib.pyplot as plt

import phantomgaze as pg

# Create SDF feild of a sphere using cupy
lin = cp.linspace(-1, 1, 256)
X, Y, Z = cp.meshgrid(lin, lin, lin, indexing="ij")
sphere = -(cp.sqrt(X**2 + Y**2 + Z**2) - 1.0)
sphere_volume = pg.objects.Volume(
sphere, spacing=(2 / 256, 2 / 256, 2 / 256), origin=(-1.0, -1.0, -1.0)
)
color_volume = pg.objects.Volume(
cp.sin(X * 2 * cp.pi) * cp.sin(Y * 2 * cp.pi) * cp.sin(Z * 2 * cp.pi),
spacing=(2 / 256, 2 / 256, 2 / 256),
origin=(-1.0, -1.0, -1.0),
)

# Create camera object
camera = pg.Camera(position=(2.0, 1.0, -4.0), focal_point=(0.0, 0.0, 0.0), view_up=(0.0, 1.0, 0.0))

# Render the contour of the inner sphere
screen_buffer = pg.render.contour(sphere_volume, camera, threshold=0.0, color=color_volume)

# Show the rendered image
plt.imshow(screen_buffer.image.get())
plt.show()
```

This produces the following image:

![Contour](https://github.com/loliverhennigh/PhantomGaze/assets/readme_example.png)

Binary file added assets/axes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/geometry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/readme_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sphere.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/volume.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
camera = pg.Camera(position=(0.0, 1.0, 6.69), focal_point=(0.0, 0.0, 0.0), view_up=(0.0, 1.0, 0.0))

# Render the axes
screen_buffer = pg.render.axes(size=1.0, center=(1.0, 0.0, 0.0), camera=camera)
screen_buffer = pg.render.axes(size=1.0, center=(0.0, 0.0, 0.0), camera=camera)

# Plot the result
plt.imshow(screen_buffer.image.get())
Expand Down
11 changes: 0 additions & 11 deletions examples/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cupy as cp
import matplotlib.pyplot as plt
from tqdm import tqdm

import phantomgaze as pg

Expand All @@ -27,16 +26,6 @@
# Create screen buffer
screen_buffer = pg.ScreenBuffer.from_camera(camera)

for _ in tqdm(range(100)):
# Render the axes
screen_buffer = pg.render.axes(size=0.1, center=(-1.5, -1.5, 1.0), camera=camera, screen_buffer=screen_buffer)

# Render wireframe of the volume
screen_buffer = pg.render.wireframe(lower_bound=(-1.0, -1.0, -1.0), upper_bound=(1.0, 1.0, 1.0), thickness=2 / 256, camera=camera, screen_buffer=screen_buffer)

# Render the volume plot
screen_buffer = pg.render.volume(sin_volume, camera, colormap=colormap, screen_buffer=screen_buffer)

# Render the axes
screen_buffer = pg.render.axes(size=0.1, center=(-1.5, -1.5, 1.0), camera=camera)

Expand Down

0 comments on commit c368639

Please sign in to comment.