hylogen: an EDSL for live-coding fragment shaders

[ graphics, library, mit ] [ Propose Tags ]

an EDSL for live-coding fragment shaders


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.0.6, 0.1.0.8, 0.1.0.10, 0.1.0.11, 0.1.0.12, 0.1.1.0, 0.1.1.1, 0.1.1.2, 0.1.1.3, 0.1.2.0, 0.1.2.1, 0.1.2.2, 0.1.2.3, 0.1.3.0, 0.1.3.1, 0.1.3.2, 0.1.4.0, 0.1.4.1, 0.1.5.0, 0.1.5.1
Dependencies aeson, base (>=4.8 && <5), bytestring, data-reify, filepath, fsnotify, hint, http-types (>=0.9 && <0.10), process, text, vector-space, wai (>=3.2 && <3.3), warp (>=3.2 && <3.3), websockets [details]
License MIT
Author Sean Lee
Maintainer freshdried@gmail.com
Category Graphics
Home page https://github.com/sleexyz/hylogen
Uploaded by sleexyz at 2016-06-07T20:57:17Z
Distributions NixOS:0.1.5.1
Reverse Dependencies 1 direct, 0 indirect [details]
Executables hylide
Downloads 15878 total (62 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for hylogen-0.1.3.2

[back to package description]

H Y L O G E N

Hackage Status Join the chat at https://gitter.im/sleexyz/hylogen

Hylogen is a purely functional language embedded in Haskell for live-coding fragment shaders, featuring:

  • simple and pure syntax
  • standard operators (+, *, *^, <.>)
  • compat. w/ your fav haskell goodies (higher-order functions, ADTS, swanky polymorphism).
  • compiles to GLSL

It comes with hylide, a live WebGL renderer with:

  • hot-reloading
  • audio-reactive primitives
  • texture backbuffering

Install

cabal update
cabal install hylogen

This will install the Hylogen package and hylide, the live renderer.

Usage

Here's a simple Hylogen program, saved as Example.hs:


module Example where
import Hylogen.WithHylide

color :: Vec4
color = vec4 (a, a, a, 1)
  where
    k = 20
    f = (*k) . sin . (/k)
    a = sum [ cos (x_ uvN * f time + x_ mouse )
            , sin (y_ uvN * f time + y_ mouse )
            ]

output :: Program
output = toProgram color

Run hylide:

$ hylide Example.hs

Now go to localhost:5678 in your browser. You'll see a live rendering of the generated GLSL:

void main() {
    float _7 = uvN.x;
    float _10 = (time / 20.0);
    float _9 = sin(_10);
    float _8 = (_9 * 20.0);
    float _6 = (_7 * _8);
    float _11 = mouse.x;
    float _5 = (_6 + _11);
    float _4 = cos(_5);
    float _3 = (0.0 + _4);
    float _15 = uvN.y;
    float _18 = (time / 20.0);
    float _17 = sin(_18);
    float _16 = (_17 * 20.0);
    float _14 = (_15 * _16);
    float _19 = mouse.y;
    float _13 = (_14 + _19);
    float _12 = sin(_13);
    float _2 = (_3 + _12);
    vec4 _1 = vec4(_2, _2, _2, 1.0);

    gl_FragColor = _1;
}

Hylide will recompile on file changes, sending fresh shaders to the WebGL context via websockets.

References

  • The_Force by Shawn Lawson. Live-coding audio-reactive shaders!
  • data-reify by Andy Gill, to keep intermediate AST representations from exploding by preserving the GHC heap's internal sharing

Resources

conceived of at the recurse center :)