Ambient Lighting - Possible bug?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Alonguy
Posts: 9
Joined: Mon Feb 01, 2010 3:37 am

Ambient Lighting - Possible bug?

Post 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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Alonguy
Posts: 9
Joined: Mon Feb 01, 2010 3:37 am

Post 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.
Post Reply