67 lines
2.5 KiB
Common Lisp
67 lines
2.5 KiB
Common Lisp
|
;;;; basic-shaders.lisp (Lisp shader code)
|
||
|
(in-package wh-engine/render)
|
||
|
|
||
|
(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)))
|
||
|
:documentation "Simple shader for 2D sprites."
|
||
|
:version 330
|
||
|
:vert ((setf *position* (* proj view model (vec4 vert-pos 1.0))))
|
||
|
:frag ((setf *frag-colour* (* (sample-texture main-tex vert-uv) colour)))
|
||
|
:options (:depth-test t
|
||
|
:depth-write t
|
||
|
:blend t))
|
||
|
|
||
|
(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)))
|
||
|
:documentation "Shader for compositing render targets together."
|
||
|
: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)))
|
||
|
:options (:depth-test t
|
||
|
:depth-write t
|
||
|
:blend nil))
|
||
|
|
||
|
(define-shader ui-basic-shader
|
||
|
(:in ((vert-pos :type :vec2 :location 0)
|
||
|
(vert-uv :type :vec2 :location 1))
|
||
|
:out ((*frag-colour* :type :vec4))
|
||
|
:uniform ((model :type :mat4)
|
||
|
(proj :type :mat4)
|
||
|
(main-tex :type :sampler-2d)
|
||
|
(colour :type :vec4)))
|
||
|
:documentation "Simple shader for overlay UI."
|
||
|
:version 330
|
||
|
:vert ((setf *position* (* proj model (vec4 vert-pos 1.0 1.0))))
|
||
|
:frag ((setf *frag-colour* (* (sample-texture main-tex vert-uv) colour)))
|
||
|
:options (:depth-test nil
|
||
|
:depth-write nil
|
||
|
:blend t))
|
||
|
|
||
|
(define-shader ui-glyph-shader
|
||
|
(:in ((vert-pos :type :vec2 :location 0)
|
||
|
(vert-uv :type :vec2 :location 1))
|
||
|
:out ((*frag-colour* :type :vec4))
|
||
|
:uniform ((model :type :mat4)
|
||
|
(proj :type :mat4)
|
||
|
(main-tex :type :sampler-2d)
|
||
|
(colour :type :vec3)))
|
||
|
:documentation "Shader for text and other glyphs within overlay UI."
|
||
|
:version 330
|
||
|
:vert ((setf *position* (* proj model (vec4 vert-pos 1.0 1.0))))
|
||
|
:frag ((setf *frag-colour* (vec4 colour (vx (sample-texture main-tex vert-uv)))))
|
||
|
:options (:depth-test nil
|
||
|
:depth-write nil
|
||
|
:blend t))
|