summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render/shader.scm26
1 files changed, 18 insertions, 8 deletions
diff --git a/chickadee/render/shader.scm b/chickadee/render/shader.scm
index 1f97a0d..050a81c 100644
--- a/chickadee/render/shader.scm
+++ b/chickadee/render/shader.scm
@@ -279,13 +279,17 @@
(define (shader-struct-default vtable field)
(match (assq-ref (shader-struct-fields vtable) field)
((_ type size)
- (let ((default (if (eq? (struct-vtable type) <shader-struct>)
- (apply make-struct/no-tail type
- (map (match-lambda
- ((sub-field _ _ _)
- (shader-struct-default type sub-field)))
- (shader-struct-fields type)))
- (shader-primitive-type-null type))))
+ (let ((default (cond
+ ((eq? type local-field)
+ #f)
+ ((eq? (struct-vtable type) <shader-struct>)
+ (apply make-struct/no-tail type
+ (map (match-lambda
+ ((sub-field _ _ _)
+ (shader-struct-default type sub-field)))
+ (shader-struct-fields type))))
+ (else
+ (shader-primitive-type-null type)))))
(if (= size 1)
default
(make-vector size default))))))
@@ -749,7 +753,13 @@ shader program."
(if (shader-struct? value)
(uniform-namespace-for-each
(lambda (key uniform)
- (traverse uniform (shader-struct-ref value key)))
+ ;; Samplers are opaque types and you cannot pass them
+ ;; into the shader as uniform values like you can with
+ ;; most other values. In the case of samplers, they are
+ ;; mapped to OpenGL's "texture units", so we need to
+ ;; ignore them here.
+ (unless (eq? (uniform-type uniform) sampler-2d)
+ (traverse uniform (shader-struct-ref value key))))
uniform)
(error "expected shader struct" x)))
;; A nested array namespace indicates that this must be an array