Fireship · @fireship
WebGL 3D Graphics Explained in 100 Seconds
Uploaded May 12, 2021 · Length 2:07
Summary
webgl 3d graphics explained in 100 seconds, including rendering pipeline and gpu acceleration.
- webgl
- 3d graphics
- gpu acceleration
- javascript api
- opengl
- 3js
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
web graphics library is a javascript api
- 0:02
for implementing
- 0:04
interactive 2d and 3d vector graphics in
- 0:06
the browser
- 0:07
it allows developers to run hardware
- 0:09
accelerated graphics with the client's
- 0:10
gpu
- 0:11
directly inside an html canvas without
- 0:13
the need for external plugins it opens
- 0:15
the door to 3d web design
- 0:17
interactive games data vis physics
- 0:19
simulations and most importantly
- 0:21
beautiful artwork
- 0:22
webgl is used to render graphics in
- 0:24
everyday tools like google maps and by
- 0:26
the unity engine to make web-based games
- 0:28
to understand how it works it helps to
- 0:30
first understand basic 3d theory
- 0:32
and the rendering pipeline in a 3d scene
- 0:35
every point is a vertex
- 0:36
identified by its x y and z coordinates
- 0:39
the vertices are then connected together
- 0:41
to form a bunch of little triangles
- 0:43
known as primitives
- 0:44
then a light source bounces off of them
- 0:46
to create the appearance of shadows and
- 0:48
depth perception they're then rasterized
- 0:50
to convert
- 0:50
a 3d vector graphic into a projection of
- 0:53
a 2d pixel
- 0:54
which tricks our brains into seeing a 3d
- 0:56
object on a 2-dimensional computer
- 0:58
screen
- 0:58
this pipeline can be customized by
- 1:00
writing shaders which are just functions
- 1:02
that tell the computer how to draw
- 1:04
pixels on the screen
- 1:05
shading requires the computer to perform
- 1:07
a ton of linear algebra or matrix
- 1:09
multiplication
- 1:10
to render graphics smoothly at 60fps
- 1:13
it's often too much for the cpu to
- 1:14
handle by itself which is why we have
- 1:16
gpus to distribute the calculations more
- 1:18
efficiently webgl
- 1:20
allows us to process graphics on the gpu
- 1:22
and is based on a library that's been
- 1:24
around since 1992 called opengl
- 1:26
to get started you just need to grab an
- 1:28
html canvas in the dom
- 1:30
then get its webgl contacts to start
- 1:32
drawing the main program code is written
- 1:34
in javascript
- 1:35
but shaders are written in the opengl es
- 1:38
shading language
- 1:39
a shader will take information about a
- 1:41
vertex or fragment and use the gpu to
- 1:43
calculate the data required to render it
- 1:45
as a pixel on the screen
- 1:47
luckily you don't need to write shaders
- 1:48
by hand to start adding 3d graphics to
- 1:51
your website you can use libraries like
- 1:52
3js or tools like spline to quickly
- 1:55
design 3d experiences without much
- 1:57
underlying knowledge of webgl
- 1:59
stay tuned for a full 3js tutorial make


