Page 1 of 1

OpenGL Ambient Light grays out my models

Posted: Fri Feb 03, 2012 8:51 pm
by superLED
Hello again.

I've tried to move forward to 3D programming, and I kinda understand the basic of OpenGL. But I seem to have problem with the lightning...
In my project, there is a 'object loader' function, which loads up a .obj file that I can render to my scene. It looks nice and all, but the parts where there is no light, there is completely black.
I have set the ambient light to 0.3, 0.3, 0.3 (and I've tried different numbers), but when I do this, the black just turn gray.
(When I load in the object, I don't read in the ambient light from the .obj/.mtl file)

What I want, is that the colors is still visible - just darker - when there is no light.

Is this the default way OpenGL handles ambient light, or do I do something wrong?
And is there a way I can make it 'not gray out' with ambient light?

Let me know if you need some code to read.

1: No light reaches this side of the face
2: Light on the object, but with amibent light as well, so it still somewhat grayed out.
3: With ambient light turned Off.
Image

Re: OpenGL Ambient Light grays out my models

Posted: Fri Feb 03, 2012 11:26 pm
by szdarkhack
Check this link and see if you do everything it says, especially setting the material color correctly: http://www.sjbaker.org/steve/omniv/opengl_lighting.html

If you cannot figure it out still, post some of the light setup and the rendering code. By the way, the old built in opengl lighting is horrible, you should consider writing a simple shader instead. Don't worry, opengl 2.0 is 8 years old, nobody will have compatibility issues ;)

EDIT: Here, i fixed it :)

Re: OpenGL Ambient Light grays out my models

Posted: Sat Feb 04, 2012 6:22 am
by Nokurn
szdarkhack wrote:Check this link and see if you do everything it says, especially setting the material color correctly: http://www.sjbaker.org/steve/omniv/opengl_lighting.html

If you cannot figure it out still, post some of the light setup and the rendering code. By the way, the old built in opengl lighting is horrible, you should consider writing a simple shader instead. Don't worry, opengl 2.0 is 15 years old, nobody will have compatibility issues ;)
Actually, OpenGL 2.0 is only 8 years old. Though I agree; unless you're specifically trying to maintain compatibility with ancient systems, go with shaders. It is possible to make a good looking game without the use of shaders (see Torchlight), but it's usually not worth the hassle, especially nowadays.

Re: OpenGL Ambient Light grays out my models

Posted: Sat Feb 04, 2012 9:55 am
by superLED
Thanks for the replies!
I have been reading a little bit about shaders, and I find it quite interesting. Tried to look through some tutorials, but I didn't understand much x) It may be that I didn't find the right tutorials
Do any of you have some links to tutorials/guides that are easy to follow for a starter?

In the meantime, I will check the link to see if I've done something wrong.
If that won't help, I may just put a dim light source at the cameras position, so the light will always hit whatever i'm looking at.