Permalink
Browse files

Minor change to shader pass protocol

  • Loading branch information...
Shinmera committed Jan 30, 2019
1 parent 7a4e1da commit 4f2080068a6ebff4e3fc08dbe56135b3433e4d7b
Showing with 15 additions and 11 deletions.
  1. +3 −0 shader-entity.lisp
  2. +10 −9 shader-pass.lisp
  3. +2 −2 shadow-map.lisp
@@ -136,6 +136,9 @@
(defmethod remove-class-shader (type (class symbol))
(remove-class-shader type (find-class class)))

(defmethod effective-shader (type thing)
(getf (effective-shaders thing) type))

(defmethod effective-shader-class ((name symbol))
(effective-shader-class (find-class name)))

@@ -75,8 +75,8 @@

(defgeneric register-object-for-pass (pass object))
(defgeneric shader-program-for-pass (pass object))
(defgeneric make-pass-shader-program (pass class))
(defgeneric coerce-pass-shader (pass class type spec))
(defgeneric make-pass-shader-program (pass object))
(defgeneric coerce-pass-shader (pass object type))

(defmethod make-pass-shader-program (pass (class symbol))
(make-pass-shader-program pass (find-class class)))
@@ -87,11 +87,10 @@
(defmethod make-pass-shader-program ((pass shader-pass) (class shader-entity-class))
(let ((shaders ())
(buffers ()))
;; FIXME: What if the pass defines types that the class does not?
(loop for (type spec) on (effective-shaders class) by #'cddr
for inputs = (coerce-pass-shader pass class type spec)
(loop for type in *shader-type-list*
for inputs = (coerce-pass-shader pass class type)
for shader = (make-instance 'shader :source inputs :type type)
do (push shader shaders))
do (when inputs (push shader shaders)))
(loop for asset-spec in (effective-buffers class)
do (push (apply #'asset asset-spec) buffers))
(loop for asset-spec in (effective-buffers pass)
@@ -180,9 +179,11 @@
(defmethod shader-program-for-pass ((pass per-object-pass) (subject shader-entity))
(gethash (effective-shader-class subject) (assets pass)))

(defmethod coerce-pass-shader ((pass per-object-pass) class type spec)
(glsl-toolkit:merge-shader-sources
(list spec (getf (effective-shaders pass) type))))
(defmethod coerce-pass-shader ((pass per-object-pass) class type)
(let ((sources (remove NIL (list (effective-shader type class)
(effective-shader type pass)))))
(when sources
(glsl-toolkit:merge-shader-sources sources))))

(defmethod register-object-for-pass ((pass per-object-pass) o))

@@ -21,8 +21,8 @@
"#version 330 core
void main(){}")

(defmethod coerce-pass-shader ((pass shadow-map-pass) class (type (eql :fragment-shader)) spec)
(getf (effective-shaders pass) type))
(defmethod coerce-pass-shader ((pass shadow-map-pass) class (type (eql :fragment-shader)))
(effective-shader type pass))

(defmethod paint-with ((pass shadow-map-pass) target)
(with-pushed-matrix ((projection-matrix (shadow-projection-matrix pass))

0 comments on commit 4f20800

Please sign in to comment.