This topic is 3668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I got a question about Graphic Programming. A very basic graphic programming uses almost no OpenGL Lib. So Im trying to simulate a basic shading to a polygon build by triangles. So I got the light source, the color of the light, and triangles, which has a color. I know that I should find the normal of each triangle, but then what happened? How the angle between normal of triangles and light source may affect the end result? How can I represent the color of the triangle based on the lighting effect in a math formula? Thanks in advance

##### Share on other sites
There's got to be a FAQ describing lighting somewhere, which I can't seem to find. There are certainly lots and lots of books that cover this as well.

In very brief summary, light on a surface is broken up into 3 parts, ambient, diffuse, and specular. Ambient is basically the overall light in the scene. Diffuse is the light that hits the object and goes every which way. Specular is the light that hits the object and bounces off it like it was a mirror.

For a simple lighting model, we just sum them up. Ambient is constant for the scene being rendered. Diffuse is color*(N dot L) (where dot is the dot product, N is the triangle's normal and L is the vector from the point in question to the light - all normalized). Specular is more involved and there are many different models (http://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model, for example). If you just want a very simple rendering, OpenGL does all of this automatically.

1. 1
2. 2
Rutin
29
3. 3
4. 4
5. 5
khawk
14

• 11
• 11
• 23
• 10
• 9
• ### Forum Statistics

• Total Topics
633648
• Total Posts
3013110
×