Skip to content

Commit 8ce0806

Browse files
committed
Finised chapter 08 and created a new chapter for markers
1 parent 941c366 commit 8ce0806

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1313
-465
lines changed

07-points.rst

Lines changed: 197 additions & 126 deletions
Large diffs are not rendered by default.

08-markers.rst

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
Rendering markers
2+
===============================================================================
3+
4+
.. contents:: .
5+
:local:
6+
:depth: 2
7+
:class: toc chapter-08
8+
9+
..
10+
.. figure:: movies/chapter-07/triangles.mp4
11+
:loop:
12+
:autoplay:
13+
:controls:
14+
:figwidth: 30%
15+
:figclass: right
16+
17+
Figure
18+
19+
20+
21+
.. figure:: movies/chapter-07/ellipses.mp4
22+
:loop:
23+
:autoplay:
24+
:controls:
25+
:figwidth: 30%
26+
:figclass: right
27+
28+
Figure
29+
30+
31+
Constructive Solid Geometry
32+
-------------------------------------------------------------------------------
33+
34+
35+
.. figure:: images/chapter-07/CSG.png
36+
:figwidth: 50%
37+
:figclass: right
38+
39+
Figure
40+
41+
Constructive solid geometry (CSG) allows a to create a complex object by using
42+
Boolean operators to combine simpler objects.
43+
44+
45+
Constructive solid geometry (CSG) is a technique used for modeling in order to
46+
create a complex object by using Boolean operators to combine simpler objects
47+
(primitives). Resulting objects appear visually complex but are actually a
48+
cleverly combined or decombined objects. The teaser image in the `GLSL
49+
References`_ chapter is the result of `complex constructive geometry in 3D
50+
<http://iquilezles.org/www/articles/distfunctions/distfunctions.htm>`_. See
51+
also the Wikipedia entry on `Truth function
52+
<https://en.wikipedia.org/wiki/Truth_function>`_.
53+
54+
This is the reason we did not bother to try to render complex shapes in the
55+
previous section. Using constructive solid geometry, we are free to model
56+
pretty much anything and we'll see that in the markers section below. In the
57+
meantime, we need to define our CSG operations in glsl. The good news is that
58+
it is incredibly simple, just read:
59+
60+
.. code:: glsl
61+
62+
// Union (A or B)
63+
float csg_union(float d1, float d2)
64+
{ return min(d1,d2); }
65+
66+
// Difference (A not B)
67+
float csg_difference(float d1, float d2)
68+
{ return max(d1,-d2); }
69+
70+
// Intersection (A and B)
71+
float csg_intersection(float d1, float d2)
72+
{ return max(d1,d2); }
73+
74+
// Exclusion (A xor B)
75+
float csg_exclusion(float d1, float d2)
76+
{ return min(max(d1,-d2), max(-d1,d2)); }
77+
78+
79+
And we can check for the result using two circles (the shadertoy link for each
80+
example allows you to play online with them):
81+
82+
83+
.. figure:: images/chapter-07/CSG-intersection.png
84+
:figwidth: 30%
85+
:figclass: right
86+
87+
Figure
88+
89+
| Intersection (A and B)
90+
| `CSG-intersection.py <code/chapter-07/csg-intersection.py>`_ / `Shadertoy`__
91+
92+
__ https://www.shadertoy.com/view/XllyWn
93+
94+
.. figure:: images/chapter-07/CSG-union.png
95+
:figwidth: 30%
96+
:figclass: right
97+
98+
Figure
99+
100+
| Union (A or B)
101+
| `CSG-union.py <code/chapter-07/csg-union.py>`_ / `Shadertoy`__
102+
103+
__ https://www.shadertoy.com/view/4tlyWn
104+
105+
.. figure:: images/chapter-07/CSG-mix.png
106+
:figwidth: 30%
107+
:figclass: right
108+
109+
Figure
110+
111+
| Two SDF circles (A, B)
112+
| `CSG-mix.py <code/chapter-07/csg-mix.py>`_ / `Shadertoy`__
113+
114+
__ https://www.shadertoy.com/view/MtfcDr
115+
116+
----
117+
118+
.. figure:: images/chapter-07/CSG-exclusion.png
119+
:figwidth: 30%
120+
:figclass: right
121+
122+
Figure
123+
124+
| Exclusion (A xor B)
125+
| `CSG-exclusion.py <code/chapter-07/csg-exclusion.py>`_ / `Shadertoy`__
126+
127+
__ https://www.shadertoy.com/view/4tsyWn
128+
129+
130+
.. figure:: images/chapter-07/CSG-difference-2.png
131+
:figwidth: 30%
132+
:figclass: right
133+
134+
Figure
135+
136+
| Difference (A not B)
137+
| `CSG-difference-2.py <code/chapter-07/csg-difference-2.py>`_ / `Shadertoy`__
138+
139+
__ https://www.shadertoy.com/view/XtsyWn
140+
141+
.. figure:: images/chapter-07/CSG-difference-1.png
142+
:figwidth: 30%
143+
:figclass: right
144+
145+
Figure
146+
147+
| Difference (B not A)
148+
| `CSG-difference-1.py <code/chapter-07/csg-difference-1.py>`_ / `Shadertoy`__
149+
150+
__ https://www.shadertoy.com/view/4llyWn
151+
152+
153+
.. figure:: images/chapter-07/CSG-markers.png
154+
:figwidth: 50%
155+
:figclass: right
156+
157+
Figure
158+
159+
Some example of markers constructed using CSG.
160+
161+
162+
Arrows
163+
-------------------------------------------------------------------------------
164+
165+
166+
167+
168+
169+
Boundings boxes
170+
-------------------------------------------------------------------------------

08-lines.rst renamed to 09-lines.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ Rendering lines
44
.. contents:: .
55
:local:
66
:depth: 2
7-
:class: toc chapter-08
7+
:class: toc chapter-09
88

99
Segments
1010
--------
1111

12-
.. figure:: images/chapter-08/segment.png
12+
.. figure:: images/chapter-09/segment.png
1313
:figwidth: 50%
1414

1515
Figure

09-polygons.rst renamed to 10-polygons.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rendering a polygon
44
.. contents:: .
55
:local:
66
:depth: 2
7-
:class: toc chapter-09
7+
:class: toc chapter-10
88

99

1010
Triangulation

10-meshes.rst renamed to 11-meshes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rendering a mesh
44
.. contents:: .
55
:local:
66
:depth: 2
7-
:class: toc chapter-10
7+
:class: toc chapter-11
88

99

1010
Implicit surfaces

11-text.rst renamed to 12-text.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rendering text
44
.. contents:: .
55
:local:
66
:depth: 2
7-
:class: toc chapter-11
7+
:class: toc chapter-12
88

99

1010
Failsafe text

12-framebuffer.rst renamed to 13-framebuffer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Framebuffer
44
.. contents:: .
55
:local:
66
:depth: 2
7-
:class: toc chapter-12
7+
:class: toc chapter-13
88

99
Post-processing
1010
---------------

13-special.rst renamed to 14-special.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Special techniques
44
.. contents:: .
55
:local:
66
:depth: 2
7-
:class: toc chapter-13
7+
:class: toc chapter-14
88

99

1010
Colormaps
File renamed without changes.

15-glsl-reference.rst renamed to 16-glsl-reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ GLSL References
66
.. contents:: .
77
:local:
88
:depth: 2
9-
:class: toc chapter-15
9+
:class: toc chapter-16
1010

1111

1212
The information below has been directly extracted and reformated from the `GLES

16-bibliography.rst renamed to 17-bibliography.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Bibliography
55
.. contents:: .
66
:local:
77
:depth: 2
8-
:class: toc chapter-16
8+
:class: toc chapter-17
99

1010

1111
This is a curated list of some computer graphics resources (peoole, articles,

book.css

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ body {
9292
}
9393

9494
/* Buy the book !!! */
95-
#id54 {
95+
#id56 {
9696
padding-top: .25em;
9797
padding-bottom: .25em;
9898
color: #ffffff;
@@ -447,64 +447,72 @@ a:active {
447447

448448

449449
.chapter-01 .topic-title {
450-
background: url("images/chapter-01/chapter-01.png") no-repeat center;
450+
background: url("images/chapter-01/toc.png") no-repeat center;
451451
background-size: 100%;
452452
}
453453
.chapter-02 .topic-title {
454-
background: url("images/chapter-02/chapter-02.jpg") no-repeat center;
454+
background: url("images/chapter-02/toc.png") no-repeat center;
455455
background-size: 100%;
456456
}
457457
.chapter-03 .topic-title {
458-
background: url("images/chapter-03/chapter-03.png") no-repeat center;
458+
background: url("images/chapter-03/toc.png") no-repeat center;
459459
background-size: 100%;
460460
}
461461
.chapter-04 .topic-title {
462-
background: url("images/chapter-04/chapter-04.jpg") no-repeat center;
462+
background: url("images/chapter-04/toc.png") no-repeat center;
463463
background-size: 125%;
464464
}
465465
.chapter-05 .topic-title {
466-
background: url("images/chapter-05/chapter-05.png") no-repeat center;
466+
background: url("images/chapter-05/toc.png") no-repeat center;
467467
background-size: 100%;
468468
}
469469
.chapter-06 .topic-title {
470-
background: url("images/chapter-06/chapter-06.jpg") no-repeat center;
470+
background: url("images/chapter-06/toc.png") no-repeat center;
471471
background-size: 100%;
472472
background-position: center 25%;
473473
}
474474
.chapter-07 .topic-title {
475-
background: url("images/chapter-07/chapter-07.png") no-repeat center;
475+
background: url("images/chapter-07/toc.png") no-repeat center;
476476
background-size: 100%;
477477
}
478478
.chapter-08 .topic-title {
479-
background: url("images/chapter-08/chapter-08.png") no-repeat center;
479+
background: url("images/chapter-08/toc.png") no-repeat center;
480480
background-size: 120%;
481481
}
482482
.chapter-09 .topic-title {
483-
background: url("images/chapter-09/chapter-09.png") no-repeat center;
483+
background: url("images/chapter-09/toc.png") no-repeat center;
484484
background-size: 100%;
485485
}
486486
.chapter-10 .topic-title {
487-
background: url("images/chapter-10/chapter-10.png") no-repeat center;
487+
background: url("images/chapter-10/toc.png") no-repeat center;
488488
background-size: 100%;
489489
}
490490
.chapter-11 .topic-title {
491-
background: url("images/chapter-11/chapter-11.png") no-repeat center;
491+
background: url("images/chapter-11/toc.png") no-repeat center;
492492
background-size: 100%;
493493
}
494+
.chapter-12 .topic-title {
495+
background: url("images/chapter-12/toc.png") no-repeat center;
496+
c background-size: 100%;
497+
}
494498
.chapter-13 .topic-title {
495-
background: url("images/chapter-13/chapter-13.png") no-repeat center;
496-
background-size: 125%;
499+
background: url("images/chapter-13/toc.png") no-repeat center;
500+
background-size: 100%;
497501
}
498502
.chapter-14 .topic-title {
499-
background: url("images/chapter-15/chapter-15.png") no-repeat center;
500-
background-size: 175%;
503+
background: url("images/chapter-14/toc.png") no-repeat center;
504+
background-size: 125%;
501505
}
502506
.chapter-15 .topic-title {
503-
background: url("images/chapter-15/chapter-15.png") no-repeat center;
504-
background-size: 175%;
507+
background: url("images/chapter-15/toc.png") no-repeat center;
508+
background-size: 125%;
505509
}
506510
.chapter-16 .topic-title {
507-
background: url("images/chapter-16/chapter-16.jpg") no-repeat center;
511+
background: url("images/chapter-16/toc.png") no-repeat center;
512+
background-size: 175%;
513+
}
514+
.chapter-17 .topic-title {
515+
background: url("images/chapter-17/toc.png") no-repeat center;
508516
background-size: 125%;
509517
}
510518

0 commit comments

Comments
 (0)