https://github.com/simleek/torchrender
Rendering utilities using PyTorch
https://github.com/simleek/torchrender
Last synced: over 1 year ago
JSON representation
Rendering utilities using PyTorch
- Host: GitHub
- URL: https://github.com/simleek/torchrender
- Owner: SimLeek
- License: mit
- Created: 2019-02-27T05:44:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-11T21:10:46.000Z (about 3 years ago)
- Last Synced: 2025-02-28T18:38:45.300Z (over 1 year ago)
- Language: Python
- Size: 26.4 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# TorchRender
A library for testing and debugging graphics algorithms with torch. Or just graphics, though that may be slow depending on the GPU.
## Examples
The current best way to see how to use this library is by looking through the examples and tests.
### Conways's Game of Life + Color

[This example](https://github.com/SimLeek/TorchRender/blob/master/examples/interactive_test_pixel_shader.py) adds interaction between colors of different pixels to Conway's game of life. This doesn't really require a pixel shader, and could be done on normal pytorch, but the scrolling I added after the video above demonstrates a very simple usage for a pixel shader:
```python
def conway(frame, coords, finished):
...
trans = np.zeros_like(coords)
trans[0, ...] = np.ones(trans.shape[1:])
frame[coords] = array[coords+trans]
```
Here, we're adding 1 to a dimensions of 'coords' which is a tensor holding the locations of each pixel and color. This shifts the entire image by one pixel. If we did something more complicated based on the values of the coordinates, we could add more complicated shaders, like barrel distortions.
## Installation
torchrender is distributed on [PyPI](https://pypi.org) as a universal
wheel and is available on Linux/macOS and Windows and supports
Python 3.5+ and PyPy.
```bash
$ pip install torchrender
```
## License
torchrender is distributed under the terms of the
[MIT License](https://choosealicense.com/licenses/mit>).