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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyvvisf-0.9.0.tar.gz
Algorithm Hash digest
SHA256 893ef044bfe5b487ad6f77034da3603bfbdcc638fc463458ed4d1f57a508ce04
MD5 4136cc97d8468334274194cf1aa87c4d
BLAKE2b-256 a50ac71f151a6a408fa6140d6b3820d8786185dc5b9f6ed591ca47aa017d5453

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvvisf-0.9.0.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.9.0-py3-none-any.whl.

File metadata

  • Download URL: pyvvisf-0.9.0-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.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57988996328a97c4353dbf938215c0d0343efe94fac6b5a7c80a353939279e67
MD5 d4559859efeb6a57d043e4c53421ac5b
BLAKE2b-256 a90e4860047f75fa0c4f5ce94198c17954ccd8def36152f472ef751c1747039e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvvisf-0.9.0-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