@@ -82,16 +82,22 @@ <h1>WebGL Fundamentals</h1>
82
82
< p > Nearly all of the entire WebGL API is about setting up state for these pairs of functions to run. You setup
83
83
a bunch of state then execute a pair of functions by calling < code > gl.drawArrays</ code > or < code > gl.drawElements</ code > which
84
84
executes your shaders on the GPU.</ p >
85
- < p > Any data you want those functions to have accessed to must be provided to the GPU. There are 4 ways
85
+ < p > Any data you want those functions to have accesse to must be provided to the GPU. There are 4 ways
86
86
a shader can receive data.</ p >
87
87
< ol >
88
88
< li > < p > Attributes and Buffers</ p >
89
- < p > Buffers are arrays of binary data you upload to the GPU. Attributes are used to specify how to
89
+ < p > Buffers are arrays of binary data you upload to the GPU. Usually buffers contain
90
+ things like positions, normals, texture coordinates, vertex colors, etc although
91
+ you're free to put anything you want in them.</ p >
92
+ < p > Attributes are used to specify how to
90
93
pull data how of your buffers and provide them to your vertex shader.
91
94
For example you might put positions in a buffer as three 32bit floats
92
- per position. You would tell a particular attribute which buffer to pull the data out of, what type
93
- of data it shoudl pull out (3 component 32 bit floating point numbers), what offset
95
+ per position. You would tell a particular attribute which buffer to pull the positions out of, what type
96
+ of data it should pull out (3 component 32 bit floating point numbers), what offset
94
97
in the buffer the positions start, and how many bytes to get from one position to the next.</ p >
98
+ < p > Buffers are not random access. Instead a vertex shaders is executed a specified number
99
+ of times. Each time it's executed the next value from each specified buffers is pulled
100
+ out assigned to an attribute.</ p >
95
101
</ li >
96
102
< li > < p > Uniforms</ p >
97
103
< p > Uniforms are effectively global variables you set before you execute your shader program.</ p >
@@ -110,7 +116,7 @@ <h1>WebGL Fundamentals</h1>
110
116
< h2 id ="webgl-hello-world "> WebGL Hello World</ h2 >
111
117
< p > WebGL only cares about 2 things. Clipspace coordinates and colors.
112
118
Your job as a programmer using WebGL is to provide WebGL with those 2 things.
113
- You provide 2 "shaders" to do this. A Vertex shader which provides the
119
+ You provide your 2 "shaders" to do this. A Vertex shader which provides the
114
120
clipspace coordinates and a fragment shader that provides the color.</ p >
115
121
< p > Clipspace coordinates always go from -1 to +1 no matter what size your
116
122
canvas is. Here is a simple WebGL example that shows WebGL in its simplest form.</ p >
0 commit comments