forked from iapafoto/WebGLShader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslide.html
More file actions
365 lines (313 loc) · 11.1 KB
/
slide.html
File metadata and controls
365 lines (313 loc) · 11.1 KB
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://codemirror.net/5/lib/codemirror.css">
<link rel="stylesheet" href="https://codemirror.net/5/theme/darcula.css">
<link rel="stylesheet" href="https://codemirror.net/5/addon/lint/lint.css">
<script src="shaders.js"></script>
<script src="GLCanvasWithEdit.js"></script>
<script src="https://codemirror.net/5/lib/codemirror.js"></script>
<script src="https://codemirror.net/5/addon/edit/matchbrackets.js"></script>
<script src="https://codemirror.net/5/addon/lint/lint.js"></script>
<script src="glsl.js"></script>
<title>Slideshow</title>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #f0f0f0;
font-size: 20px;
}
h1 {
text-align: center;
font-size: 30px;
}
#slideshow-container {
position: relative;
max-width: 1000px;
margin: auto;
}
.slide {
//animation: fade 1s ease-in-out;
//display: none;
//position: absolute;
width: 100%;
}
@keyframes fade {
from {
opacity: 0.4;
}
to {
opacity: 1;
}
}
.iframe-container {
position: relative;
padding-bottom: 56.25%; /* 16:9 aspect ratio */
height: 0;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
.iframe-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#slide-list {
position: fixed;
top: 0;
left: 0;
padding: 20px;
//background-color: #00000050;
}
#navigation-buttons {
position: fixed;
bottom: 20px;
width: 100%;
text-align: center;
}
.navigation-button {
padding: 10px;
margin: 5px;
width:220px;
cursor: pointer;
font-size: 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
text-align: center;
}
.menu-button {
}
.infos {
position: fixed;
top: 40px;
right: 30px;
padding: 20px;
background-color: white;
border:solid;
border-color: black;
border-radius: 10px;
}
main {
display: flex;
flex-basis:auto;
}
.CodeMirror {
font-size: 20px;
}
</style>
</head>
<body>
<div id="slideshow-container">
<div class="slide">
<h1>Comment faire rentrer une bibliothéque dans un timbre poste ?</h1>
<!--div class="iframe-container"-->
<!--iframe width="1200" height="600" frameborder="0" allowfullscreen="allowfullscreen" src="https://www.shadertoy.com/embed/XcfGW8?gui=false&t=10&paused=false&muted=true"></iframe-->
<!--/div-->
<ul>
<li>biblio.bmp - ??? ko</li>
<li>biblio.png - 5600ko</li>
<li>biblio.jpg - 1000ko</li>
<li>...</li>
</ul>
</div>
<div class="slide">
<h1>Quelles sont les étapes du rendu OpenGL ?</h1>
<canvas id="webgl-canvas1" style="width:800px; height:400px"></canvas>
<!--div class="iframe-container">
<iframe width="1200" height="600" frameborder="0" allowfullscreen="allowfullscreen" src="https://www.shadertoy.com/embed/WlSXRW?gui=false&t=10&paused=true&muted=true"></iframe>
</div-->
<h3>Etapes du rendu Opencl</h3>
<img src="img/fragment.png" width="100%"></img>
<h3>Le fragment shader</h3>
<ul>
<li>Le rendu des couleurs se fait via un programe, le <b>fragment shader</b></li>
<li>Le fragment shader est compilé et exécuté par le GPU</li>
<li>Une scéne peut contenir de nombreux fragment shader</li>
<li>Tous les pixels sont +/- calculés en même temps !</li>
</ul>
</div>
<div class="slide">
<h1>Comment dessiner dans un shader ?</h1>
<div class="main">
<canvas id="webgl-canvas2" style="width:800px; height:400px"></canvas>
<textarea id="glsl-editor2" style="width:800px; height:150px"></textarea>
</div>
<h3>main()</h3>
<ul>
<li>La fonction <b>mainImage()</b> s'execute pour chaque pixels</li>
<li>Elle reçoit en entrée, la coordonnée du pixel (<b>coord</b>)</li>
<li>Elle doit retourner la couleur du pixel (<b>col</b>)</li>
<li>Elle peut aussi utiliser certain paramétes généraux (<b>iTime</b>, <b>iResolution</b>, etc.)</li>
</ul>
<div class="infos">
<img src="img/smoothstep.png"></img>
</div>
</div>
<div class="slide">
<h1>Qu'est ce qu'un Signed Distance Field ?</h1>
<div class="main">
<canvas id="webgl-canvas3" style="width:800px; height:400px"></canvas>
<textarea id="glsl-editor3" style="width:800px; height:150px"></textarea>
</div>
<h3>Signed Distance Field</h3>
<ul>
<li>Le <b>SDF</b> indique une distance vers un contour</li>
<li>Le <b>SDF</b> est positif à l'exterieur et négatif à l'intérieur</li>
<li>Il permet d'effectuer simplement des opérations (union, intersection, soustraction)</li>
<li>Il peut être déformé et n'a pas forcement besoin d'être exact !</li>
</ul>
<div class="infos">
<img src="img/union.png"></img>
</div>
</div>
<div class="slide">
<h1>Rasterization vs Ray-tracing vs Ray-marching ?</h1>
<img width="1000" height="600" src="img/raster-raytrace.png"></img>
<h3>Signed Distance Field</h3>
<ul>
<li><b>Rasterization :</b> la scéne est découpé en triangles qui sont triés puis projetées à l'écran</li>
<li><b>Ray-tracing :</b></li>
<ul>
<li>Lance un rayon pour chaque pixel de l'écran</li>
<li>Calcul pour chaque rayon, le point d'intersection et la normale avec les objets</b>
</ul>
<li>Le <b>Ray-marching</b> ressemble au ray-tracing mais recherche une surface implicite dans le SDF</li>
</ul>
</div>
<div class="slide">
<h1>Comment faire un rendu 3D avec le ray-marching ?</h1>
<canvas id="webgl-canvas5A" style="width:480px; height:400px"></canvas>
<canvas id="webgl-canvas5B" style="width:480px; height:400px"></canvas>
<h3>Les bases du rendu via ray-marching</h3>
<ul>
<li>Les surfaces sont implicites et correspondent à l'isoligne 0 du SDF</li>
<li>On trouve le point d'intersection en <b>itérant</b> dans le SDF par pas de distance locale</li>
<li>La normale à la surface est obtenue grâce à la normale du <b>gradient</b> du SDF</li>
<li>Les formules décriavnt les objets sont beaucoup plus simples que en ray-tracing</li>
<li>On a tout ce qu'il faut pour faire de la 3D via ray-marching !</li>
</ul>
</div>
<div class="slide">
<h1>Exemple de rendu 3D</h1>
<div class="main">
<canvas id="webgl-canvas6" style="width:800px; height:400px"></canvas>
<textarea id="glsl-editor6" style="width:800px; height:350px"></textarea>
</div>
</div>
<div class="slide">
<h1>Des questions ?</h1>
<canvas id="webgl-canvas0" style="width:800px; height:600px"></canvas>
<!--ul>
<li>Fragment Shader</li>
<li>Signed Distance Field</li>
<li>Ray Marching</li>
<li>Demo 4K</li>
</ul-->
</div>
</div>
<div id="slide-list"></div>
<div id="navigation-buttons">
<button class="navigation-button" onclick="plusSlides(-1)">Précédent</button>
<button class="navigation-button" onclick="plusSlides(1)">Suivant</button>
</div>
<script>
var glRenderer0 = new GLCanvas("webgl-canvas0", shCode0);
var glRenderer1 = new GLCanvas("webgl-canvas1", shCode3);
var glRenderer5A = new GLCanvas("webgl-canvas5A", shCode5);
var glRenderer5B = new GLCanvas("webgl-canvas5B", shCode5B);
// ---------------------------------------------------------
var glRenderer2 = new GLCanvas("webgl-canvas2", shCode1);
var editor2 = glRenderer2.associateEditor("glsl-editor2", true, "darcula", true);
editor2.setSize(800, 145);
// ---------------------------------------------------------
var glRenderer3 = new GLCanvas("webgl-canvas3", shCode2);
var editor3 = glRenderer3.associateEditor("glsl-editor3", true, "darcula", true);
editor3.setSize(800, 145);
// ---------------------------------------------------------
var glRenderer6 = new GLCanvas("webgl-canvas6", shCode6);
var editor6 = glRenderer6.associateEditor("glsl-editor6", true, "darcula", true);
editor6.setSize(800, 400);
</script>
<script>
let counter = 0;
document.addEventListener('keydown', function (event) {
if (event.code === 'Space') {
counter++;//addNewElement();
// todo display element /pages according to counter
}
});
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
// Mettez à jour la fonction showSlides pour gérer l'animation
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("slide");
var btns = document.getElementsByClassName("menu-button");
if (n > slides.length) {
slideIndex = 1;
}
if (n < 1) {
slideIndex = slides.length;
}
// Masquez toutes les diapositives
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
btns[i].style.backgroundColor = i == slideIndex-1 ? "#4CAF50" : "#AAAAAA";
}
// Affichez la diapositive actuelle
slides[slideIndex - 1].style.display = "block";
if (slideIndex == 2) {
glRenderer1.start();
} else {
glRenderer1.pause();
}
if (slideIndex == 6) {
glRenderer5A.start();
glRenderer5B.start();
} else {
glRenderer5A.pause();
glRenderer5B.pause();
}
if (slideIndex == 7) {
glRenderer6.start();
} else {
glRenderer6.pause();
}
if (slideIndex == 8) {
glRenderer0.start();
} else {
glRenderer0.pause();
}
}
function initMenu() {
// Mettez à jour la liste des diapositives
var slideList = document.getElementById("slide-list");
slideList.innerHTML = "";
slideList.innerHTML += "<button id='menu1' class='navigation-button menu-button' onclick='currentSlide(1)'>Intro</button></br>";
slideList.innerHTML += "<button id='menu2' class='navigation-button menu-button' onclick='currentSlide(2)'>Rendu OpenGL</button></br>";
slideList.innerHTML += "<button id='menu3' class='navigation-button menu-button' onclick='currentSlide(3)'>Fragment shader</button></br>";
slideList.innerHTML += "<button id='menu4' class='navigation-button menu-button' onclick='currentSlide(4)'>Distance field</button></br>";
slideList.innerHTML += "<button id='menu5' class='navigation-button menu-button' onclick='currentSlide(5)'>Ray marching</button></br>";
slideList.innerHTML += "<button id='menu6' class='navigation-button menu-button' onclick='currentSlide(6)'>Rendu scéne 3D</button></br>";
slideList.innerHTML += "<button id='menu7' class='navigation-button menu-button' onclick='currentSlide(7)'>Rendu SDF 3D</button></br>";
slideList.innerHTML += "<button id='menu1' class='navigation-button menu-button' onclick='currentSlide(8)'>Questions</button></br>";
}
initMenu();
var slideIndex = 1;
showSlides(slideIndex);
</script>
</body>
</html>