mirror of
https://github.com/LearnOpenGL-CN/LearnOpenGL-CN.git
synced 2025-08-23 04:35:28 +08:00
Update 07 Bloom.md, code_fixer.css, mkdocs.yml
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
本文作者JoeyDeVries,由Django翻译自[http://learnopengl.com](http://learnopengl.com)
|
||||
|
||||
## Bloom
|
||||
## 泛光(Bloom)
|
||||
|
||||
明亮的光源和区域经常很难向观察者表达出来,因为监视器的亮度范围是有限的。一种区分明亮光源的方式是使它们在监视器上发出光芒,光源的的光芒向四周发散。这样观察者就会产生光源或亮区的确是强光区。(译注:这个问题的提出简单来说是为了解决这样的问题:例如有一张在阳光下的白纸,白纸在监视器上显示出是出白色,而前方的太阳也是纯白色的,所以基本上白纸和太阳就是一样的了,给太阳加一个光晕,这样太阳看起来似乎就比白纸更亮了)
|
||||
|
||||
@@ -130,39 +130,7 @@ void main()
|
||||
|
||||
在我们研究帧缓冲之前,先讨论高斯模糊的像素着色器:
|
||||
|
||||
|
||||
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
|
||||
```c++
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
in vec2 TexCoords;
|
||||
@@ -195,32 +163,13 @@ void main()
|
||||
}
|
||||
FragColor = vec4(result, 1.0);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
这里我们使用一个比较小的高斯权重做例子,每次我们用它来指定当前fragment的水平或垂直样本的特定权重。你会发现我们基本上是将模糊过滤器根据我们在uniform变量horizontal设置的值分割为一个水平和一个垂直部分。通过用1.0除以纹理的大小(从textureSize得到一个vec2)得到一个纹理像素的实际大小,以此作为偏移距离的根据。
|
||||
|
||||
我们为图像的模糊处理创建两个基本的帧缓冲,每个只有一个颜色缓冲纹理:
|
||||
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
```c++
|
||||
GLuint pingpongFBO[2];
|
||||
GLuint pingpongBuffer[2];
|
||||
glGenFramebuffers(2, pingpongFBO);
|
||||
@@ -240,7 +189,7 @@ for (GLuint i = 0; i < 2; i++)
|
||||
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongBuffer[i], 0
|
||||
);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
得到一个HDR纹理后,我们用提取出来的亮区纹理填充一个帧缓冲,然后对其模糊处理10次(5次垂直5次水平):
|
||||
|
||||
|
@@ -11,8 +11,4 @@ div.admonition code {
|
||||
color: #404040;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
background: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: justify;
|
||||
}
|
||||
}
|
@@ -45,7 +45,7 @@ pages:
|
||||
- 法线贴图: '05 Advanced Lighting/04 Normal Mapping.md'
|
||||
- 视差贴图: '05 Advanced Lighting/05 Parallax Mapping.md'
|
||||
- HDR: '05 Advanced Lighting/06 HDR.md'
|
||||
- Bloom: '05 Advanced Lighting/07 Bloom.md'
|
||||
- 泛光: '05 Advanced Lighting/07 Bloom.md'
|
||||
|
||||
site_name: LearnOpenGL-CN
|
||||
|
||||
|
Reference in New Issue
Block a user