From 03072ef67af0623758a660e2cd3fb5e153133efa Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 24 May 2023 08:09:03 -0400 Subject: Update chickadee manual. --- manuals/chickadee/Shaders.html | 70 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'manuals/chickadee/Shaders.html') diff --git a/manuals/chickadee/Shaders.html b/manuals/chickadee/Shaders.html index 95c5186..505e031 100644 --- a/manuals/chickadee/Shaders.html +++ b/manuals/chickadee/Shaders.html @@ -1,6 +1,6 @@ - - + --> + - + Shaders (The Chickadee Game Toolkit) - - - - - - - - - - - + + + + + + + + + + + - + @@ -84,7 +84,7 @@ ul.no-bullet {list-style: none}

Next: , Previous: , Up: Graphics   [Contents][Index]

-
+

5.3.13 Shaders

Shaders are programs that the GPU can evaluate that allow the @@ -139,10 +139,10 @@ Chickadee uses, is to think about it as a function call: The shader is a function, and it is applied to some “attributes” (positional arguments), and some “uniforms” (keyword arguments).

-
-
(define my-shader (load-shader "vert.glsl" "frag.glsl"))
-(define vertices (make-vertex-array …))
-(shader-apply my-shader vertices #:color red)
+
+
(define my-shader (load-shader "vert.glsl" "frag.glsl"))
+(define vertices (make-vertex-array ...))
+(shader-apply my-shader vertices #:color red)
 

See Rendering Engine for more details about the shader-apply @@ -277,17 +277,17 @@ shader struct.

Some example code will explain this concept best. Here is the Scheme equivalent of the Light struct:

-
-
(define-shader-type <light>
-  make-light
-  light?
-  (bool enabled light-enabled?)
-  (int type light-type)
-  (float-vec3 position light-position)
-  (float-vec3 direction light-direction)
-  (float-vec4 color light-color)
-  (float intensity light-intensity)
-  (float cut-off light-cut-off))
+
+
(define-shader-type <light>
+  make-light
+  light?
+  (bool enabled light-enabled?)
+  (int type light-type)
+  (float-vec3 position light-position)
+  (float-vec3 direction light-direction)
+  (float-vec4 color light-color)
+  (float intensity light-intensity)
+  (float cut-off light-cut-off))
 

The macro define-shader-type closely resembles the familiar @@ -393,7 +393,7 @@ optional.

Return #t if obj is a shader data type object.

-
+

Next: , Previous: , Up: Graphics   [Contents][Index]

-- cgit v1.2.3