Skip to main content

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 demonstration
  • isf_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

pyvvisf-0.4.3.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvvisf-0.4.3-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

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

Hashes for pyvvisf-0.4.3.tar.gz
Algorithm Hash digest
SHA256 f86f4cf728fd8c8f459273a9aa62bee97ee2d145f7e99e5dfa8a830b9dcc44c4
MD5 86a35c631e1c75594f5e7b95a455ac86
BLAKE2b-256 1cc703c1fd2377671dfe16b1b39557b51e0c76e66eb8575d81c99c8ec0b875aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvvisf-0.4.3.tar.gz:

Publisher: build-wheels.yml on jimcortez/pyvvisf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pyvvisf-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cbc5ce527a9175a020f1427cd061dbbe255cbf51ef68f32ca87a9bef464dabfe
MD5 421ce2f857230db58efec05e5b9ab6fb
BLAKE2b-256 438a4b4dbbbdd04a041835c3314dae5c5d29f0293d90085381b16d1531020090

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvvisf-0.4.3-py3-none-any.whl:

Publisher: build-wheels.yml on jimcortez/pyvvisf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page