Skip to main content

Pure Python ISF shader renderer with PyOpenGL and json5

Project description

pyvvisf

Pure Python ISF (Interactive Shader Format) renderer built on PyOpenGL.

CI Read the Docs PyPI version Python versions License: MIT GitHub release

isf_window_demo.py running shapes.fs

pyvvisf parses and renders ISF shaders from Python — to images or to an interactive window — without any C++ build step. It is a modern, pure-Python alternative to VVISF-GL, with enhanced error reporting that mirrors the official ISF online editor's diagnostics. Originally written to power ai-shader-tool, it gives AI agents (and humans) a way to validate, render, and inspect generated shaders. The majority of code in this repository was built with AI.

Docs | PyPI | Issue Tracker

Features

  • Pure Python — no C++ compilation required
  • Robust ISF parsing with json5 (comments, trailing commas)
  • Modern OpenGL via PyOpenGL + GLFW for cross-platform contexts
  • Enhanced error reporting with Python-native messages and shader context
  • Type-safe metadata via Pydantic models, with auto-coercion for inputs
  • Multi-version GLSL support with automatic detection
  • ISF 2.0 compliant — multi-pass rendering, imports, IMG_THIS_PIXEL, IMG_PIXEL, IMG_SIZE, etc.
  • Context-managed resources for clean setup and teardown

Contents

Quick Start

See the docs for a comprehensive overview.

Requirements

  • Python 3.10+
  • A working OpenGL driver (the renderer uses GLFW + PyOpenGL)

Setup Instructions

Install from PyPI:

pip install pyvvisf

Or install from source for development:

git clone https://github.com/jimcortez/pyvvisf.git
cd pyvvisf
pip install -e ".[dev]"

Run Instructions

Render an ISF shader to a PNG:

from pyvvisf import ISFRenderer

shader = """
/*{
    "DESCRIPTION": "Every pixel is the selected color.",
    "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(shader) as renderer:
    renderer.render(512, 512).to_pil_image().save("output_red.png")

    renderer.set_input("color", (0.0, 1.0, 0.0, 1.0))
    renderer.render(512, 512).to_pil_image().save("output_green.png")

Usage Examples

  • examples/isf_renderer_demo.py — render shaders to images, set inputs, save output
  • examples/isf_window_demo.py — interactive window display (screenshot above)
  • examples/time_offset_demo.py — capture frames at arbitrary time offsets

Bundled shaders in examples/shaders/:

  • simple.fs — fills the screen with blue
  • simple_color_change.fs — single color input
  • simple_color_animation.fs — fades between two colors over time
  • shapes.fs — animated moving circle, rotating rectangle, pulsating ring

To pin a specific GLSL version or query what's available:

from pyvvisf import ISFRenderer, get_supported_glsl_versions

print(get_supported_glsl_versions())
renderer = ISFRenderer(shader_content, glsl_version="330")

The default is '330'. The library compiles a probe shader at construction time to verify compatibility.

Test Instructions

pip install -e ".[dev]"
pytest

Running headless (Docker, CI, servers)

pyvvisf needs a real OpenGL context. On a headless Linux box, wrap the process in xvfb-run:

sudo apt-get install -y xvfb
xvfb-run -a python my_render_script.py

In GitHub Actions, the pyvista/setup-headless-display-action step provides a display on Linux, macOS, and Windows runners — see .github/workflows/ci.yml for an example.

License

See LICENSE — MIT.

Support

Maintainer: @jimcortez. For bugs and feature requests, please use the issue tracker.

Acknowledgments

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.8.1.tar.gz (620.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.8.1-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file pyvvisf-0.8.1.tar.gz.

File metadata

  • Download URL: pyvvisf-0.8.1.tar.gz
  • Upload date:
  • Size: 620.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyvvisf-0.8.1.tar.gz
Algorithm Hash digest
SHA256 c3d1948aa11a7333d51da1be42c84975c27e64daf5c2ca8059fba4370a129108
MD5 6bd952e2d53b9d4ddf2b3e42375f7da7
BLAKE2b-256 6c46bfc2f2f472e80da74daf2a56dfadd46791de4a677f5aaeb0a86a15106595

See more details on using hashes here.

Provenance

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

Publisher: release.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.8.1-py3-none-any.whl.

File metadata

  • Download URL: pyvvisf-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyvvisf-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 253337a9929f0eca7f9e18fd44c6c56c87d537b3fe472ea5ecfc37ce53c481cd
MD5 a37ca2180102aec9fc75eb3c19761bef
BLAKE2b-256 8c431055f4d3efa5f3686dd0e6f3f453448138a9d738b2855e8d8fd372d3fc9c

See more details on using hashes here.

Provenance

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

Publisher: release.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