summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render/model.scm17
1 files changed, 16 insertions, 1 deletions
diff --git a/chickadee/render/model.scm b/chickadee/render/model.scm
index ec2246b..7771127 100644
--- a/chickadee/render/model.scm
+++ b/chickadee/render/model.scm
@@ -225,6 +225,9 @@
(make-phong-material
#:name name
#:ambient (assq-ref opts 'ambient)
+ #:ambient-map (assq-ref opts 'ambient-map)
+ #:use-ambient-map
+ (assq-ref opts 'use-ambient-map?)
#:diffuse (assq-ref opts 'diffuse)
#:diffuse-map (assq-ref opts 'diffuse-map)
#:use-diffuse-map
@@ -278,7 +281,17 @@
;; Force specular exponent to be a float.
(let ((new-shininess (* (string->number n) 1.0)))
(loop (cons (cons 'shininess new-shininess) opts))))
- (("map_Kd" . args)
+ (("map_Ka" . args) ; ambient map
+ (let* ((ambient-opts (parse-map-args args))
+ (file (scope-file (assq-ref ambient-opts
+ 'file-name)))
+ (texture (load-image file
+ #:min-filter 'linear
+ #:mag-filter 'linear)))
+ (loop (cons* (cons 'ambient-map texture)
+ (cons 'use-ambient-map? #t)
+ opts))))
+ (("map_Kd" . args) ; diffuse map
(let* ((diffuse-opts (parse-map-args args))
(file (scope-file (assq-ref diffuse-opts
'file-name)))
@@ -313,6 +326,8 @@
(maybe-add-material)
(loop `((name . ,new-name)
(ambient . ,(vec3 0.0 0.0 0.0))
+ (ambient-map . ,null-texture)
+ (use-ambient-map? . #f)
(diffuse . ,(vec3 0.0 0.0 0.0))
(diffuse-map . ,null-texture)
(use-diffuse-map? . #f)