shader stuff

This commit is contained in:
~keith 2022-03-27 18:02:45 +00:00
parent 079990422d
commit 19fb9fb9fb
Signed by: keith
GPG Key ID: 5BEBEEAB2C73D520
2 changed files with 13 additions and 21 deletions

View File

@ -1,6 +1,6 @@
;;;; wh-engine/render/shader.lisp
;;;; Lisp class for holding & handling shaders.
;; (in-package wh-engine/render)
(in-package wh-engine/render)
(defun replace-xref-vars (forms vars replace-fun)
(loop for elt on forms

View File

@ -1,24 +1,5 @@
;;;; 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)))))
|#
(in-package wh-engine/render)
(define-shader basic-shader
(:in ((vert-pos :type :vec3 :location 0)
@ -32,3 +13,14 @@
:version 330
:vert ((setf *position* (* proj view model (vec4 vert-pos 1.0))))
:frag ((setf *frag-colour* (* (sample-texture main-tex vert-uv) colour))))
(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))))