Skip to content

Instantly share code, notes, and snippets.

@davexunit
Created July 12, 2022 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davexunit/a861ccfabc9843b32c95aaead1879572 to your computer and use it in GitHub Desktop.
Save davexunit/a861ccfabc9843b32c95aaead1879572 to your computer and use it in GitHub Desktop.
S-expression representation of GLSL
(define-graphics-variable sprite-shader
(make-shader*
((in vec2 position)
(in vec2 tex)
(out vec2 fragTex)
(uniform mat4 mvp)
(define (void main)
(= fragTex tex)
(= gl_Position (* mvp (vec4 (-> position xy) 0.0 1.0)))))
((in vec2 fragTex)
(out vec4 fragColor)
(uniform sampler2D colorTexture)
(uniform vec4 tint)
(define (void main)
(= fragColor (* (texture colorTexture fragTex) tint))))))
;; Generated vertex shader code:
;; in vec2 position;in vec2 tex;out vec2 fragTex;uniform mat4 mvp;void main(){(fragTex = tex);(gl_Position = (mvp * vec4(position.xy,0.0,1.0)));};
;; Generated fragment shader code:
;; in vec2 fragTex;out vec4 fragColor;uniform sampler2D colorTexture;uniform vec4 tint;void main(){(fragColor = (texture(colorTexture,fragTex) * tint));};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment