summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-08-12 20:24:04 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-08-12 20:24:04 -0400
commitf82e5122c2feabb8d92e3d4d1789ee1490b96a90 (patch)
tree7250f80bf5823f1f678efe8c3f2ad3daa03c6cee
parentcaf243c60f84850a9a70c94db577dd2322a782fa (diff)
graphics: texture: Add black, white, gray, and flat convenience textures.
-rw-r--r--chickadee/graphics/texture.scm40
1 files changed, 40 insertions, 0 deletions
diff --git a/chickadee/graphics/texture.scm b/chickadee/graphics/texture.scm
index 5b46af1..b3a9985 100644
--- a/chickadee/graphics/texture.scm
+++ b/chickadee/graphics/texture.scm
@@ -49,6 +49,10 @@
texture-gl-rect
texture-gl-tex-rect
null-texture
+ black-texture
+ white-texture
+ gray-texture
+ flat-texture
g:texture-0
g:texture-1
g:texture-2
@@ -317,6 +321,42 @@ magnification. Valid values are 'nearest and 'linear. By default,
(surface->texture surface min-filter mag-filter wrap-s wrap-t
transparent-color flip?))))
+(define (black-texture)
+ null-texture)
+
+(define %white-texture
+ (delay
+ (make-texture (u32vector #xffffffff #xffffffff #xffffffff #xffffffff)
+ 2 2)))
+
+(define (white-texture)
+ (force %white-texture))
+
+(define %gray-texture
+ (delay
+ (make-texture (u32vector #xff808080 #xff808080 #xff808080 #xff808080)
+ 2 2)))
+
+(define (gray-texture)
+ (force %gray-texture))
+
+;; A "flat" normal map, in tangent space. It's like the identity
+;; property for normals. The colors are used to store 3D tangent space
+;; vectors, with positive Z being "up". Each coordinate is in the
+;; [-1,1] range and then remapped to an 8-bit color channel in the
+;; 0-255 range. Thus, 0 maps to 127 or #x80, -1 maps to 0, and 1 maps
+;; to 255. The color values are in ABGR ordering. A flat tangent
+;; normal is (0, 0, 1), which is encoded as the color #xffff8080.
+;; Such a value means that a mesh's vertex normals remain completely
+;; unchanged by this normal map.
+(define %flat-texture
+ (delay
+ (make-texture (u32vector #xffff8080 #xffff8080 #xffff8080 #xffff8080)
+ 2 2)))
+
+(define (flat-texture)
+ (force %flat-texture))
+
;;;
;;; Texture Atlas