# How to calculate the RGB intensity values at center of face using flat shading?

Consider a triangular face of three vertices A(0,2,1), B(3,0,1) and the origin, and the normal vectors at the vertices are nA=(0,0,1), nB=(1,1,0) and nO=(-1,-1,1), respectively. The incident light is white and directional in the direction of L=(0,3,4) and the intensity is 1, the background ambient light intensity is 0.1, and the diffuse reflection coefficients for (red, green, blue) are (0.6,0.7,0.8). No specular light contribution need be considered.

How do I find the (red, green, blue) intensity values at the centre of the face using flat shading?

I = Ia x Ka + Fatt x Il x (Kd x (N x L))

Final intensity = ambient reflection x ambient reflection coefficient + (attenuation x incident light intensity x (diffusive reflection coefficient x (surface normal x Light intensity))

My lecturer told me that because ambient reflection coefficient and attenuation are not given, I can forget about it. Also specular light contribution need not be considered.

The surface normal is:

A = (0, 2, 1) B = (3, 0, 1) O = (0, 0, 0)

U = A - O = (0, 2, 1) V = B - O = (3, 0, 1)

Surface normal = U x V (cross-product) = (2, 3, -6)

I = 0.1 + (1, 1, 1) x ((0.6, 0.7, 0.8) x ((2, 3, -6) x (0, 3, 4)))

I = 0.1 + (1, 1, 1) x ((0.6, 0.7, 0.8) x (0, 9, -2.4))

I = 0.1 + (1, 1, 1) x (0, 6.3, -1.92)

I = (0.1, 6.4, -1.82) = RGB intensity values

Is this correct?

• Do you have to use vertex normals as opposed to face normals? This makes the problem considerably more difficult. That said, the center of the triangle is always going to be the average of the values at the 3 vertices of the triangle, regardless of the size or direction of the triangle. If you know how to calculate the values at each vertex, you can simply interpolate t=0.5 between all three values.
– Dan
Commented Mar 14, 2017 at 13:52
• @Dan No, it's flat shading, so it should be by face normal.
– aces
Commented Mar 14, 2017 at 15:25
• @aces So you're agreeing with me? Lol. Your comment contradicts itself.The OP specified 3 normals, one for each vertex, in his question.
– Dan
Commented Mar 14, 2017 at 17:44
• @Dan Sorry, I interpreted your comment incorrectly.
– aces
Commented Mar 14, 2017 at 19:31
• @aces No big deal. Hopefully your answer helps the OP!
– Dan
Commented Mar 15, 2017 at 16:16

You shouldn't solve for $\cos^{-1}(\theta)$.

The ambient component is as follows (we are assuming the ambient light is white): $$ambient\ color = (ambient\ light\ color)(ambient\ intensity)(diffuse\ color) = (1,1,1)(0.1)(0.6,0.7,0.8) = (0.06,0.07,0.08)$$

The diffuse component is as follows: $$diffuse\ color = (light\ color)(light\ intensity)(diffuse\ color)(\cos(\theta)) = (1,1,1)(1)(0.6,0.7,0.8)(0.8) = (0.48,0.56,0.64)$$

Now we just need to add them up: $$final\ intensity = (diffuse\ color) + (ambient\ color) = (0.06,0.07,0.08) + (0.48,0.56,0.64) = (0.54,0.63,0.72)$$

For more information, here's a pretty decent summary of various lighting calculations.

• My lecturer told me this method is not answering the question, because the question asks for flat shading.
– S.A
Commented Mar 16, 2017 at 9:33
• This does answer the question. The only difference between flat shading and smooth shading in this question is the normal you use in the lighting calculation. That's why I edited your earlier question.
– aces
Commented Mar 20, 2017 at 1:59
• Also, I treat the diffuse reflectance coefficients as the diffuse color (maybe there's some miscommunication here?) because it doesn't make sense for them to be three-component vector of arbitrary values. It's used in energy conservation. The same thing is applicable to the diffuse light attenuation you put in you question; it should only be a single value (although the calculation is the same for this question).
– aces
Commented Mar 20, 2017 at 2:03

I = Ia x Ka + Fatt x Il x (Kd x (N x L))

Final intensity = ambient reflection x ambient reflection coefficient + (attenuation x incident light intensity x (diffusive reflection coefficient x (surface normal x Light intensity))

He told me that because ambient reflection coefficient and attenuation are not given, I can forget about it. Also specular light contribution need not be considered.

The surface normal is: A = (0, 2, 1) B = (3, 0, 1) O = (0, 0, 0)

U = A - O = (0, 2, 1) V = B - O = (3, 0, 1)

Surface normal = U x V (cross-product) = (2, 3, -6)

I = 0.1 + (1, 1, 1) x ((0.6, 0.7, 0.8) x ((2, 3, -6) x (0, 3, 4)))

I = 0.1 + (1, 1, 1) x ((0.6, 0.7, 0.8) x (0, 9, -2.4))

I = 0.1 + (1, 1, 1) x (0, 6.3, -1.92)

I = (0.1, 6.4, -1.82) = RGB intensity values

• To my understanding, this is how to calculate the RGB intensity values using flat shading. I would really appreciate seeing what others have to say about this.
– S.A
Commented Mar 16, 2017 at 9:45
• There are multiple problems with the normal. The first is that it needs to be normalized. The second issue is that it points in the opposite direction as the vertex normals. Maybe that's somehow correct, but since you weren't given a winding order, I would pick the direction that's similar to the direction of the vertex normals: computergraphics.stackexchange.com/questions/4839/…
– aces
Commented Mar 20, 2017 at 1:50