Jump to content
  • Advertisement
Sign in to follow this  
svnstrk

OpenGL basic shading programming

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!