Sign in to follow this  
pikebu

GDI+ simulating light, color values

Recommended Posts

hi, i'm working on a vrml viewer with gdi+. now i have the problem with calculating the different lightvalues for my object. when i paint all the polygons with all the same color you can't see anything of 3d. it all looks like a 2d shape filled with one color. hope u know what i mean. now i'm calculating the normals, get the x value and the arcus cosine of it. then i multiply it with a fixed value to get a result beween 0 and 255. my code looks like this: int blue_value = (int)(Math.Acos(face.normal.x) * 81.16; then i'm just taking the original red and green values and the calculated blue value for my brush color. this works fine with only a few clear colors like blue with rgb(0,0,bluevalue), but it starts to look totally bad with more different colors, especially with not clear red, green or blue values. then the calculated color turns from e.g. blue to green etc. hope u know what i mean. has anyone a good idea to calculate the different values for a color, without gettin these results?

Share this post


Link to post
Share on other sites
To change the intensity of a color, multiply all three components by the same value. That will prevent the problem you are describing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this