PDA

View Full Version : Lighting effect on unit sphere



thinhare
01-07-2010, 03:04 PM
Compared the lighting effect (shadow and such) on the sphere created using glutSolidSphere and the sphere created myself, it appears on the former one the transition from bright region to dark region is smooth, the border that separate the two regions is a piece of nice arc, while on the one I made, the border looks jagged. I guess the normal of vertex is the key...

Any ideas? :(

Jan
01-07-2010, 03:50 PM
You need to "smooth" your vertex normals.

Usually once first computes all face normals. Then one takes the normals of all faces that use the same vertex, adds them up and normalizes the result again. That gives you the average normal of all faces that use the same vertex.

Have fun,
Jan.

GreenAlien
01-08-2010, 06:17 AM
I guess, for a sphere only, it might be easier to just create a vector from the center of the sphere to the vertex in question, normalize it and then use it as the normal for the vertex.

thinhare
01-08-2010, 04:19 PM
Hello, Jan: I think that may make a difference, the one I made looks OK, just not as good as glutSolidSphere. I will try the averaging approach when I have got some time.

Hello, GreenAlien, yes, that was way I did it.