-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
276 lines (252 loc) · 10.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mandelbulb rendered in P5.js using a SDF - Home</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<h1>Mandelbulb rendered in P5.js using a SDF </h1>
<nav id="myNavBar">
<div class="overlay" id="myNav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<div class="overlay-content">
<!--<button id="toggle">Three color Mandelbulb</button>-->
</div>
</div>
<div class="topNav">
<a href="../html/index.html" class="active" id="a0">Home</a>
</div>
<!-- Use any element to open/show the overlay navigation menu-->
<button id="ham"><span onclick="openNav()"><i class="fa fa-bars"></i></span></button>
</nav>
</header>
<div class="flex-container" id="flex">
<!--<input class="form-control" id="myInput" type="text" placeholder="Search.."> -->
<div class="intro" style="flex-grow:1" id="intro">
<p>
<h2>Introduction</h2>
<br>
</p>
<p>
I was first exposed to the mandelbrot set a VERY long time ago when my father (a retired physics
professor) became interested in coding it using postscript.
I am not sure whether I ever saw his version, but I remember looking at the pictures in a book he
purchased. I was fascinated with the intricate designs!
</p>
<p>
Fast forward many decades. NYU professor Daniel Shiffman (The Coding Train) did a Mandelbulb coding
challenge in February using Processing. By the end of the challenge, he had created a point cloud
version of the mandelbulb! He was kind
enough to share his .txt file and processing code in the Coding Train Discord for a couple of us
that were interested in tryng to render the mandelbulb. After some early attempts to apply
a mesh to the vertices (see below), Dan Shiffman consulted with some colleauges and concluded that using
a shader with a
signed distance function would be a better approach. During a livestream on Twitch, he explored this
possibility and provided the necessary
background to render the mandelbulb.
<br>
<a class="link" href="https://thecodingtrain.com/CodingChallenges/168-mandelbulb.html">The
Mandelbulb</a>
<a class="link" href="https://www.youtube.com/watch?v=7ZIfXu_iPv4">Revisiting Mandelbulb</a></a>
<br></p>
<p>
By now, I have rendered the mandelbulb using several different lighting and coloring techniques. I think
the best effort so far is the pastel version, altough there is still
room for improvement.</p>
<p>
</p>
</div>
</div>
<div class="container" id="myDIV1">
<div class="row">
<div class="mandelbulb" id="mandelbulb1">
<p>
<h2>Pastel Mandelbulb</h2>
<br>
This version is my attempt at coloring the mandelbulb based on edge detection. It is certainly not
as
good as some of the amazing verson you can find on the web (such as the ones by <a class="link"
href="https://iquilezles.org/articles/mandelbulb/">Inigo Quilez</a>). I think
that if someone did a watercolor of the mandelbulb, this is what it might look like.
<br>
</p>
<br>
<br>
<img class="img" src="assets/pastel.jpg" alt="Pastel Mandelbulb" width="500" height="500">
<br>
<a class="link" href="https://editor.p5js.org/kfahn/full/U6_U2XHJj">Pastel mandelbulb sketch</a></a>
<br>
<a class="link" href="https://github.com/kfahn22/mandelbulb/tree/main/edge-detection">Code</a></a>
</div>
<div class="mandelbulb" id="mandelbulb2">
<p>
<h2>Three Color Mandelbulb</h2>
<br>
This rendered version uses the lighting techniques described in <a class="link"
href="https://www.youtube.com/watch?v=0RWaR7zApEo">The Art of Code: Bending Light</a>
youtube tutorial by Martijn Steinrucken. Rather than the more advanced method of coloring the
mandelbulb using edge detection, each of the x, y, z dimensions is assigned a different RGB color.
<br>
</p>
<br>
<br>
<img class="img" src="assets/three_color.png" alt="Three Color Mandelbulb" width="500" height="500">
<br>
<a class="link" href="https://editor.p5js.org/kfahn/full/XF8pZKeRC">Three color mandelbulb
sketch</a></a>
<br>
<a class="link" href="https://github.com/kfahn22/mandelbulb/tree/main/Multi_color">Code</a></a>
</div>
<div class="mandelbulb" id="mandelbulb3">
<p>
<h2>One Color Mandelbulb</h2>
<br>
This version uses the <a class="link" href="https://www.shadertoy.com/view/WtGXDD">Ray Marching
Starting Point</a> tutorial by Martijn Steinrucken. I think the
mandelbulb is too dark--I believe that the diffuse lighting needs improvement.
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<img class="img" src="assets/single_color.png" alt="Single Color Mandelbulb" width="500"
height="500">
<br>
<a class="link" href="https://editor.p5js.org/kfahn/full/2w56dWbzL">Single color mandelbulb
sketch</a></a>
<br>
<a class="link" href="https://github.com/kfahn22/mandelbulb/tree/main/One%20Color">Code</a></a>
</p>
</div>
<div class="mandelbulb" id="mandelbulb4">
<p>
<h2>Mandelbulb using Inigo Quilez lighting</h2>
<br>
This version uses the lighting techniques of Inigo Quilez in his <a class="link"
href="https://www.youtube.com/watch?v=Cfe5UQ-1L9Q">LIVE Coding "Happy Jumping"</a></a>
tutorial (truely wonderful!) Inigo Quilez is an expert at lighting, and the parameters
were optimized for his animation
of a blobby monster jumping. I had a hard time trying to figure out how to change his
lighting parameters--I think this is the reason that this version is over-exposed. There is also
quite a
bit of aliasing when it is animated. Improving the lighting and animation are avenues for future
improvement.
<br>
<br>
<br>
<img class="img" src="assets/single_color1.png" alt="Single Color Mandelbulb: Version 2"
width="500" height="500">
<br>
<a class="link" href="https://editor.p5js.org/kfahn/full/3Yp7ZBCMw">Single color mandelbulb
sketch</a></a>
<br>
<a class="link" href="https://github.com/kfahn22/mandelbulb/tree/main/IQ_Lighting">Code</a></a>
</p>
</div>
<div class="mandelbulb" id="mandelbulb5">
<p>
<h2>"Crystal" mandelbulb</h2>
<br>
This is my first render of the mandelbulb in p5.js. I started out using <a class="link"
href="https://www.shadertoy.com/view/llt3R4">Jamie
Wong's shadertoy code</a>--which uses phong illumination--as a guide. I think it is pretty cool
looking, but it doesn't
animate well.
I suspect this is due to the raydirection function, and I hope to investigate further to see if I
can get this version to animate.
<br>
<br>
<br>
<br>
<img class="img" src="assets/crystal.png" alt="Crystal Mandelbulb" width="500" height="500">
<br>
<a class="link" href="https://editor.p5js.org/kfahn/full/o5sX5O0cF">Crystal mandelbulb
sketch</a></a>
<br>
<a class="link" href="https://github.com/kfahn22/mandelbulb/tree/main/Crystal">Code</a></a>
</p>
</div>
<div class="mandelbulb" id="mandelbulb6">
<p>
<h2>Attempt #1: MeshLab</h2>
<br>
I initially tried to render the mandelbulb using MeshLab. Following Dan Shiffman's lead, I loaded
the vertices (all 206,828 of them) into MeshLab and used a guide a found in github to try to mesh
the
vertices. The first version looked rather like a pin cushion because the normals were facing the
wrong direction! I eventually came
up with this version. While not bad, it is not fully rendered and it kind of looks the mandelbulb
is in a cage.
<br>
<br>
<img class="img" src="assets/meshlab.png" alt="Meshlab Mandelbulb" width="500" height="500">
<br>
</div>
<div class="mandelbulb" id="mandelbulb7">
<h2>Attempt #2: Blender</h2>
For the next attempt, I loaded the vertices into Blender. I was able to obtain something that looked
kind of like a very simplified version of a mandelbulb.
<br>
<br>
<br>
<img class="img" src="assets/blender.png" alt="Blender Mandelbulb" width="500" height="500">
</p>
</div>
</div>
</div>
<!-- javascript -->
<!-- This function toggles a read more button -->
<script>
$(document).ready(function () {
$("#myInput").on("keyup", function () {
var value = $(this).val().toLowerCase();
$("#myDIV *").filter(function () {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
<!-- This function is for a Read more read less button -->
<!-- Code found on codepen legendaryPower "Simple Read Less Read More Button"-->
<script>
$(document).ready(function () {
$("#toggle").click(function () {
var elem = $("#toggle").text();
if (elem == "Answer") {
//Stuff to do when btn is in the read more state
$("#toggle").text("Close");
$("#text").slideDown();
} else {
//Stuff to do when btn is in the read less state
$("#toggle").text("Answer");
$("#text").slideUp();
}
});
});
</script>
<!--This function open and closes a curtain overlay -->
<script>
/* Open when someone clicks on the span element */
function openNav() {
document.getElementById("myNav").style.width = "100%";
}
/* Close when someone clicks on the "x" symbol inside the overlay */
function closeNav() {
document.getElementById("myNav").style.width = "0%";
}
</script>
</body>
</html>