All Projects → pygfx → pygfx

pygfx / pygfx

Licence: BSD-2-Clause License
Like ThreeJS but for Python and based on wgpu

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pygfx

wgpu-py
Next generation GPU API for Python
Stars: ✭ 210 (+191.67%)
Mutual labels:  metal, vulkan, dx12, wgpu, closember
rend3
Easy to use, customizable, efficient 3D renderer library built on wgpu.
Stars: ✭ 546 (+658.33%)
Mutual labels:  metal, vulkan, 3d-graphics, wgpu
wgpu-mc
Rust-based replacement for the default Minecraft renderer
Stars: ✭ 254 (+252.78%)
Mutual labels:  metal, vulkan, wgpu
RavEngine
A fast, easy to use C++20 3D game library for modern computers
Stars: ✭ 122 (+69.44%)
Mutual labels:  metal, vulkan, 3d-engine
Gfx
[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
Stars: ✭ 5,045 (+6906.94%)
Mutual labels:  metal, vulkan, dx12
Filament
Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
Stars: ✭ 13,215 (+18254.17%)
Mutual labels:  metal, vulkan, 3d-graphics
Explosion
💥 A modern cross-platform game engine (WIP)
Stars: ✭ 102 (+41.67%)
Mutual labels:  metal, vulkan, dx12
virtualGizmo3D
Virtual GIZMO - 3D object manipulator / orientator, via mouse, with pan and dolly/zoom features
Stars: ✭ 36 (-50%)
Mutual labels:  metal, vulkan
CrossWindow-Demos
🥪 Examples of how to use CrossWindow for things like rendering graphics, listening to events, etc.
Stars: ✭ 48 (-33.33%)
Mutual labels:  metal, vulkan
LowLevelAPIDemo
Evergine Low-Level API samples.
Stars: ✭ 12 (-83.33%)
Mutual labels:  metal, vulkan
SourceRenderer
A tiny 3D engine that loads and renders Source engine maps - Also known as dreieck.exe
Stars: ✭ 32 (-55.56%)
Mutual labels:  vulkan, 3d-graphics
mojoshader
Use Direct3D shaders with other 3D rendering APIs.
Stars: ✭ 91 (+26.39%)
Mutual labels:  metal, vulkan
MetalGlobe
Simple demo project with Metal on Swift
Stars: ✭ 18 (-75%)
Mutual labels:  metal, 3d-graphics
FWK
💎 3D game framework in C, with Luajit bindings now.
Stars: ✭ 423 (+487.5%)
Mutual labels:  3d-graphics, 3d-engine
bgfx-header-extension-library
Header-only effects and helper library for Bgfx to help you hit the ground running. Includes a bunch of post processing filters to complete common graphical tasks
Stars: ✭ 35 (-51.39%)
Mutual labels:  metal, vulkan
GroundEngine
Ground Engine is an easy to use Game Engine for 3D Game Development written in C++
Stars: ✭ 61 (-15.28%)
Mutual labels:  3d-graphics, 3d-engine
FANCY
A rendering-framework for DX12 and Vulkan. Mostly intended for personal learning purposes and graphics demos
Stars: ✭ 21 (-70.83%)
Mutual labels:  vulkan, dx12
pilka
Another live-coding tool for creating shader demos, Vulkan+Wgpu powered.
Stars: ✭ 84 (+16.67%)
Mutual labels:  vulkan, wgpu
nautilus
another graphics engine
Stars: ✭ 16 (-77.78%)
Mutual labels:  vulkan, 3d-graphics
bgfx-python
Python 3.7+ wrapper for the BGFX library. 🐍
Stars: ✭ 99 (+37.5%)
Mutual labels:  metal, vulkan

CI Documentation Status PyPI version

pygfx

A render engine, inspired by ThreeJS, but for Python and targeting Vulkan/Metal/DX12 (via wgpu).

Introduction

This is a Python render engine build on top of WGPU (instead of OpenGL).

We take a lot of inspiration from ThreeJS, e.g.:

  • Materials and Geometry are combined in world objects.
  • Decoupled cameras and controllers.
  • The code for the render engines is decoupled from the objects, allowing multiple render engines (e.g. wgpu and svg).

Further we aim for a few niceties:

  • Proper support for high-res screens.
  • Builtin anti-aliasing.
  • Custom post-processing steps.
  • Support for picking objects and parts within objects.
  • (approximate) order-independent transparency (OIT) (not implemented yet).

WGPU is awesome (but also very new)

Working with the WGPU API feels so much nicer than OpenGL. It's well defined, no global state, we can use compute shaders, use storage buffers (random access), etc.

Fair enough, the WGPU API is very new and is still changing a lot, but eventually it will become stable. One of the biggest downsides right now is the lack of software rendering. No luck trying to run wgpu on a VM or CI.

Because of how Vulkan et. al. work, the WGPU API is aimed at predefining objects and pipelines and then executing these. Almost everything is "prepared". The main reasoning for this is consistency and stable drivers, but it also has a big advantage for us Pythoneers: the amount of code per-draw-per-object is very limited. This means we can have a lot of objects and still be fast.

As an example, see collections_line.py: drawing 1000 line objects with 30k points each at 57 FPS (on my laptop).

How to build a visialization

See also the examples, they all do something like this:

  • Instantiate a renderer and a canvas to render to.
  • Create a scene and populate it with world objects.
  • Create a camera (and maybe a control).
  • Define an animate function that calls: renderer.render(scene, camera)

On world objects, materials, and geometry

There are a few different world object classes. The class defines (semantically) the kind of object being drawn, e.g. Line, Image, Mesh, Volume. World objects have a position and orientation in the scene, and can have children (other world objects), creating a tree. World objects can also have a geometry and/or a material.

The geometry of an object defines its base data, usually per-vertex attributes such as positions, normals, and texture coordinates. There are several pre-defined geometries, most of which simply define certain 3D shapes.

The material of an object defines how an object is rendered. Usually each WorldObject class has one or more materials associated with it. E.g. a line can be drawn solid, segmented or with arrows. A volume can be rendered as a slice, MIP, or something else.

Installation

pip install -U pygfx

Or, to get the latest from GitHub:

pip install -U https://github.com/pygfx/pygfx/archive/main.zip

Current status

Under development, many things can change.

Testing examples

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.

There are two types of tests for examples included with pygfx:

Type 1: Checking if examples can run

When running the test suite, pytest will run every example in a subprocess, to see if it can run and exit cleanly. You can opt out of this mechanism by including the comment # run_example = false in the module.

Type 2: Checking if examples output an image

You can also (independently) opt-in to output testing for examples, by including the comment # test_example = true in the module. Output testing means the test suite will attempt to import the renderer instance global from your example, and call it to see if an image is produced.

To support this type of testing, ensure the following requirements are met:

  • The WgpuCanvas class is imported from the wgpu.gui.auto module.
  • The renderer instance is exposed as a global in the module.
  • A rendering callback has been registered with renderer.request_draw(fn).

Reference screenshots are stored in the examples/screenshots folder, the test suite will compare the rendered image with the reference.

Note: this step will be skipped when not running on CI. Since images will have subtle differences depending on the system on which they are rendered, that would make the tests unreliable.

For every test that fails on screenshot verification, diffs will be generated for the rgb and alpha channels and made available in the examples/screenshots/diffs folder. On CI, the examples/screenshots folder will be published as a build artifact so you can download and inspect the differences.

If you want to update the reference screenshot for a given example, you can grab those from the build artifacts as well and commit them to your branch.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].