Skip to content

Commit e251353

Browse files
committed
Relocation episode II
1 parent 54ae45c commit e251353

Some content is hidden

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

56 files changed

+123
-123
lines changed

05-cube.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ by compositing a rotation the z axis (`theta`), then around the y axis (`phi`):
169169
Actual rendering
170170
-------------------------------------------------------------------------------
171171

172-
.. figure:: data/solid-cube.mp4
172+
.. figure:: movies/chapter-05/solid-cube.mp4
173173
:loop:
174174
:autoplay:
175175
:controls:
@@ -202,7 +202,7 @@ endless animation:
202202
203203
app.run(framerate=60, framecount=360)
204204
205-
Complete source code: `<code/solid-cube.py>`_
205+
Complete source code: `<code/chapter-05/solid-cube.py>`_
206206

207207

208208

@@ -253,7 +253,7 @@ shader.
253253
} """
254254
255255
256-
.. figure:: data/color-cube.mp4
256+
.. figure:: movies/chapter-05/color-cube.mp4
257257
:loop:
258258
:autoplay:
259259
:controls:
@@ -282,14 +282,14 @@ But we could also have written
282282
cube["position"] = V["position"]
283283
cube["color"] = V["color"]
284284
285-
Complete source code: `<code/color-cube.py>`_
285+
Complete source code: `<code/chapter-05/color-cube.py>`_
286286

287287

288288

289289
Outlined cube
290290
+++++++++++++
291291

292-
.. figure:: data/outline-cube.mp4
292+
.. figure:: movies/chapter-05/outline-cube.mp4
293293
:loop:
294294
:autoplay:
295295
:controls:
@@ -354,13 +354,13 @@ are drawn "above" the cube because we paint a line on a surface:
354354
glm.rotate(model, phi, 0, 1, 0)
355355
cube['model'] = model
356356
357-
Complete source code: `<code/outlined-cube.py>`_
357+
Complete source code: `<code/chapter-05/outlined-cube.py>`_
358358

359359

360360
Textured cube
361361
+++++++++++++
362362

363-
.. figure:: data/texture-cube.mp4
363+
.. figure:: movies/chapter-05/texture-cube.mp4
364364
:loop:
365365
:autoplay:
366366
:controls:
@@ -454,12 +454,12 @@ Now, inside the fragment shader, we have access to the texture:
454454
} """
455455
456456
457-
Complete source code: `<code/textured-cube.py>`_
457+
Complete source code: `<code/chapter-05/textured-cube.py>`_
458458

459459
Exercises
460460
-------------------------------------------------------------------------------
461461

462-
.. figure:: data/color-border-cube-1.mp4
462+
.. figure:: movies/chapter-05/color-border-cube-1.mp4
463463
:loop:
464464
:autoplay:
465465
:controls:
@@ -478,14 +478,14 @@ is possible to get more or less the same results from within the shader in a
478478
single pass. The trick is to pass the (untransformed) position from the vertex
479479
shader to the fragment shader and to use this information to set the color of
480480
the fragment to either the black color or the v_color. Starting from the `color
481-
cube code <code/chapter-03/color-cube.py>`_, try to modify only the shader code
481+
cube code <code/chapter-05/color-cube.py>`_, try to modify only the shader code
482482
(both vertex and fragment) to achieve the result on the right.
483483

484-
**Solution**: `<code/border-cube.py>`_
484+
**Solution**: `<code/chapter-05/border-cube.py>`_
485485

486486
----
487487

488-
.. figure:: data/color-border-cube-2.mp4
488+
.. figure:: movies/chapter-05/color-border-cube-2.mp4
489489
:loop:
490490
:autoplay:
491491
:controls:
@@ -504,7 +504,7 @@ instructs OpenGL to not display the fragment at all and to terminate the
504504
program frot this shader. Since nothing will be rendered, there is no need to
505505
process the rest of program.
506506

507-
**Solution**: `<code/hollow-cube.py>`_
507+
**Solution**: `<code/chapter-05/hollow-cube.py>`_
508508

509509
----
510510

06-anti-grain.rst

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Anti-grain geometry
32
===============================================================================
43

@@ -8,7 +7,7 @@ Anti-grain geometry
87
:class: toc chapter-06
98

109

11-
.. image:: data/mcseem.jpg
10+
.. image:: images/chapter-06/mcseem.jpg
1211
:class: right
1312
:width: 20%
1413

@@ -29,7 +28,7 @@ do the job and we'll need to take care of pretty much everything.
2928
Antialiasing
3029
-------------------------------------------------------------------------------
3130

32-
.. figure:: data/circle-aa-none.png
31+
.. figure:: images/chapter-06/circle-aa-none.png
3332
:figwidth: 50%
3433
:figclass: right
3534

@@ -68,7 +67,7 @@ approximate shape for small sizes as well.
6867
Sample based methods
6968
++++++++++++++++++++
7069

71-
.. figure:: data/circle-aa-multisample.png
70+
.. figure:: images/chapter-06/circle-aa-multisample.png
7271
:figwidth: 45%
7372
:figclass: right
7473

@@ -111,7 +110,7 @@ methods. If they are great for real-time rendering such as video games (and
111110
some of them are really good), they are hardly sufficient for any scientific
112111
visualization as illustrated on the figure below.
113112

114-
.. figure:: data/ssaa-sdf.png
113+
.. figure:: images/chapter-06/ssaa-sdf.png
115114
:figwidth: 100%
116115

117116
Figure
@@ -120,10 +119,10 @@ visualization as illustrated on the figure below.
120119
patterns. The more samples , the better the output but even using 64
121120
samples, the rendering quality does not match the SDF rendering, especially
122121
if you consider triangle sharp vertices. Supersampled triangles have been
123-
rendered using a dedicated shader (see `<code/triangle-ssaa.py>`_) and the
122+
rendered using a dedicated shader (see `<code/chapter-06/triangle-ssaa.py>`_) and the
124123
SDF triangle has been rendered using a fake signed-distance triangle
125124
function (see below) and a stroke anti-alias function (see
126-
`<code/triangle-sdf.py>`_)
125+
`<code/chapter-06/triangle-sdf.py>`_)
127126

128127

129128
.. _CSAA: http://www.anandtech.com/show/2116/9
@@ -152,7 +151,7 @@ explaining `antialiasing modes`_ or this nice `overview of MSAA`_
152151
Coverage methods
153152
++++++++++++++++
154153

155-
.. figure:: data/circle-aa-exact.png
154+
.. figure:: images/chapter-06/circle-aa-exact.png
156155
:figwidth: 50%
157156
:figclass: right
158157

@@ -175,7 +174,7 @@ the `Anti-grain geometry
175174
<http://www.antigrain.com/doc/introduction/introduction.agdoc.html>`_ library
176175
that constitutes the quality standard we aim at.
177176

178-
.. figure:: data/coverage.png
177+
.. figure:: images/chapter-06/coverage.png
179178
:figwidth: 40%
180179
:figclass: right
181180

@@ -246,15 +245,15 @@ origin is given by:
246245
d(x,y) = sqrt(x*x+y*y) - r
247246
248247
249-
.. figure:: data/circle-sdf-distances.png
248+
.. figure:: images/chapter-06/circle-sdf-distances.png
250249
:figwidth: 30%
251250
:figclass: right
252251

253252
Figure
254253

255254
Signed distance to a circle. Inside is red, outside is blue, border is white.
256255

257-
See `<code/circle-sdf-distances.py>`_
256+
See `<code/chapter-06/circle-sdf-distances.py>`_
258257

259258

260259
As an exercise, you can check that `d(x,y)` is null if `(x,y)` is on the
@@ -317,8 +316,8 @@ of my knowledge):
317316
available from within glumpy.
318317

319318
However, we don't want to copy this code in all the example. We can instead
320-
write a `palette.glsl <code/palette.glsl>`_ shader and include it in each of
321-
the example.
319+
write a `palette.glsl <code/chapter-06/palette.glsl>`_ shader and include it in
320+
each of the example.
322321

323322

324323

@@ -329,7 +328,7 @@ Circle
329328

330329
Distance to a circle is the easiest to compute.
331330

332-
.. figure:: data/SDF-circle.mp4
331+
.. figure:: movies/chapter-06/SDF-circle.mp4
333332
:loop:
334333
:autoplay:
335334
:controls:
@@ -338,7 +337,7 @@ Distance to a circle is the easiest to compute.
338337

339338
Figure
340339

341-
`SDF-circle.py <code/SDF-circle.py>`_
340+
`SDF-circle.py <code/chapter-06/SDF-circle.py>`_
342341

343342

344343
.. code:: glsl
@@ -357,7 +356,7 @@ The distance from a point P to a plane (line in 2d) is the distance from P to
357356
the projection of P onto the place.
358357

359358

360-
.. figure:: data/SDF-plane.mp4
359+
.. figure:: movies/chapter-06/SDF-plane.mp4
361360
:loop:
362361
:autoplay:
363362
:controls:
@@ -366,7 +365,7 @@ the projection of P onto the place.
366365

367366
Figure
368367

369-
`SDF-plane.py <code/SDF-plane.py>`_
368+
`SDF-plane.py <code/chapter-06/SDF-plane.py>`_
370369

371370

372371
.. code:: glsl
@@ -386,7 +385,7 @@ True Box
386385
When computing distance to a box, one has to take care of the distance to the
387386
vertices defining the box.
388387

389-
.. figure:: data/SDF-box.mp4
388+
.. figure:: movies/chapter-06/SDF-box.mp4
390389
:loop:
391390
:autoplay:
392391
:controls:
@@ -395,7 +394,7 @@ vertices defining the box.
395394

396395
Figure
397396

398-
`SDF-box.py <code/SDF-box.py>`_
397+
`SDF-box.py <code/chapter-06/SDF-box.py>`_
399398

400399

401400

@@ -422,7 +421,7 @@ Rounded Box
422421

423422
Figure
424423

425-
`SDF-round-box.py <code/SDF-round-box.py>`_
424+
`SDF-round-box.py <code/chapter-06/SDF-round-box.py>`_
426425

427426

428427
Distance to a round can be immediately derived from the distance to a box by
@@ -441,7 +440,7 @@ subtracting the corner radius.
441440
Fake Box
442441
~~~~~~~~
443442

444-
.. figure:: data/SDF-fake-box.mp4
443+
.. figure:: movies/chapter-06/SDF-fake-box.mp4
445444
:loop:
446445
:autoplay:
447446
:controls:
@@ -450,7 +449,7 @@ Fake Box
450449

451450
Figure
452451

453-
`SDF-fake-box.py <code/SDF-fake-box.py>`_
452+
`SDF-fake-box.py <code/chapter-06/SDF-fake-box.py>`_
454453

455454

456455
A faster way to compute a SDF box is to consider it to be delimited by lines
@@ -468,7 +467,7 @@ box vertices.
468467
True triangle
469468
~~~~~~~~~~~~~
470469

471-
.. figure:: data/SDF-triangle.mp4
470+
.. figure:: movies/chapter-06/SDF-triangle.mp4
472471
:loop:
473472
:autoplay:
474473
:controls:
@@ -477,7 +476,7 @@ True triangle
477476

478477
Figure
479478

480-
`SDF-triangle.py <code/SDF-triangle.py>`_
479+
`SDF-triangle.py <code/chapter-06/SDF-triangle.py>`_
481480

482481
Computing the distance to a triangle is not totally straightfoward because a
483482
triangle is made of three line segments, meaning we have to take into account
@@ -514,7 +513,7 @@ vertices.
514513
Round triangle
515514
~~~~~~~~~~~~~~
516515

517-
.. figure:: data/SDF-round-triangle.mp4
516+
.. figure:: movies/chapter-06/SDF-round-triangle.mp4
518517
:loop:
519518
:autoplay:
520519
:controls:
@@ -523,7 +522,7 @@ Round triangle
523522

524523
Figure
525524

526-
`SDF-round-triangle.py <code/SDF-round-triangle.py>`_
525+
`SDF-round-triangle.py <code/chapter-06/SDF-round-triangle.py>`_
527526

528527
Round triangle is very easy to obtain from the triangle above. We just
529528
substract the radius of the corner such that the border of the triangle is on
@@ -542,7 +541,7 @@ the oustide part of the SDF triangle.
542541
Fake triangle
543542
~~~~~~~~~~~~~
544543

545-
.. figure:: data/SDF-fake-triangle.mp4
544+
.. figure:: movies/chapter-06/SDF-fake-triangle.mp4
546545
:loop:
547546
:autoplay:
548547
:controls:
@@ -551,7 +550,7 @@ Fake triangle
551550

552551
Figure
553552

554-
`SDF-fake-triangle.py <code/SDF-fake-triangle.py>`_
553+
`SDF-fake-triangle.py <code/chapter-06/SDF-fake-triangle.py>`_
555554

556555
What I call a fake SDF triangle is a triangle made of lines instead of line
557556
segments. If you look at the corner (outside part), you will notice the
@@ -582,7 +581,7 @@ markers because it is faster to compute than the regular SDF triangle.
582581
True ellipse
583582
~~~~~~~~~~~~
584583

585-
.. figure:: data/SDF-ellipse.mp4
584+
.. figure:: movies/chapter-06/SDF-ellipse.mp4
586585
:loop:
587586
:autoplay:
588587
:controls:
@@ -591,7 +590,7 @@ True ellipse
591590

592591
Figure
593592

594-
`SDF-ellipse.py <code/SDF-ellipse.py>`_
593+
`SDF-ellipse.py <code/chapter-06/SDF-ellipse.py>`_
595594

596595
Computing the distance from an arbitrary point to an ellipse is surprinsingly
597596
difficult if you compare it to the distance to a circle. If you want to read
@@ -649,7 +648,7 @@ problem for us. We will re-use his formula.
649648
Fake (but fast) ellipse
650649
~~~~~~~~~~~~~~~~~~~~~~~
651650

652-
.. figure:: data/SDF-fake-ellipse.mp4
651+
.. figure:: movies/chapter-06/SDF-fake-ellipse.mp4
653652
:loop:
654653
:autoplay:
655654
:controls:
@@ -658,7 +657,7 @@ Fake (but fast) ellipse
658657

659658
Figure
660659

661-
`SDF-fake-ellipse.py <code/SDF-fake-ellipse.py>`_
660+
`SDF-fake-ellipse.py <code/chapter-06/SDF-fake-ellipse.py>`_
662661

663662
Íñigo Quílez also provided a very fast apprximation of the ellipse
664663
distance. Some artifacts can be clearly seen but we'll see later that if our ellipse is not too thick, this approximation will do the job.
@@ -692,7 +691,7 @@ grey you might ask? Well, it is directly correlated with the distance to the
692691
border. But first, let's have a look at the figure below that show the
693692
different situations:
694693

695-
.. figure:: data/circle-aa.png
694+
.. figure:: images/chapter-06/circle-aa.png
696695

697696
Figure
698697

@@ -709,7 +708,7 @@ If it is larger, the shape will appear blurry, and it it is too narrow, the
709708
shape will have hard egdes. The degenerated case being a null area that results
710709
in no antialias at all.
711710

712-
.. figure:: data/antialias-function.png
711+
.. figure:: images/chapter-06/antialias-function.png
713712

714713
Figure
715714

0 commit comments

Comments
 (0)