wh-engine/wh-engine/render/shaders/basic-shader.lisp

35 lines
1.1 KiB
Common Lisp

;;;; basic-shader.lisp (Lisp shader code)
#|
(define-shader basic-shader
(:version 330)
(:vertex-shader
:in ((vert-pos :type :vec3 :location 0)
(vert-uv :type :vec2 :location 1))
:out ((uv :type :vec2))
:uniform ((model :type :mat4)
(view :type :mat4)
(proj :type :mat4))
:main ((setf *position* (* proj view model (vec4 vert-pos 1.0)))
(setf uv vert-uv)))
(:fragment-shader
:in ((uv :type :vec2))
:out ((*frag-colour* :type :vec4))
:uniform ((main-tex :type :sampler-2d)
(colour :type :vec4))
:main ((setf *frag-colour* (* (sample-texture main-tex uv) colour)))))
|#
(define-shader basic-shader
(:in ((vert-pos :type :vec3 :location 0)
(vert-uv :type :vec2 :location 1))
:out ((*frag-colour* :type :vec4))
:uniform ((model :type :mat4)
(view :type :mat4)
(proj :type :mat4)
(main-tex :type :sampler-2d)
(colour :type :vec4)))
:version 330
:vert ((setf *position* (* proj view model (vec4 vert-pos 1.0))))
:frag ((setf *frag-colour* (* (sample-texture main-tex vert-uv) colour))))