上一篇“游戏中基于物理的渲染(三)”中详细讲解了microfacet BRDF,本篇将解释目前大部分游戏中所用的BRDF和基于物理的BRDF之间的区别。
这里先回顾一下第二篇中推导出来的公式:
Comparison
The reflectance equation common used in game look like this:
根据第一篇文章所述,实际上是属于反射方程,而不是diffuse,所以应该改成:
According to my first article, is part of reflectance equation, not diffuse term. So it should be:
其中,是视线方向对法线的反射向量,来自Phong模型。但是上一篇文章所论述的microfacet BRDF中并没有这一项。Blinn-Phong模型的形式和它类似,但用的是更有物理意义的h,也就是microfacet的m。改用Blinn-Phong的话就得到:
where is the view vector reflected about the normal. It’s from Phong model. It doesn’t seem to correspond to anything from microfacet theory in my last article. The Blinn-Phong model is very similar to this equation, but it uses the more physically meaningful half-vector h, which is microfacet’s normal m. Changing from Phong to Blinn-Phong gives us the following model:
从第一篇文章提到的Lambert可以发现,diffuse项已经和基于物理的一样了:
Recall the Lambert term from the first article, the diffuse term now is the same with physically-based one:
所以,现在我们专注于specular项,前面的公式如果只看specular是这样的
So, now we focus on specular term. If we look at the specular term only in the equation before:
Compare to microfacet specular:
首先,从公式可以看出,游戏中用的应该用表示Fresnel的替换。
第二,上篇文章说过,与粗糙度有关,所以可以认为和Blinn-Phong的功能相似。但是,要把替换成正确的microfacet分布函数,就必须做一个归一化。也就是说,对于任意的视线方向v,微表面投影的面积之和必须等于宏表面投影的面积,数学上就是:
Firstly, we can see from these two equations, the in game can be replaced by Fresnel’s .
Secondly, recall my last article, I mentioned that is related to roughness. So and Blinn-Phong’s have similar functions. However, to convert the term into a microfacet normal distribution function it must be correctly normalized. It means the sum of the signed projected areas of the microfacets needs to equal the signed projected area of the macroscopic surface; this must hold true for any viewing direction. Mathematically, this means that the function must fulfil this equation for any v:
既然这个方程是对任何视线方向都得成立,那么对于特殊情况v = n也得成立:
This equation holds for any viewing direction. In the special case, v = n:
Blinn-Phong的项如果也要满足这个方程,就得乘上一个归一化系数:
The Blinn-Phong cosine power term can be made to obey this equation by multiplying it with a simple normalization factor:
这个项的物理意义是可见性(遮挡项除以校正因子)。我们修改过的specular模型并不打算包含可见性,所以简单地把这个项设成1就行了,也就是:
It’s shadowing/masking, or geometry term divided by the foreshortening factors. The physical meaning of this term is visibility. Since our modified specular model has no visibility term, we will simply set it to 1. That is:
实际上,这对于仅包含height field的微表面是成立的(Blinn-Phong的表面分布函数也对应于此,因为所有背面的microfacet都等于0)。当l = n而且v = n的时候等于1, 这对于height field也是正确的(在宏表面的法线方向没有任何遮挡)。对于很斜的视角或者很斜的光线角都趋向于0,这也是正确的(microfacet被其他microfacet遮挡的可能性随着视角的增加而增加)。
经过整理,来自microfacet specular BRDF的几个项都明朗了,于是得到下面的渲染模型:
This is actually a plausible geometry term for a heightfield microsurface (which is what the Blinn-Phong normal distribution function corresponds to, since it is zero for all backfacing microfacets). is equal to 1 when l = n and v = n, which is correct for a heightfield (no microfacets are occluded from the direction of the macrosurface normal). It goes to 0 for either glancing view angles or glancing light angles, which again is correct (the probability of a microfacet being occluded by other microfacets increases with viewing angle).
Until now, several terms from microfacet specular BRDF are all explained, leaving us this rendering model:
前面的系数是因为。
把diffuse加回去,就得到:
The factor is because of .
Add the diffuse term back, that is:
这就是本系列文章最终推出的基于物理的渲染模型。对比原先游戏中使用的模型,计算量增加非常少,但不但保证了保能量,还能让美术更容易调整参数。
本系列最重要的方程已经呈现,下一篇文章将提一些未来的工作,并展示一些基于物理的渲染结果,作为本系列的完结篇。
This is the final equation, which is physically-based rendering model, derivated by this serial. Compare to the model common used in game, the calculated amount increases little. However, this equation not only ensure the energy-preserving, but also easier for artists to adjust parameters.
The most import equation of this serial is shown. In the next article, which is the last article in this serial, I’ll propose some future works, and will present some rendering results of physically-based model.
Comments