Phong底纹和Gouraud底纹有什么区别? [英] What is the difference between Phong Shading and Gouraud Shading?

查看:69
本文介绍了Phong底纹和Gouraud底纹有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知, Gouraud 阴影为每个顶点计算光色并对该颜色进行插值,而 Phong 阴影为每个像素插值法线并计算光色基于该插值.

但是,当我尝试数学推导浅色时,两种方法都得出了相同的公式!

(其中 n1 n2 是两个顶点的法线, t 是插值系数, L 是光的方向,顶部和虚线处的平面表示屏幕和像素.

这两种方法的浅色推导为:

  • 古洛德(Gouraud): L = t * dot(n1,L)+(1-t)* dot(n2,L)

  • Phong: L =点(t * n1 +(1-t)* n2,L)

与结果相同.

有人可以告诉我我的推导有什么问题吗?

解决方案

同时位于


另请参阅:
GLSL固定功能片段程序替换
Phong和Gouraud着色
Gouraud底纹/Phong底纹

As I understand it, Gouraud shading calculates light color for each vertex and does interpolation on that color, whereas Phong shading interpolates the normal for each pixel and calculates light color based on that interpolated value.

However, when I tried to derive the light color mathematically, I ended up with the same formula for both ways!

(Where n1 and n2 are the normals of the two vertices, t is the coefficient for interpolation, L is the light direction, and the plane on the top and the dotted line means screen and a pixel.)

The light colors for the two methods are derived as:

  • Gouraud: L = t*dot(n1,L) + (1-t)*dot(n2,L)

  • Phong: L = dot(t*n1+(1-t)*n2,L)

and the results are the same.

Can anyone tell me what's wrong with my derivations?

解决方案

While at Gouraud shading the light is calculates per vertex (Vertex shader), at Phong shading the light is calculates per fragment (fragment shader).
Therefore, Gouraud shading calculates the light for the vertices (corners) of a primitive and interpolates the light for the fragments covered by the primitive.
With Phong shading, the light is calculated separately for each fragment.

In general a light is computed by the Bidirectional reflectance distribution function. The function computes the reflectance of the light on a surface and depends on the vector of the incident light, the point of view and the normal vector of the surface.
At Gouraud shading the vertex color (reflectance) is interpolated and at Phong shading the 3 vectors are interpolated. That won't make any difference if the function c = brdf(l, v, n) is linear, where c is the color, l is the light direction, v is the view vector and n is the normal vector (e.g. Lambertian reflectance). But if the light model is not linear (e.g. Blinn–Phong), then the linear interpolation of Gouraud shading leads to different results.

Compare Gouraud shading and Phong shading


See also:
GLSL fixed function fragment program replacement
Phong and Gouraud Shading
Gouraud shading / Phong shading

这篇关于Phong底纹和Gouraud底纹有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆