Package: pygfx
A python render engine targeting Vulkan/Metal/DX12.[User Guide]
[Example Gallery]
[API Reference]Installationpipinstall-UpygfxglfwTo work correctly, pygfx needssomewindow 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, orwx.In addition there are some platform
requirements, see thewgpu docs. In
essence, you need modern (enough) graphics drivers, andpip>=20.3.StatusWe're currently working towards version1.0, which means that the API
can change with each version. We expect to reach1.0near the end of
2023, 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 therelease noteswhen you update.Usage ExampleNoteThe example below is designed against themainbranch,
and may not work on the latest release from pypi, while we're in beta.NoteA walkthrough of this example can be found inthe
guide.importpygfxasgfximportpylinalgaslacube=gfx.Mesh(gfx.box_geometry(200,200,200),gfx.MeshPhongMaterial(color="#336699"),)rot=la.quat_from_euler((0,0.01),order="XY")defanimate():cube.local.rotation=la.quat_mul(rot,cube.local.rotation)if__name__=="__main__":gfx.show(cube,before_render=animate)Feature HighlightsSome 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 ourfeature demosin the docs.About pygfxPygfx 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, youcanwrite 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.LicensePygfx is licensed under theBSD 2-Clause "Simplified" License. This means::white_check_mark: It is free (and open source) forever. :cupid::white_check_mark: Youcanuse it commercially.:white_check_mark: Youcandistribute it and freely make changes.:x: Youcan nothold us accountable for the results of using pygfx.ContributingWe use a pull request (PR) based workflow similar to many other open-source
libraries in the python ecosystem. You can read more about this workflowhere;
if you have previously contributed to open-source, a lot of this will look
familiar already.Development InstallTo get a working dev install of pygfx you can use the following steps:# Click the Fork button on GitHub and navigate to your forkgitclone<address_of_your_fork>cdpygfx# if you use a venv, create and activate itpipinstall-e.[dev,docs,examples]pytestTestingThe test suite is divided into two parts; unit tests for the core, and unit
tests for the examples.pytest -v testsruns the core unit tests.pytest -v examplestests the examples.