Three.js: What Is The Exact Difference Between Lambert and Phong?

后端 未结 4 1445
孤街浪徒
孤街浪徒 2020-12-03 10:19

I understand the difference between Lambert and Phong in general computer graphics. I also understand how we can change and create our own materials using three.js. But I ca

4条回答
  •  醉酒成梦
    2020-12-03 10:42

    Shane, it's not your fault that you're confused.

    Lambert is an illumination model (with a physical basis) for the light reflected off a surface, expressed in terms of the incoming illumination's direction with respect to the surface normal at the point of incidence.

    Phong is a more nuanced shading model (albeit a more hacky one) which says that light is composed of ambient + diffuse + specular components. It treats the ambient component as constant everywhere (hack!), the diffuse component using the Lambertian model above, and the specular component using a power-law falloff (which is a clever hack, roughly approximating actual BRDFs).

    The word "Phong" is also an interpolation method (when used in the context of modern triangle-based rendering pipelines). When computing the illumination at a pixel in the interior of a triangle, you have two choices:

    1. Gouraud shading: Compute the color at the three vertices and interpolate in the interior, using barycentric coordinates, or

    2. Phong shading: Using the normal at the three vertices, interpolate the normal in the interior and compute the shading using this interpolated normal at each pixel.

    This is why (as @RayToal pointed out), if your specular "highlight" falls in the interior of a triangle, none of the vertices will be bright, but Phong shading will interpolate the normal and there will be a bright spot in the interior of your rendered triangle.

提交回复
热议问题