Skip to content

Commit 9ff97ec

Browse files
committed
Merge branch 'master' of github.com:gl-modules/shader-school
2 parents cb873ad + 3eb82d9 commit 9ff97ec

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
## Running this thing
1010

1111
First, you need to [get a browser with WebGL](http://get.webgl.org/), as well
12-
as a copy of [node.js](http://nodejs.org/). Once you have all of that set up,
13-
you can install the workshop using [npm](http://npmjs.org/), which is included
14-
with node:
12+
as a copy of [node.js](http://nodejs.org/) and [git](http://git-scm.com/). Once you have
13+
all of that set up, you can install the workshop using [npm](http://npmjs.org/), which
14+
is included with node:
1515

1616
```
1717
npm install -g shader-school

exercises/02-intro-2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void test() {
6565
testFunction(x, y, z, w);
6666
6767
//Now:
68-
// x == 2.0
68+
// x == 1.0
6969
// y == 3.0
7070
// z == 4.0
7171
// w == -1.0

exercises/03-intro-3/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ In this lesson, you will write a GLSL function which computes the unit angle bis
66

77
As an example, if `a = vec2(1,0)` and `b = vec2(0,1)`, then you should return the result `vec2(sqrt(2)/2, sqrt(2)/2)`.
88

9+
**Hint** It is useful to remember the angle bisector theorem. In ascii art, suppose we have two vectors, A and B. Then the angle bisector between A and B is the vector C:
10+
11+
```
12+
B
13+
^
14+
|\
15+
| \^ C
16+
| /\
17+
|/ \
18+
*----> A
19+
O
20+
```
21+
22+
In this situation, the angle bisector theorem tells us the following information about the ratio of the lengths of these vectors:
23+
24+
```glsl
25+
length(B - C) / length(C - A) == length(B) / length(A)
26+
```
27+
28+
Using the above equation, solve for the position of C and then normalize it to unit length.
29+
930
***
1031

1132
After scalars, the next most important data type in GLSL are vectors. GLSL comes with built in types for small vectors with up to 4 components. Like scalars, vectors come in boolean, integer and floating point varieties which are declared using the following syntax:

exercises/05-intro-5/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ vec2 z2 = mandelbrot(z1, c); // 2 iterations
2323
vec2 zn = mandelbrot(zn_1, c); // n iterations
2424
```
2525

26-
As a general principle, say that a point in the Mandelbrot set diverges if it has a magnitude greater than 2:
26+
As a general principle, say that a point in the Mandelbrot set diverges if it has a magnitude greater than 2, so we will classify points as inside the set if their magnitude is less than 2:
2727

2828
```glsl
29-
bool mandelbrotDiverges(vec2 z) {
30-
return length(z) >= 2.0;
29+
bool mandelbrotConverges(vec2 z) {
30+
return length(z) < 2.0;
3131
}
3232
```
3333

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "shader-school",
33
"version": "0.0.0",
4-
"description": "",
4+
"description": "Self directed GLSL lessons",
55
"main": "index.js",
66
"bin": "index.js",
77
"scripts": {

0 commit comments

Comments
 (0)