1
00:00:01,200 --> 00:00:03,290
你现在看到的这片海
This ocean has no

2
00:00:03,290 --> 00:00:06,700
没有一个三角形，也没有一张贴图
triangles and no textures.

3
00:00:06,700 --> 00:00:09,661
它完全由 Shader 画出来
It is drawn entirely by a shader:

4
00:00:09,661 --> 00:00:12,621
一小段运行在 GPU 上的程序
a tiny program on the GPU that computes

5
00:00:12,621 --> 00:00:16,475
同时为屏幕上的两百万个像素，各算一次颜色
a color for each of two million pixels at once.

6
00:00:16,475 --> 00:00:22,056
今天从零开始，一步一步写出波浪、黑洞和史瓦西半径
Today we build it step by step: waves, a black hole, the Schwarzschild radius,

7
00:00:22,056 --> 00:00:26,498
让海水被吸进去，最后迎来一场宇宙大爆炸
water pulled in, and finally a big bang.

8
00:00:28,998 --> 00:00:31,893
先从最小的 Shader 开始
Start with the smallest shader.

9
00:00:31,893 --> 00:00:34,788
每个像素都会拿到自己的屏幕坐标
Every pixel gets its own screen coordinate;

10
00:00:34,788 --> 00:00:38,188
除以分辨率，就得到零到一之间的 UV
divide by the resolution to get a UV between zero and one.

11
00:00:38,188 --> 00:00:41,466
片元 Shader 只做一件事
A fragment shader does one thing:

12
00:00:41,466 --> 00:00:43,475
输入坐标，输出颜色
coordinate in, color out.

13
00:00:43,475 --> 00:00:48,348
把 UV 直接当成红和绿，整块屏幕就变成了渐变
Use UV as red and green, and the whole screen becomes a gradient.

14
00:00:48,348 --> 00:00:51,054
两百万个像素，同一段代码
Two million pixels, one program,

15
00:00:51,054 --> 00:00:54,625
同时运行。这就是 GPU 的力量
all at once. That is the power of the GPU.

16
00:00:56,525 --> 00:00:59,678
接着，用几层正弦波叠出海面
Next, stack a few sine waves into a sea.

17
00:00:59,678 --> 00:01:02,364
每一层方向和频率都不同
Each layer has its own direction and frequency,

18
00:01:02,364 --> 00:01:05,455
再用指数函数把波峰压得更尖
and an exponential sharpens the crests.

19
00:01:05,455 --> 00:01:09,532
高度场有了，做一次有限差分就得到法线
With a height field, one finite difference gives the normal.

20
00:01:09,532 --> 00:01:14,710
法线决定每个像素朝向哪里，也就决定了光怎么反射
The normal says where each pixel faces, and so how light reflects.

21
00:01:14,710 --> 00:01:18,276
再加上菲涅尔：视线越贴近水面
Add Fresnel: the lower the view angle,

22
00:01:18,276 --> 00:01:22,580
海就越像一面镜子，倒映出天空和落日
the more the sea becomes a mirror for the sky and the setting sun.

23
00:01:24,680 --> 00:01:28,800
现在，在海面上空放一个黑洞。没有模型
Now place a black hole above the sea. No model,

24
00:01:28,800 --> 00:01:33,810
也没有后期特效，只是让每一条视线在引力里拐弯
no post effect, just every line of sight bending in gravity.

25
00:01:33,810 --> 00:01:39,818
光线每走一小步，就被拉向黑洞中心；角动量越大
With every small step a ray is pulled toward the center; the more angular momentum,

26
00:01:39,818 --> 00:01:46,360
拐得越少。迭代几十次，天空和海面就被扭成一圈光环
the less it bends. A few dozen steps twist sky and sea into a ring of light.

27
00:01:46,360 --> 00:01:49,926
如果光线落进了视界，就再也出不来
If a ray falls inside the horizon it never returns,

28
00:01:49,926 --> 00:01:52,196
那个像素直接输出纯黑
and that pixel simply outputs black.

29
00:01:54,496 --> 00:01:57,389
黑洞的大小由史瓦西半径决定
The size of a black hole is set

30
00:01:57,389 --> 00:02:02,426
它等于二倍的引力常数乘以质量，再除以光速的平方
by the Schwarzschild radius: two G M over c squared.

31
00:02:02,426 --> 00:02:07,094
红圈是事件视界；一点五倍半径处是光子球
The red ring is the event horizon; at one and a half radii sits the photon sphere,

32
00:02:07,094 --> 00:02:12,481
光可以绕着黑洞转圈；三倍半径，是最内稳定轨道
where light can orbit; at three radii, the innermost stable orbit.

33
00:02:12,481 --> 00:02:14,490
质量翻倍，半径就翻倍
Double the mass and the radius doubles.

34
00:02:14,490 --> 00:02:18,031
把质量交给 Shader 的一个参数
Hand the mass to the shader as one parameter

35
00:02:18,031 --> 00:02:20,194
我们就能随时让黑洞长大
and we can grow the hole at will.

36
00:02:22,294 --> 00:02:27,869
再给黑洞加上吸积盘。光线每穿过赤道面一次
Now add an accretion disk. Each time a ray crosses the equatorial plane,

37
00:02:27,869 --> 00:02:30,724
就采样一圈炽热的气体
it samples a ring of glowing gas.

38
00:02:30,724 --> 00:02:33,636
内圈转得快、温度高，发白
The inner gas spins fast and runs white-hot;

39
00:02:33,636 --> 00:02:36,547
外圈转得慢，渐渐变成橙红
the outer gas slows and turns orange.

40
00:02:36,547 --> 00:02:40,579
朝向我们的一侧，因为多普勒效应更亮
The side moving toward us is brighter thanks to the Doppler effect.

41
00:02:40,579 --> 00:02:44,276
盘的背面也会被引力折到黑洞上方
Even the far side of the disk is bent over the top of the hole.

42
00:02:44,276 --> 00:02:47,019
那道弯曲的光弧，就是它
That curved arc of light is it.

43
00:02:49,319 --> 00:02:54,134
黑洞开始吸水。我们把海面的坐标绕黑洞旋转
The hole starts drinking the sea. We rotate the water coordinates around it,

44
00:02:54,134 --> 00:02:58,479
越靠近中心转得越快，波浪就卷成了螺旋
faster toward the center, and the waves curl into a spiral.

45
00:02:58,479 --> 00:03:03,995
同时把水面朝黑洞抬起，形成一根被引力拉起的水柱
We also lift the surface toward the hole, forming a column of water pulled up by gravity,

46
00:03:03,995 --> 00:03:06,459
泡沫沿着螺旋被甩出去
with foam flung along the spiral.

47
00:03:06,459 --> 00:03:09,762
这一切，只是改了几行采样坐标
All of it is a few lines changing the sampling coordinates.

48
00:03:09,762 --> 00:03:13,065
没有粒子系统，也没有流体模拟
No particle system, no fluid simulation.

49
00:03:15,365 --> 00:03:20,596
接下来，让质量持续增长。史瓦西半径越变越大
Now let the mass keep growing. The Schwarzschild radius swells,

50
00:03:20,596 --> 00:03:23,880
视界先吞掉海面，再吞掉天空
and the horizon swallows the sea, then the sky.

51
00:03:23,880 --> 00:03:27,936
光线无处可逃，每一个像素都落进视界
No ray can escape. Every pixel falls inside the horizon,

52
00:03:27,936 --> 00:03:30,370
屏幕一点一点变成纯黑
and the screen fades to pure black.

53
00:03:30,370 --> 00:03:33,812
没有海，没有天，也没有光
No sea, no sky, no light.

54
00:03:36,712 --> 00:03:41,232
然而，奇点无法一直坍缩。一个点，突然爆发
But a singularity cannot collapse forever. A single point suddenly erupts.

55
00:03:41,232 --> 00:03:44,059
同一个 Shader
Same shader, a new formula:

56
00:03:44,059 --> 00:03:48,233
换一个公式：密度从中心向外膨胀
density expands outward from the center,

57
00:03:48,233 --> 00:03:52,857
温度从白热冷却成橙红，再冷却成深蓝
and the temperature cools from white-hot to orange to deep blue.

58
00:03:52,857 --> 00:03:56,711
无数星点向外飞散，星云开始成形
Countless stars fly outward and nebulae take shape.

59
00:03:56,711 --> 00:03:59,322
一个新的宇宙，诞生了
A new universe is born.

60
00:04:02,822 --> 00:04:06,615
回头看，从渐变到海浪，从黑洞到爆炸
Looking back, from gradient to waves, from black hole to explosion,

61
00:04:06,615 --> 00:04:09,775
我们只写了一个 Shader
we wrote just one shader,

62
00:04:09,775 --> 00:04:14,832
核心始终是同一个问题：这个像素，应该是什么颜色？
built around one question: what color should this pixel be?

63
00:04:14,832 --> 00:04:19,190
当你理解了这一点，Shader 就不只是特效
Once you see that, a shader is more than an effect:

64
00:04:19,190 --> 00:04:21,999
而是一台，可以创造宇宙的机器
it is a machine that can create a universe.
