Pure Python ISF shader renderer with PyOpenGL and json5
Project description
pyvvisf
Pure Python ISF shader renderer with PyOpenGL and json5.
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.
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
from pyvvisf import ISFRenderer, ISFColor, ISFPoint2D
# Create a simple test shader
test_shader = """
/*{
"NAME": "Test Shader",
"INPUTS": [
{
"NAME": "color",
"TYPE": "color",
"DEFAULT": [1.0, 0.0, 0.0, 1.0]
},
{
"NAME": "scale",
"TYPE": "float",
"DEFAULT": 1.0
}
]
}*/
uniform vec2 RENDERSIZE;
uniform vec4 color;
uniform float scale;
out vec4 fragColor;
void main() {
vec2 uv = gl_FragCoord.xy / RENDERSIZE.xy;
vec2 pos = (uv - 0.5) * scale;
float dist = length(pos);
float circle = smoothstep(0.5, 0.4, dist);
fragColor = color * circle;
}
"""
# Render the shader
with ISFRenderer() as renderer:
# Load shader
metadata = renderer.load_shader_content(test_shader)
# Render with default parameters
image_array = renderer.render(width=512, height=512)
# Render with custom parameters
custom_inputs = {
'color': [0.0, 1.0, 0.0, 1.0], # Green
'scale': 2.0
}
image_array = renderer.render(
width=512, height=512,
inputs=custom_inputs,
metadata=metadata
)
# Save to file
renderer.save_render("output.png", width=512, height=512)
Examples
See the examples/ directory for complete examples:
pure_python_demo.py: Basic usage demonstrationisf_renderer_demo.py: Advanced rendering examples
Development
Building
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/ tests/
isort src/ tests/
# Type checking
mypy src/
Project Structure
pyvvisf/
├── src/pyvvisf/
│ ├── core/
│ │ ├── __init__.py
│ │ ├── renderer.py # Main renderer
│ │ ├── parser.py # ISF parser with json5
│ │ ├── types.py # Value types
│ │ └── errors.py # Error handling
│ ├── __init__.py
│ └── _version.py
├── 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.4.3.tar.gz.
File metadata
- Download URL: pyvvisf-0.4.3.tar.gz
- Upload date:
- Size: 42.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f86f4cf728fd8c8f459273a9aa62bee97ee2d145f7e99e5dfa8a830b9dcc44c4
|
|
| MD5 |
86a35c631e1c75594f5e7b95a455ac86
|
|
| BLAKE2b-256 |
1cc703c1fd2377671dfe16b1b39557b51e0c76e66eb8575d81c99c8ec0b875aa
|
Provenance
The following attestation bundles were made for pyvvisf-0.4.3.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.4.3.tar.gz -
Subject digest:
f86f4cf728fd8c8f459273a9aa62bee97ee2d145f7e99e5dfa8a830b9dcc44c4 - Sigstore transparency entry: 271074754
- Sigstore integration time:
-
Permalink:
jimcortez/pyvvisf@848dc4c3c727053003d804361cfd2c84111b3ae1 -
Branch / Tag:
refs/tags/0.4.3 - Owner: https://github.com/jimcortez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@848dc4c3c727053003d804361cfd2c84111b3ae1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyvvisf-0.4.3-py3-none-any.whl.
File metadata
- Download URL: pyvvisf-0.4.3-py3-none-any.whl
- Upload date:
- Size: 19.0 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 |
cbc5ce527a9175a020f1427cd061dbbe255cbf51ef68f32ca87a9bef464dabfe
|
|
| MD5 |
421ce2f857230db58efec05e5b9ab6fb
|
|
| BLAKE2b-256 |
438a4b4dbbbdd04a041835c3314dae5c5d29f0293d90085381b16d1531020090
|
Provenance
The following attestation bundles were made for pyvvisf-0.4.3-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.4.3-py3-none-any.whl -
Subject digest:
cbc5ce527a9175a020f1427cd061dbbe255cbf51ef68f32ca87a9bef464dabfe - Sigstore transparency entry: 271074755
- Sigstore integration time:
-
Permalink:
jimcortez/pyvvisf@848dc4c3c727053003d804361cfd2c84111b3ae1 -
Branch / Tag:
refs/tags/0.4.3 - Owner: https://github.com/jimcortez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@848dc4c3c727053003d804361cfd2c84111b3ae1 -
Trigger Event:
release
-
Statement type: