gouraud

What is the difference between Phong Shading and Gouraud Shading?

。_饼干妹妹 提交于 2021-02-05 06:34:26
问题 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

Most efficient algorithm to calculate vertex normals from set of triangles for Gouraud shading

拜拜、爱过 提交于 2019-11-29 11:09:37
We are given a set of triangles. Each triangle is a triplet of points. Each point is a triplet of real numbers. We can calculate surface normal for each triangle. For Gouraud shading however, we need vertex normals. Therefore we have to visit each vertex and look at the triangles that share that vertex, average their surface normals and we get vertex normal. What is the most efficient algorithm and data structure to achieve this? A naive approach is this (pseudo python code): MAP = dict() for T in triangles: for V in T.vertices: key = hash(V) if MAP.has(key): MAP[key].append(T) else: MAP[key]

Most efficient algorithm to calculate vertex normals from set of triangles for Gouraud shading

故事扮演 提交于 2019-11-28 04:53:50
问题 We are given a set of triangles. Each triangle is a triplet of points. Each point is a triplet of real numbers. We can calculate surface normal for each triangle. For Gouraud shading however, we need vertex normals. Therefore we have to visit each vertex and look at the triangles that share that vertex, average their surface normals and we get vertex normal. What is the most efficient algorithm and data structure to achieve this? A naive approach is this (pseudo python code): MAP = dict() for