easl

the Enhanced Abstraction Shader Language

A lispy shader language with closures, higher-order functions, sum types, and other high-level features. It can also run from the CPU and share state across the CPU/GPU boundary without any synchronization code.

Read the guide

Quick start guide:

git clone https://github.com/Ella-Hoeppner/easl_cli
cd easl_cli && cargo install --path .
easl run examples/simple.easl

Easl is a work in progress; expect breaking changes.

The background of this page is an easl program, running live in your browser. Edit it in the playground.

This program is normally the background of this page, but your browser doesn't support WebGPU.

(defn vert []: vec4f
  ([(vec4f -1. -1. 0. 1.)
    (vec4f -1. 3. 0. 1.)
    (vec4f 3. -1. 0. 1.)]
   (vertex-index)))

(defn frag []: vec4f
  (let [pos (/ (.xy (position))
               (f32 (.y (window-resolution))))
        distort (fn [x dir drift factor]
                  (+ x
                     (* factor
                        (cos (+ (dot x dir)
                                (* drift (window-time)))))))
        f (fn [x]
            (-> x
                (distort (vec2f -400. 150.) 10.1 0.001)
                (distort (vec2f -12.9 -3.3) 0.15 0.2)
                (distort (vec2f -14.9 8.3) 0.2 0.2)
                (distort (vec2f 13.9 -7.3) -0.1 0.9)
                (distance x)
                (pow 1.75)
                (smoothstep 0. 2.8 <>)))
        center (f pos)]
    (-> (vec3f (- (f (+ pos (vec2f 0.01 0.)))
                  center)
               (- (f (+ pos (vec2f 0. 0.01)))
                  center)
               0.01)
        normalize
        .z
        (mix 0.1 1. <>)
        (* (vec3f (f (- pos 0.0065))
                  center
                  (f (+ pos 0.0065))))
        (pow ~(/ 2.2))
        (vec4f 1.))))

@cpu
(defn main []
  (spawn-window (fn []
                  (dispatch-render-shaders vert frag 3))))