A minimal graphics library in PyTorch
Project description
gffx - a minimal library for (differentiable) graphics
import gffx
import torch
import matplotlib.pyplot as plt
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Setup Camera
camera = gffx.ray.Camera(
width = 512,
height = 512,
pos = [0, 0, 3],
dir = [0, 0, -1],
device = device
)
# Setup list of meshes
vertices = torch.load('path/to/vertices.pt').to(device)
faces = torch.load('path/to/vertices.pt').to(device)
object_list = [
gffx.obj.mesh_from_vertices_and_faces(
vertices = vertices,
faces = faces,
init_translation = [0, 0.0, 2],
init_rotation = [0, 0, 0],
init_scale = [1, 1, 1],
ambient_color = [0.5, 0.5, 0.5],
diffuse_color = [0.5, 0.5, 0.5],
specular_color = [0.5, 0.5, 0.5],
specular_coefficient = 1,
device = device
)
]
# Ray Trace Render
images = gffx.ray.mesh_render(
meshes = object_list,
camera = camera,
light_intensity = 1.0,
ambient_intensity = 0.2,
light_pos = [5, 5, 5],
background_color = [0, 0, 0],
ray_chunk_size = 4096,
device = device
)
plt.imshow((images[0].cpu()).permute(1, 0, 2))
plt.gca().invert_yaxis()
plt.show()
[WIP] CLI
python -m gffx --vertices '/path/to/vertices.pt' --faces 'path/to/faces.pt'
Motivation
- Installing PyTorch3D everytime in colab is a hassle. This library's first aim is to render a mesh using native operations in PyTorch.
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
gffx-0.1.3.tar.gz
(11.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
gffx-0.1.3-py3-none-any.whl
(13.9 kB
view details)
File details
Details for the file gffx-0.1.3.tar.gz.
File metadata
- Download URL: gffx-0.1.3.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebe0ccfaec86f02d75acfba98a9daedc947aa1409920b74ca69f2bc9ab1dcd39
|
|
| MD5 |
71e627bbc4f188ca87a24fbf39bbbe54
|
|
| BLAKE2b-256 |
7ad851bc7b0e4589fd5b5643bec85464a212b76c936ff0ee4d22c4105497a8b4
|
File details
Details for the file gffx-0.1.3-py3-none-any.whl.
File metadata
- Download URL: gffx-0.1.3-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3e14ec170853a6fd215cbf232f40a9ed59c7b64786c9b6b25782dfb2a9bc0f6
|
|
| MD5 |
f458147825101728697a5f5ae56e733d
|
|
| BLAKE2b-256 |
f76ceae1c9b76128aaa4486caa06b3cd87914bdd797638cd77972aaed1b30721
|