Pure Python ISF shader renderer with PyOpenGL and json5
Project description
pyvvisf
Python ISF shader renderer with PyOpenGL. Render images from your shaders, or visualize in a window.
Overview
pyvvisf is a pure Python implementation for parsing and rendering ISF (Interactive Shader Format) shaders. It provides a modern, maintainable alternative to the C++ VVISF-GL library with enhanced error reporting and cross-platform compatibility. The original version of this library tried to build VVISF-GL bindings, but that approach was abandoned.
This library tried to catch all the errors that would trigger the online ISF renderer here: https://editor.isf.video/. It will also try to provide compatibility warnings when appropriate.
The main use of this library is intended to be from https://github.com/jimcortez/ai-shader-tool, which provides ai's the ablility to validate, render, and inspect the results of shaders it generates.
The majority of code in this repository was built with AI.
Features
- Pure Python: No C++ compilation required
- Robust JSON parsing: Uses json5 for comment support and trailing commas
- Modern OpenGL: PyOpenGL with GLFW for cross-platform context management
- Enhanced error reporting: Detailed Python-native error messages with context
- Type safety: Pydantic models for metadata validation
- Auto-coercion: Automatic type conversion for shader inputs
- Context management: Automatic resource cleanup
Installation
pip install pyvvisf
Development Installation
git clone https://github.com/jimcortez/pyvvisf.git
cd pyvvisf
pip install -e .
Quick Start
Here's a minimal example using a well-formed ISF shader:
from pyvvisf import ISFRenderer
# A simple ISF shader (every pixel is the selected color)
test_shader = """
/*{
\"DESCRIPTION\": \"Every pixel is the selected color.\",
\"CREDIT\": \"pyvvisf example\",
\"ISFVSN\": \"2.0\",
\"CATEGORIES\": [\"Generator\"],
\"INPUTS\": [
{\"NAME\": \"color\", \"TYPE\": \"color\", \"DEFAULT\": [1.0, 0.0, 0.0, 1.0]}
]
}*/
void main() {
gl_FragColor = color;
}
"""
with ISFRenderer(test_shader) as renderer:
# Render with the default color (red)
buffer = renderer.render(512, 512)
image = buffer.to_pil_image()
image.save("output_red.png")
# Render with a custom color (green)
renderer.set_input("color", (0.0, 1.0, 0.0, 1.0))
buffer = renderer.render(512, 512)
image = buffer.to_pil_image()
image.save("output_green.png")
Examples
See the examples/ directory for complete examples:
isf_renderer_demo.py: Render ISF shaders to images, set inputs, and save output.isf_window_demo.py: Render ISF shaders in a window (interactive display).time_offset_demo.py: Render shaders at different time offsets (for animation or frame capture).
Shader examples are in examples/shaders/:
simple_color_change.fs: Single color input, fills the screen with the selected color.simple_color_animation.fs: Fades between two user-selected colors over time.shapes.fs: Animated shapes (moving circle, rotating rectangle, pulsating ring).simple.fs: Minimal shader, fills the screen with blue.
Development
Building
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
Project Structure
pyvvisf/
├── src/pyvvisf/
│ ├── renderer.py # Main renderer
│ ├── parser.py # ISF parser with json5
│ ├── types.py # Value types
│ └── errors.py # Error handling
├── examples/
├── tests/
└── docs/
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
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
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
File details
Details for the file pyvvisf-0.6.0.tar.gz.
File metadata
- Download URL: pyvvisf-0.6.0.tar.gz
- Upload date:
- Size: 40.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e08da80cd0458115f8feea940a36d8b7b70c3c787af584cc21076de76d421f9
|
|
| MD5 |
08b131878409afc6ff5373bd007e63f6
|
|
| BLAKE2b-256 |
fab9e4afa5c3b5574603ef5fdfb6f2c477ee8c9a6ad66785b32c11ee283a67c6
|
Provenance
The following attestation bundles were made for pyvvisf-0.6.0.tar.gz:
Publisher:
build-wheels.yml on jimcortez/pyvvisf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyvvisf-0.6.0.tar.gz -
Subject digest:
1e08da80cd0458115f8feea940a36d8b7b70c3c787af584cc21076de76d421f9 - Sigstore transparency entry: 271254720
- Sigstore integration time:
-
Permalink:
jimcortez/pyvvisf@05d6a756d0456899f302a0df4029b37eed6ec42f -
Branch / Tag:
refs/tags/0.6.0 - Owner: https://github.com/jimcortez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@05d6a756d0456899f302a0df4029b37eed6ec42f -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyvvisf-0.6.0-py3-none-any.whl.
File metadata
- Download URL: pyvvisf-0.6.0-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7c47c9b51aa564e3d48d70f7619b49e3ea8c2bd07ea17f520360b6ee5b892a9
|
|
| MD5 |
53695a6a559f90f3bf15eb22d0278404
|
|
| BLAKE2b-256 |
d044d79af3b877fb9eea01178a20041fc131d9f39a8ca7433fbdfd638ff2328f
|
Provenance
The following attestation bundles were made for pyvvisf-0.6.0-py3-none-any.whl:
Publisher:
build-wheels.yml on jimcortez/pyvvisf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyvvisf-0.6.0-py3-none-any.whl -
Subject digest:
c7c47c9b51aa564e3d48d70f7619b49e3ea8c2bd07ea17f520360b6ee5b892a9 - Sigstore transparency entry: 271254721
- Sigstore integration time:
-
Permalink:
jimcortez/pyvvisf@05d6a756d0456899f302a0df4029b37eed6ec42f -
Branch / Tag:
refs/tags/0.6.0 - Owner: https://github.com/jimcortez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@05d6a756d0456899f302a0df4029b37eed6ec42f -
Trigger Event:
release
-
Statement type: