danielepanozzo / cg-old

44 stars 16 forks source link

I feel like the Specular shading ball is not right #89

Closed TrojanFighter closed 5 years ago

TrojanFighter commented 5 years ago

I am moving forward but... image My shading attempt felt weird. The left bottom one is the specular one and it has huge colored parts outside the black areas. Also I don’t know what should be the right value range of ambient light(affected the right bottom one), -1 or 1 maybe?

TrojanFighter commented 5 years ago

In my MakeSphere() I used Vector3d RValue = 2 (ray_normal.dot(LightDirection))ray_normal - LightDirection; double Specular1 = pow(RValue.dot(cameraDirection.light_direction), 10); to calculate Specular value.

danielepanozzo commented 5 years ago

The ambient light component should have a much smaller impact than the other two. A weight of 0.1 or 0.2 (out of 1) is usually a good choice. The specular highlight looks indeed strange. Could it be that you forgot to normalize some of your vectors?

TrojanFighter commented 5 years ago

Oh I guess this might be right? image

It looks I misuse the vector from light source to point as" light direction"