2022-03-23 18:16:40 +00:00
|
|
|
;;;; basic-shader.lisp (Lisp shader code)
|
2022-03-27 18:02:45 +00:00
|
|
|
(in-package wh-engine/render)
|
2022-03-23 18:16:40 +00:00
|
|
|
|
|
|
|
(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))))
|
2022-03-27 18:02:45 +00:00
|
|
|
|
|
|
|
(define-shader render-target-blit-shader
|
|
|
|
(:in ((vert-pos :type :vec2 :location 0))
|
|
|
|
:out ((*frag-colour* :type :vec4)
|
|
|
|
(*frag-depth* :type :float))
|
|
|
|
:uniform ((main-tex :type :sampler-2d)
|
|
|
|
(depth-tex :type :depth-sampler-2d)))
|
|
|
|
:version 330
|
|
|
|
:vert ((setf *position* (vec4 vert-pos 0.0 1.0)))
|
|
|
|
:frag ((setf *frag-colour* (sample-texture main-tex vert-pos)
|
|
|
|
*frag-depth* (sample-texture depth-tex vert-pos))))
|