Skip to main content

A threejs-like render engine based on wgpu

Project description

CI Documentation Status PyPI version

A python render engine targeting Vulkan/Metal/DX12.

drawing drawing drawing

[User Guide] [Example Gallery] [API Reference]

Installation

pip install -U pygfx glfw

To work correctly, pygfx needs some window to render to. Glfw is one lightweight option, but there are others, too. If you use a different wgpu-compatible window manager or only render offscreen you may choose to omit glfw. Examples of alternatives include: jupyter_rfb (rendering in jupyter), PyQt, PySide, or wx.

In addition there are some platform requirements, see the wgpu docs. In essence, you need modern (enough) graphics drivers, and pip>=20.3.

Usage Example

Note A walkthrough of this example can be found in the guide.

import pygfx as gfx

cube = gfx.Mesh(
    gfx.box_geometry(200, 200, 200),
    gfx.MeshPhongMaterial(color="#336699"),
)

def animate():
    rot = gfx.linalg.Quaternion().set_from_euler(
            gfx.linalg.Euler(0, 0.01)
        )
    cube.rotation.multiply(rot)

if __name__ == "__main__":
    gfx.show(cube, before_render=animate)
drawing

Feature Highlights

Some of pygfx's key features are:

  • SDF based text rendering (example)
  • order-independent transparency (OIT) (example)
  • lights, shadows, and physically based rendering (PBR) (example)
  • event system with built-in picking (example)
  • texture and color mapping supporting 1D, 2D and 3D data (example)

And many more! Check out our feature demos in the docs.

About pygfx

pygfx is a ThreeJS inspired graphics library that uses WGPU (the successor of OpenGL) to provide GPU acceleration to rendering workloads. It is mature enough to serve as a general-purpose rendering engine (Yes, you can write a game with it.) while being geared towards scientific and medical visualization. Thanks to its low level of abstraction it is flexible and can be adapted to various use-cases. In other words, pygfx emphasizes on hackability and correctness while maintaining the level of performance you would expect from a GPU accelerated library.

License

Pygfx is licensed under the BSD 2-Clause "Simplified" License. This means:

  • :white_check_mark: It is free (and open source) forever. :cupid:
  • :white_check_mark: You can use it commercially.
  • :white_check_mark: You can distribute it and freely make changes.
  • :x: You can not hold us accountable for the results of using pygfx.

Contributing

We use a pull request (PR) based workflow similar to many other open-source libraries in the python ecosystem. You can read more about this workflow here; if you have previously contributed to open-source, a lot of this will look familiar already.

Development Install

To get a working dev install of pygfx you can use the following steps:

# Click the Fork button on GitHub and navigate to your fork
git clone <address_of_your_fork>
cd pygfx
# if you use a venv, create and activate it
pip install -e .[dev,docs,examples]
pytest

Testing

The test suite is divided into two parts; unit tests for the core, and unit tests for the examples.

  • pytest -v tests runs the core unit tests.
  • pytest -v examples tests the examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygfx-0.1.12.tar.gz (969.9 kB view details)

Uploaded Source

Built Distribution

pygfx-0.1.12-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file pygfx-0.1.12.tar.gz.

File metadata

  • Download URL: pygfx-0.1.12.tar.gz
  • Upload date:
  • Size: 969.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for pygfx-0.1.12.tar.gz
Algorithm Hash digest
SHA256 616f28a6a36343353ccf2036c8d0da7ec0b1bd7ea7215d5a654e11a19f53537e
MD5 834187d16bdff46c48bbb06790afcd2b
BLAKE2b-256 44437a2fd1e0f7e5bb39ef5800c98a7a19d5fccf9f4044d118d6d7d3c69e1815

See more details on using hashes here.

File details

Details for the file pygfx-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: pygfx-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for pygfx-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 196bbce7d9cf785571165e9b39c26305c606532b265186d5fbe4485836aad5d2
MD5 4cdffae9f9ea692a623327077b673a24
BLAKE2b-256 2469e1f21251cdf47ab50f4e76c53fd3a3b5605ea8983099109d01836ca222e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page