summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2019-10-29 17:17:19 -0400
committerDavid Thompson <dthompson2@worcester.edu>2019-10-29 17:17:19 -0400
commitec15aa537055159fc94f667a9219dde27deefb89 (patch)
treeb811b59b9ca819a5c8addc78ae3f67e178d5eab3
parent2db2137911639b9a772a9de7cdcdf611d5ab747f (diff)
render: model: Invert texture V coords when parsing OBJ files.
-rw-r--r--chickadee/render/model.scm9
1 files changed, 7 insertions, 2 deletions
diff --git a/chickadee/render/model.scm b/chickadee/render/model.scm
index 332d211..9f29240 100644
--- a/chickadee/render/model.scm
+++ b/chickadee/render/model.scm
@@ -377,10 +377,15 @@
((u)
(vec2 (string->number u) 0.0))
((u v)
- (vec2 (string->number u) (string->number v)))
+ ;; OBJ texture coordinates use the
+ ;; top-left of the image as the origin,
+ ;; but OpenGL uses the bottom-left, so
+ ;; all V values must be inverted.
+ (vec2 (string->number u)
+ (- 1.0 (string->number v))))
((u v w)
(vec2 (string->number u)
- (string->number v)))
+ (- 1.0 (string->number v))))
(_
(parse-error "wrong number of texcoord arguments" args)))))
(define (parse-normal args)