@@ -61,17 +61,17 @@ L对N的镜像R的计算:
6161
6262属于灯光的参数:
6363
64- {% highlight c linenos %}
64+ ``` c
6565light
6666{
6767 color,
6868 shininess/power
6969}
70- {% endhighlight %}
70+ ```
7171
7272属于材质的参数:
7373
74- {% highlight c linenos %}
74+ ``` c
7575material
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
9090color = 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
111111light_buffer.rgb = light_color.rgb * N * L * attenuation
112112light_buffer.a = (N * H)^n * N * L * attenuation
113113N * 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
121121luminance = 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