Skip to main content

A threejs-like render engine based on wgpu

Project description


Pygfx

CI Documentation Status PyPI version

Pygfx' purpose is to bring powerful and reliable visualization to the Python world. 🚀

Pygfx (pronounced "py-graphics") is built on wgpu, enabling superior performance and reliability compared to OpenGL-based solutions. It is designed for simplicity and versatility: with its modular architecture, you can effortlessly assemble graphical scenes for diverse applications, from scientific visualization to video game rendering.

drawing drawing drawing

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

Professional support

Need help? We offer the following professional services:

  • Priority Support: Rest assured with our dedicated support, prioritizing your needs for quick issue resolution and feature implementation.
  • Integration Support: Get assistance with integrating Pygfx into your application, ensuring a smooth transition and optimal performance.
  • Customized Solutions: Whether it's crafting specific visualizations or developing shaders, we work closely with you to create tailored solutions that address your unique requirements.
  • Training and Workshops: We provide informative training sessions and workshops aimed at boosting skills and knowledge.

Also checkout the sponsors page. For further inquiries reach out to us at support@pygfx.org.

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.

Status

We're currently working towards version 1.0, which means that the API can change with each version. We expect to reach 1.0 near the end of 2024, at which point we start caring about backwards compatibility.

This means that until then, you should probably pin the Pygfx version that you're using, and check the release notes when you update.

Usage Example

Note The example below is designed against the main branch, and may not work on the latest release from pypi, while we're in beta.

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

import pygfx as gfx
import pylinalg as la

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

rot = la.quat_from_euler((0, 0.01), order="XY")

def animate():
    cube.local.rotation = la.quat_mul(rot, cube.local.rotation)

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.

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

See CONTRIBUTING.md.

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 tests

Testing

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

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

The screenshot tests are difficult to guarantee across all development platforms and are best run on our CI where more predictable outcomes can be achieved. They can run on a local linux machine by selecting the software rendering adapter and the tests with the command

  • PYGFX_WGPU_ADAPTER_NAME=llvmpipe pytest examples -k test_examples_compare

Note that our pytest.ini file contains the environment variable PYGFX_DISABLE_SYSTEM_FONTS=1 to help ensure consistency across system installations.

Code of Conduct

Our code of conduct can be found here: Code of Conduct

Spelling and pronunciation

Lowercase "pygfx" is used in code. You can refer to the project in written text using "Pygfx". Pygfx is pronounced as pie-graphics.

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.4.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

pygfx-0.4.1-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygfx-0.4.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pygfx-0.4.1.tar.gz
Algorithm Hash digest
SHA256 b8291fd279e214a249e4abd369d133a03f4b3a520f54495c116090c6f52ce009
MD5 84d17ea7b0cf36e5accd4a97d4e0ffd9
BLAKE2b-256 2fe689e5687f60c36839480c0378dd3ccf2e8777d20859e697e0d6c24b68bdc3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygfx-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pygfx-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7d7ee254c5406223516d32297d756b92a26426b2d2286847f7ea4b0f513e355d
MD5 02933e3efdcb219f8fdce74b9104e51f
BLAKE2b-256 2a7d3681c0d1f721e1f08a0b722758bc8fe0fe980e7a6d607f151d21f5ef020d

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