fixing problems... and adding Kynds examples to chapter 5

pull/69/head
Patricio Gonzalez Vivo 8 years ago
parent a8a4742456
commit a16d374f79

@ -103,15 +103,13 @@ At the end of the last exercise we introduced some new functions. Now its tim
* [Bezier and Other Parametric Shaping Functions: www.flong.com/texts/code/shapers_bez](http://www.flong.com/texts/code/shapers_bez/)
<div class="glslGallery" data="160414041542,160414041933,160414041756" data-properties="clickRun:editor,hoverPreview:false"></div>
Like chefs that collect spices and exotic ingredients, digital artists and creative coders have a particular love of working on their own shaping functions.
[Iñigo Quiles](http://www.iquilezles.org/) has a great collection of [useful functions](http://www.iquilezles.org/www/articles/functions/functions.htm). After reading [this article](http://www.iquilezles.org/www/articles/functions/functions.htm) take a look at the following translation of these functions to GLSL. Pay attention to the small changes required, like putting the "." (dot) on floating point numbers and using the GLSL name for *C functions*; for example instead of ```powf()``` use ```pow()```:
* [Impulse](../edit.html#05/impulse.frag)
* [Cubic Pulse](../edit.html#05/cubicpulse.frag)
* [Exponential Step](../edit.html#05/expstep.frag)
* [Parabola](../edit.html#05/parabola.frag)
* [Power Curve](../edit.html#05/pcurve.frag)
<div class="glslGallery" data="05/impulse,05/cubicpulse,05/expo,05/expstep,05/parabola,05/pcurve" data-properties="clickRun:editor,hoverPreview:false"></div>
To keep your motivation up, here is an elegant example (made by [Danguafer](https://www.shadertoy.com/user/Danguafer)) of mastering the shaping-functions karate.

@ -1,3 +1,6 @@
// Author: Inigo Quiles
// Title: Cubic Pulse
#ifdef GL_ES
precision mediump float;
#endif

@ -1,3 +1,6 @@
// Author: Inigo Quiles
// Title: Expo
#ifdef GL_ES
precision mediump float;
#endif

@ -1,3 +1,6 @@
// Author: Inigo Quiles
// Title: ExpStep
#ifdef GL_ES
precision mediump float;
#endif

@ -1 +1 @@
<div class="glslGallery" data="160414041542,160414041933,160414041756" data-properties="clickRun:edior,hoverPreview:false"></div>
<div class="glslGallery" data="160414041542,160414041933,160414041756" data-properties="clickRun:editor,hoverPreview:false"></div>

@ -1,3 +1,6 @@
// Author: Inigo Quiles
// Title: Impulse
#ifdef GL_ES
precision mediump float;
#endif

@ -1,3 +1,6 @@
// Author: Inigo Quiles
// Title: Parabola
#ifdef GL_ES
precision mediump float;
#endif

@ -1,3 +1,6 @@
// Author: Inigo Quiles
// Title: Pcurve
#ifdef GL_ES
precision mediump float;
#endif

@ -1 +1 @@
<div class="glslGallery" data="160414041142,160414040957,160414040804" data-properties="clickRun:edior,hoverPreview:false"></div>
<div class="glslGallery" data="160414041142,160414040957,160414040804" data-properties="clickRun:editor,hoverPreview:false"></div>

@ -159,7 +159,7 @@ Once you figurate out this algorithm think interesting and creative uses for it.
In 2011, [Stefan Gustavson optimized Steven Worley's algorithm to GPU](http://webstaff.itn.liu.se/~stegu/GLSL-cellular/GLSL-cellular-notes.pdf) by only iterating trough a 2x2 matrix instead of 3x3. This reduce the work significantly but can create artifacts in form of discontinuities. Take a look to the following examples.
<div class="glslGallery" data="12/2d-cnoise-2x2,12/2d-cnoise-2x2x2,12/2d-cnoise,12/3d-cnoise" data-properties="clickRun:edior,openFrameIcon:false"></div>
<div class="glslGallery" data="12/2d-cnoise-2x2,12/2d-cnoise-2x2x2,12/2d-cnoise,12/3d-cnoise" data-properties="clickRun:editor,openFrameIcon:false"></div>
Later in 2012 [Inigo Quilez wrote an article on how to make precise voronoi borders](http://www.iquilezles.org/www/articles/voronoilines/voronoilines.htm).
@ -175,4 +175,4 @@ Now is up to look closely at things, be inspired by nature to find your own voic
![Deyrolle glass film - 1831](DeyrolleFilm.png)
<div class="glslGallery" data="12/metaballs,12/stippling,12/cell,12/tissue,12/cracks,160504143842" data-properties="clickRun:edior,openFrameIcon:false"></div>
<div class="glslGallery" data="12/metaballs,12/stippling,12/cell,12/tissue,12/cracks,160504143842" data-properties="clickRun:editor,openFrameIcon:false"></div>

@ -79,6 +79,8 @@ Thanks to my wife [Jen Lowe](http://www.datatelling.com/), for her unconditional
Thanks [Scott Murray](http://alignedleft.com/) for the inspiration and advice.
Thanks [Kenichi Yoneda (Kynd)](https://twitter.com/kyndinfo), [Nicolas Barradeau](https://twitter.com/nicoptere), [Karim Naaji](http://karim.naaji.fr/) for contributing with support, good ideas and code.
Thanks [Kenichi Yoneda (Kynd)](https://twitter.com/kyndinfo) and [Sawako](https://twitter.com/sawakohome) for the [Japanese translation (日本語訳)](?lan=jp)
Thanks [Tong Li](https://www.facebook.com/tong.lee.9484) and [Yi Zhang](https://www.facebook.com/archer.zetta?pnref=story) for the [Chinese translation (中文版)](?lan=ch)
@ -87,7 +89,7 @@ Thanks [Jae Hyun Yoo](https://www.facebook.com/fkkcloud) for the Korean [transla
Thanks [Nahuel Coppero (Necsoft)](http://hinecsoft.com/) for the Spanish [translation (español)](?lan=es)
Thanks [Karim Naaji](http://karim.naaji.fr/) for contributing with support, good ideas and code.
Thanks [Nicolas Barradeau](https://twitter.com/nicoptere) and [Karim Naaji](http://karim.naaji.fr/) for the French [translation (france)](?lan=fr)
Thanks to everyone who has believed in this project and [contributed with fixes](https://github.com/patriciogonzalezvivo/thebookofshaders/graphs/contributors) or donations.

@ -1,11 +1,6 @@
<?php
echo '
<div class="header">
<p class="subtitle"><a href="http://thebookofshaders.com/">The Book of Shaders</a> by <a href="http://patriciogonzalezvivo.com">Patricio Gonzalez Vivo</a> </p>
<p> <a href="?lan=jp">日本</a> - <a href="?lan=ch">中文版</a> - <a href="?lan=kr">한국어</a> - <a href="?lan=es">Español</a> - <a href="?lan=fr">French</a> - <a href="?lan=it">Italiano</a> - <a href=".">English</a></p>
</div>
<hr>
';
?>
<div class="header">
<p class="subtitle"><a href="http://thebookofshaders.com/">The Book of Shaders</a> by <a href="http://patriciogonzalezvivo.com">Patricio Gonzalez Vivo</a> </p>
<p> <a href="?lan=jp">日本</a> - <a href="?lan=ch">中文版</a> - <a href="?lan=kr">한국어</a> - <a href="?lan=es">Español</a> - <a href="?lan=fr">French</a> - <a href="?lan=it">Italiano</a> - <a href=".">English</a></p>
</div>
<hr>

@ -50,7 +50,7 @@
echo ',';
}
}
echo '" data-properties="clickRun:edior,hoverPreview:false,showAuthor:false,openFrameIcon:false"></div>';
echo '" data-properties="clickRun:editor,hoverPreview:false,showAuthor:false,openFrameIcon:false"></div>';
}
if (file_exists($folder.'featured_examples.php') and file_exists('FEATURED'.$language.'.md')) {
@ -85,7 +85,7 @@
echo ',';
}
}
echo '" data-properties="clickRun:edior,showAuthor:false,openFrameIcon:false"></div>';
echo '" data-properties="clickRun:editor,showAuthor:false,openFrameIcon:false"></div>';
}

@ -1,20 +1,22 @@
<footer>
<p> Copyright 2015 <a href="http://www.patriciogonzalezvivo.com" target="_blank">Patricio Gonzalez Vivo</a> </p>
</footer>
<?php
echo '
<footer>
<p> Copyright 2015 <a href="http://www.patriciogonzalezvivo.com" target="_blank">Patricio Gonzalez Vivo</a> </p>
</footer>
echo '
<script type="text/javascript" src="'.$path.'/src/main.js" defer></script>';
?>
<script type="text/javascript" src="'.$path.'/src/main.js" defer></script>
<script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
<script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
ga("create", "UA-18824436-2", "auto");
ga("send", "pageview");
</script>
</body>
ga("create", "UA-18824436-2", "auto");
ga("send", "pageview");
</script>
</body>
</html>
';
?>

@ -6,13 +6,14 @@
include($path."/header.php");
include($path."/src/parsedown/Parsedown.php");
echo '
<div class="header"><p><a href="http://thebookofshaders.com/">The Book of Shaders</a> by <a href="http://patriciogonzalezvivo.com">Patricio Gonzalez Vivo</a></p></div>
?>
<div class="header">
<p class="subtitle"><a href="http://thebookofshaders.com/">The Book of Shaders</a> by <a href="http://patriciogonzalezvivo.com">Patricio Gonzalez Vivo</a></p>
</div>
<hr>
<div id="content">
';
<?php
$Parsedown = new Parsedown();
if(empty($_GET))
echo $Parsedown->text(file_get_contents ('README.md'));

@ -1,12 +1,12 @@
<?php
// main menu
echo '
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>The Book of Shaders'.$subtitle.'</title>
<?php
echo '
<title>The Book of Shaders'.$subtitle.'</title>';
?>
<link href="/favicon.gif" rel="shortcut icon"/>
<meta name="keywords" content="shader,openGL,WebGL,GLSL,book,procedural,generative" />
<meta name="description" content="Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders." />
@ -15,57 +15,64 @@ echo '
<meta name="twitter:title" content="The Book Of Shaders">
<meta name="twitter:description" content="Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders.">
<meta name="twitter:creator" content="@patriciogv">
<meta name="twitter:domain" content="thebookofshaders.edu">
<meta name="twitter:domain" content="thebookofshaders.com">
<link href="/favicon.gif" rel="shortcut icon"/>
<!-- Highlight -->
<?php
echo '
<link type="text/css" rel="stylesheet" href="'.$path.'/css/github.css">
<script type="text/javascript" src="'.$path.'/src/highlight.min.js"></script>
<script type="text/javascript" src="'.$path.'/src/highlight.min.js"></script>';
?>
<!-- GlslCanvas -->
';
<?php
if (file_exists($path."/src/glslCanvas/build/GlslCanvas.min.js")) {
echo '
<script type="text/javascript" src="'.$path.'/src/glslCanvas/build/GlslCanvas.min.js"></script>';
} else {
echo '
<script type="text/javascript" src="http://thebookofshaders.com/glslCanvas/GlslCanvas.min.js"></script>';
}
?>
if (file_exists($path."/src/glslCanvas/build/GlslCanvas.min.js")) {
echo '<script type="text/javascript" src="'.$path.'/src/glslCanvas/build/GlslCanvas.min.js"></script>';
} else {
echo '<script type="text/javascript" src="http://thebookofshaders.com/glslCanvas/GlslCanvas.min.js"></script>';
}
echo '
<!-- GlslEditor -->';
if (file_exists($path."/src/glslEditor/build/glslEditor.js")) {
echo '
<!-- GlslEditor -->
<?php
if (file_exists($path."/src/glslEditor/build/glslEditor.js")) {
echo '
<link type="text/css" rel="stylesheet" href="'.$path.'/src/glslEditor/build/glslEditor.css">
<script type="application/javascript" src="'.$path.'/src/glslEditor/build/glslEditor.js"></script>';
} else {
echo '
} else {
echo '
<link type="text/css" rel="stylesheet" href="http://thebookofshaders.com/glslEditor/glslEditor.css">
<script type="application/javascript" src="http://thebookofshaders.com/glslEditor/glslEditor.js"></script>';
}
}
?>
if (file_exists($path."/src/glslGallery/build/glslGallery.js")) {
echo '
<!-- GlslGallery -->
<?php
if (file_exists($path."/src/glslGallery/build/glslGallery.js")) {
echo '
<link type="text/css" rel="stylesheet" href="'.$path.'/src/glslGallery/build/glslGallery.css">
<script type="application/javascript" src="'.$path.'/src/glslGallery/build/glslGallery.js"></script>';
} else {
echo '
} else {
echo '
<link type="text/css" rel="stylesheet" href="http://thebookofshaders.com/glslGallery/glslGallery.css">
<script type="application/javascript" src="http://thebookofshaders.com/glslGallery/glslGallery.js"></script>';
}
echo '
<link type="text/css" rel="stylesheet" href="'.$path.'/css/style.css">
<!-- Translation -->
';
if ( $language !== '' && file_exists($path.'/css/style'.$language.'.css') ) {
echo '<link type="text/css" rel="stylesheet" href="'.$path.'/css/style'.$language.'.css">';
}
echo '
</head>
<body>
';
}
?>
<!-- Main style -->
<?php
echo '
<link type="text/css" rel="stylesheet" href="'.$path.'/css/style.css">';
if ( $language !== '' && file_exists($path.'/css/style'.$language.'.css') ) {
echo '
<!-- Translation style -->
<link type="text/css" rel="stylesheet" href="'.$path.'/css/style'.$language.'.css">';
}
?>
</head>
<body>
Loading…
Cancel
Save