Skip to content

Commit a69c41e

Browse files
committed
Update 2015-06-20-light-prepass-render.md
1 parent d50fbf2 commit a69c41e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

_posts/2015-06-20-light-prepass-render.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ L对N的镜像R的计算:
6161

6262
属于灯光的参数:
6363

64-
{% highlight c linenos %}
64+
```c
6565
light
6666
{
6767
color,
6868
shininess/power
6969
}
70-
{% endhighlight %}
70+
```
7171

7272
属于材质的参数:
7373

74-
{% highlight c linenos %}
74+
```c
7575
material
7676
{
7777
specular_color,
@@ -82,16 +82,16 @@ material
8282

8383
shininess/power
8484
}
85-
{% endhighlight %}
85+
```
8686

8787
我们需要重建的光照方程,使用Blinn-Phong光照模型:
8888

89-
{% highlight c linenos %}
89+
```c
9090
color = ambient + shadow * attenuation * (
9191
mat_diff * diff_intensity * light_color * N * L +
9292
mat_spec * spec_intensity * ((N * H)^n)^m
9393
)
94-
{% endhighlight %}
94+
```
9595

9696
| Name | Detail | Name | Detail |
9797
| ----------- | --------------- | --------- | -------------- |
@@ -107,27 +107,27 @@ color = ambient + shadow * attenuation * (
107107

108108
我们将其存储到Light Buffer中,用于后续渲染中对光照方程的重建:
109109

110-
{% highlight c linenos %}
110+
```c
111111
light_buffer.rgb = light_color.rgb * N * L * attenuation
112112
light_buffer.a = (N * H)^n * N * L * attenuation
113113
N * L * attenuation
114-
{% endhighlight %}
114+
```
115115

116116
若需要重建高光反射分量,则共需要两个Render Target。
117117

118118
在这里,我们可以转换 N * L * attenuation 到 luminance <sup>[[3]](#ref)</sup>,这两个值非常接近:
119119

120-
{% highlight c linenos %}
120+
```c
121121
luminance = N * L * attenuation
122122
= (0.2126 * R + 0.7152 * G + 0.0722 * B)
123-
{% endhighlight %}
123+
```
124124

125125
这样我们就可以重建高光反射分量,并且仅需要一个Render Target:
126126

127-
{% highlight c linenos %}
127+
```c
128128
(N * H)^n = light_buffer.a / luminance
129129
= ((N * H)^n * N * L * attenuation) / (N * L * attenuation);
130-
{% endhighlight %}
130+
```
131131

132132

133133
## 附录<span id="ref"></span>

0 commit comments

Comments
 (0)