Skip to content

Instantly share code, notes, and snippets.

@psilord
Created February 22, 2018 22:50
Show Gist options
  • Save psilord/9b0dd84165ce47ce3878a80bf185ce5e to your computer and use it in GitHub Desktop.
Save psilord/9b0dd84165ce47ce3878a80bf185ce5e to your computer and use it in GitHub Desktop.
(in-package :fl.core)
(defstruct-gpu texture-struct ()
(sampler1 :sampler-2d :accessor sampler1)
(sampler2 :sampler-2d :accessor sampler2))
(define-gpu default-vertex ((pos :vec3)
(normal :vec3)
(tangent :vec3)
(color :vec4)
(uv1 :vec2)
(uv2 :vec2)
(joints :vec4)
(weights :vec4)
&uniform
(model :mat4)
(view :mat4)
(proj :mat4))
(values
;; position is implicitly first
(* proj view model (vec4 pos 1))
;; Then the rest must match the fragment shader lambda-list
normal
tangent
color
uv1
uv2))
(define-gpu color-decal-fragment ((normal :vec3)
(tangent :vec3)
(color :vec4)
(uv1 :vec2)
(uv2 :vec2)
&uniform
(tex texture-struct))
(if (zerop color)
(discard)
color))
(define-gpu color-fragment ((normal :vec3)
(tangent :vec3)
(color :vec4)
(uv1 :vec2)
(uv2 :vec2)
&uniform
(tex texture-struct))
color)
(define-gpu texture-fragment ((normal :vec3)
(tangent :vec3)
(color :vec4)
(uv1 :vec2)
(uv2 :vec2)
&uniform
(tex texture-struct))
(* (texture (sampler1 tex) uv1) color))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment