Page 1 of 1

Ambient Lighting - Possible bug?

Posted: Sat Dec 18, 2010 1:14 am
by Alonguy
Hello, I believe I have a problem that could possibly be a bug.
I just recently installed Windows XP Pro on a former Vista computer, and got Visual Studio 2008 Express edition. I got Irrlicht 1.7.2. I also got the latest DirectX SDK. I compiled Irrlicht, set up my enviroment, and began making a simple application. I loaded some models, and set ambient lighting to 0.5 all around.
(For half-lit.) I tested to see it, but the models were completely black! Then, I added a directional light. The light worked how it should, but looked horrible because of the lack of ambient light. (Lit on one side, black on the other.)
I tried these two commands: (smgr is scenemanager, vmgr is videodriver)

Code: Select all

smgr->setAmbientLight(video::SColorf(0.5f,0.5f,0.5f,0.5f));
vmgr->setAmbientLight(video::SColorf(0.5f,0.5f,0.5f,0.5f));
Niether worked.
However, emissive lighting seemed to work: (Maria is my model, an IAnimatedMeshSceneNode)

Code: Select all

	for (u32 i = 0; i < maria->getMaterialCount(); i++)
	{
		maria->getMaterial(i).EmissiveColor = video::SColor(255,150,150,150);
	}
This worked the way I wanted it to, but I'd rather use Ambient Lighting.
This strange problem occurs in both Direct3d and OpenGL.
(But NOT the software renderers.)

Before, when I was using Windows Vista and Irllicht 1.7.1, I had no problems.

Does anyone know what may be causing this? Is it a bug?

Picture:
Image

Posted: Sat Dec 18, 2010 11:22 am
by hybrid
By default, diffuse and ambient light is modulated with vertex colors. Maybe you simply have black vertex colors, which would lead to completely black ambient light. Consider to change the color material to ECM_NONE or whatever fits your coloring scheme.

Posted: Sat Dec 18, 2010 11:24 am
by CuteAlien
There is also the ambient-part of your light which will modify the result in some way. Although setting ambient on model and on global ambient should indeed be enought not to have black models.

Maybe you can try the example 22 - it allows playing around with the ambient settings of model, light and global ambient while setting textures of different colors to see the effects. So you could check if Irrlicht behaves as you expect.

I'm not on Windows right now and could only test on Linux where results looked ok in 1.7.2.

Posted: Tue Dec 21, 2010 6:20 pm
by Alonguy
The mesh was in .obj format, but I used to use .b3d! Apparantly, Blender expot .obj with different material settings or something. Exporting as .b3d worked!
Look:
Image

All is well. Now I just need to fix the skinned/animated version.