• Stars
    star
    480
  • Rank 91,562 (Top 2 %)
  • Language
    JavaScript
  • Created over 8 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GLSL embedded in Haskell

H Y L O G E N

An embedding of GLSL in Haskell.

H Y L I D E

A live coding environment for writing shaders with Hylogen.



Install

Build from source, using Stack:

  1. Install stack
  2. git clone https://github.com/sleexyz/hylogen.git
  3. cd hylogen
  4. stack build

This is the recommended method of using Hylogen, because using Stack you can share your projects and be confident that others will be using the same version of Hylogen as you. To install it to your system so it can be used anywhere, not just inside the hylogen folder, use stack install instead of stack build.

Hylogen can also be installed to your system using the Haskell Platform:

  1. Install the Haskell Platform
  2. cabal update && cabal install hylogen hylide

Example

Here's a simple Hylogen shader to be used with Hylide, saved as Example.hs (available in the examples/ directory):

module Example where
import Hylogen.WithHylide

output :: Program
output = toProgram color

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 )
            ]

Run Hylide:

$ stack exec hylide Example.hs

If Hylide was installed using the haskell platform, you can omit stack exec:

$ hylide Example.hs

Now go to localhost:5678 in your browser. You'll see a live rendering of the corresponding 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 changes to the Haskell source, sending generated GLSL to the WebGL client over websockets.

References

  • The_Force by Shawn Lawson. This was the initial inspiration for Hylide.
  • data-reify for type-safe observable sharing.

Conceived of at the Recurse Center :)

More Repositories

1

gallium

Web-based environment for livecoding MIDI
JavaScript
19
star
2

dir-loader

Dynamically require a directory in Webpack. Use Webpack as a CMS!
JavaScript
13
star
3

hylogen-fun

hylogen is fun
Haskell
11
star
4

haskell-fun

haskell is fun
Haskell
9
star
5

tabdown

An indentation-based tree descriptor language
JavaScript
7
star
6

efx

Effectful state mangement for React, designed for simplicity, testability and type-safety
JavaScript
5
star
7

rebindable

Better RebindableSyntax for Indexed Monads
Haskell
4
star
8

syzygy

timed event dispatching engine
Haskell
4
star
9

audioprint

Sonify data fingerprints in your browser. Monthly Music Hackathon NYC, March 2015
JavaScript
4
star
10

parachute

Less addictive social media. Slow down Instagram, TikTok, Twitter.
Swift
3
star
11

reloady

node code auto reload
JavaScript
3
star
12

synthetic

Haskell
3
star
13

callable

Type-safe extendable function class
JavaScript
2
star
14

details

<details>
2
star
15

tidal-fun

Haskell
2
star
16

squishy

squishy language
Haskell
2
star
17

haskell-nn

neural networks in Haskell
Haskell
2
star
18

sc

supercollider investigations
SuperCollider
2
star
19

converge

Your AI c̶o̶p̶i̶l̶o̶t̶ cartographer.
TypeScript
1
star
20

untyped

Haskell
1
star
21

H99

ninety-nine haskell problems
Haskell
1
star
22

matasano-haskell

Matasano crypto challenges in Haskell
Haskell
1
star
23

reflex-calculator

Haskell
1
star
24

vivid-yay

Haskell supercollider fun
Haskell
1
star
25

browsersim

TypeScript
1
star
26

TABA-fun

Haskell
1
star
27

react-router-dynamic-matcher

DEPRECATED: Match routes dynamically based on your Redux state
1
star
28

dotfiles

Shell
1
star
29

jest-worker-test

JavaScript
1
star
30

ocaml-fun

fun with ocaml
OCaml
1
star
31

typegrams

Haskell
1
star
32

immutate

ergonomic, type-safe, immutable JS object modification
JavaScript
1
star
33

typesafe-react-redux-example

Typesafe React + Redux Example
JavaScript
1
star
34

schema-histogram

streaming document store schema analytics
JavaScript
1
star
35

js-fun

JavaScript
1
star
36

reasonml-hello

hi world
OCaml
1
star
37

isolation-runner

Proof-of-concept JS test runner with generators (WIP)
JavaScript
1
star
38

jsnn

JavaScript
1
star
39

site-old

my website
JavaScript
1
star
40

flow-react-redux-example

flow + react + redux
JavaScript
1
star
41

cheesebot9000

cheese ai
Haskell
1
star
42

testable-js

JavaScript
1
star