basic shading programming

Started by
0 comments, last by jdindia 15 years, 4 months ago
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
Advertisement
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.

This topic is closed to new replies.

Advertisement