Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Jun 12, 2023
1 parent 5ed005e commit f9c3428
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions renderer/pbr.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
(aref (textures material) 3))

(defmethod shared-initialize :after ((material pbr-material) slots &key metalness-texture roughness-texture occlusion-texture metal-rough-texture)
;; Reshuffle arguments when the textures are badly specified.
(when (and metalness-texture (eq metalness-texture roughness-texture))
(setf metal-rough-texture metalness-texture)
(setf metalness-texture NIL roughness-texture NIL))
(when (and metal-rough-texture (eq metal-rough-texture occlusion-texture))
(setf (aref (textures material) 1) metal-rough-texture)
(setf metal-rough-texture NIL occlusion-texture NIL))
(cond ((and metalness-texture roughness-texture occlusion-texture)
(loop for source in (sources metalness-texture)
do (setf (target source) :r))
Expand Down
13 changes: 13 additions & 0 deletions texture-source.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
(src (list NIL NIL NIL NIL NIL NIL))
(dst (list NIL NIL NIL NIL NIL NIL)))

(defmethod print-object ((source texture-source) stream)
(print-unreadable-object (source stream :type T)
(format stream "~a ~a"
(pixel-type source) (pixel-format source))
(destructuring-bind (x y z w h d) (texture-source-src source)
(when (or x y z w h d)
(format stream " SRC: ~@[~a~]~@[,~a~]~@[,~a~]~@[:~a~]~@[x~a~]~@[x~a~]"
x y z w h d)))
(destructuring-bind (x y z w h d) (texture-source-dst source)
(format stream " DST: ~@[~a~]~@[,~a~]~@[,~a~]~@[:~a~]~@[x~a~]~@[x~a~]"
x y z w h d)
(format stream "~@[ ~a~]~@[ (~a)~]" (target source) (level source)))))

(define-accessor-delegate-methods pixel-data (texture-source-pixel-data texture-source))
(define-accessor-delegate-methods pixel-type (texture-source-pixel-type texture-source))
(define-accessor-delegate-methods pixel-format (texture-source-pixel-format texture-source))
Expand Down

0 comments on commit f9c3428

Please sign in to comment.