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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyvvisf-0.8.0.tar.gz
  • Upload date:
  • Size: 617.3 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.0.tar.gz
Algorithm Hash digest
SHA256 08b4dfb09bcdbf071ae3d82e2bea49372ff4b93d032090056fc59b4c23c6249c
MD5 b27ee1d6604fac1e8134f8d9968fab6f
BLAKE2b-256 a7c7ddb9ca1d4525932e573b8613ba696ddd6aeec12767d76f94f8a1b2e69321

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyvvisf-0.8.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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 459e1e34b625ccf6cb9f16a06c673fffcbf38acadd28b71ad7ed3ffca16e6f79
MD5 514ecf5c3662aa117d24cd665dd57de3
BLAKE2b-256 e9dc180e98090acd14a89ea0a50437a89b716640114f747ddce78b1c10883581

See more details on using hashes here.

Provenance

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