GithubHelp home page GithubHelp logo

mmacklin / phantomgaze Goto Github PK

View Code? Open in Web Editor NEW

This project forked from loliverhennigh/phantomgaze

3.0 0.0 0.0 250 KB

Simple GPU rendering of scientific data with Pytorch, Jax, CuPy, and Warp backends.

License: Apache License 2.0

Python 100.00%

phantomgaze's Introduction

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:

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:

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

Gallery

The following images were generated using the examples in the examples directory.

Axes Geometry Volume

phantomgaze's People

Contributors

loliverhennigh avatar

Stargazers

Przemyslaw Korzeniowski avatar ACYang avatar Eric Heiden avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.