[SOLVED] black models with setAmbientLight

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ritti
Posts: 90
Joined: Tue Apr 10, 2012 12:09 pm

[SOLVED] black models with setAmbientLight

Post by ritti »

Hiho, as the title says, I have black models if I use

Code: Select all

smgr->setAmbientLight(video::SColor(255,255,255,255));
Do I need to add additional lights? I thought the ambient light would do the work. Or am I missing something other?
If yes, what would be the best way to acchieve an appropriate light behavior for a strategy game?
I wan't to have constant light over the whole scene, like in all common strategy games :)
But I cannot use

Code: Select all

node->setMaterialFlag(EMF_LIGHTING, false);
because the models would look a little bit strange, without any shadow and so on.

Help would be much apreciated
Best regards
Ritti
Last edited by ritti on Mon Jul 29, 2013 5:36 pm, edited 1 time in total.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: black models with setAmbientLight

Post by mongoose7 »

Setting ambient light to one should have the same effect as no lighting. That is, your objects will not exhibit light and shade. If your objects are textured, make sure the texture is loaded, otherwise make sure the vertex colours are correct.
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: black models with setAmbientLight

Post by CuteAlien »

Yeah - ambient light should be enough - but your model itself might be black - then it stays black no matter of the light.
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
ritti
Posts: 90
Joined: Tue Apr 10, 2012 12:09 pm

Re: black models with setAmbientLight

Post by ritti »

Well, I have textured models, and If i apply a light, I can see the models with textures. So I can assume that the textures are loaded properly.
Maybe there is another reason why they are black?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: black models with setAmbientLight

Post by mongoose7 »

I think you need to set an ambient value on the material.
ritti
Posts: 90
Joined: Tue Apr 10, 2012 12:09 pm

Re: black models with setAmbientLight

Post by ritti »

What do you mean with set an ambient value on the material?
I tried to set ambient Color in Blender to white, and in Irrlicht

Code: Select all

node->getMaterial(0).AmbientColor = video::SColor(255, 255, 255, 255);
but without success. Is this what you mean?

Thanks and best regards
Ritti
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: black models with setAmbientLight

Post by randomMesh »

ritti wrote:

Code: Select all

smgr->setAmbientLight(video::SColor(255,255,255,255));
This is wrong. irr::scene::ISceneManager::setAmbientLight() take an SColorf, with float values.

Caution: The alpha value ist the last one, not the first: SColorf (f32 r, f32 g, f32 b, f32 a=1.0f)
"Whoops..."
ritti
Posts: 90
Joined: Tue Apr 10, 2012 12:09 pm

Re: black models with setAmbientLight

Post by ritti »

Oh yes you are right, I posted the wrong line as I was playing around with the valies :)
But it doesn't work neither with SColorf(1.0f,1.0f,1.0f,1.0f)
Edit: I just tryed to import dwarf from the irrlicht media folder, and Its not completly black. Its a little dark but I can see the texture, so I assume I have to do something with the materials in blender, but I dont know what.
I tried to set Diffuse and Ambient to 0.5
And in the World menu I tried to set Ambient Occlusion and Environment Lighting (1.000) and activated Paper sky, Blend sky and Real sky (with grey as color) but all this without success
luthyr
Posts: 69
Joined: Wed Dec 30, 2009 5:47 pm

Re: black models with setAmbientLight

Post by luthyr »

Hmm, have you also tried changing the Diffuse color to white and/or Emissive color of the material?
ritti
Posts: 90
Joined: Tue Apr 10, 2012 12:09 pm

Re: black models with setAmbientLight

Post by ritti »

Yes but without success.
Could this be because of the .obj format?
I tried b3d too but it didn't change anything

Edit: Ok the mesh seems to work now, I recreated it and can load it in the Meshviewer (I removed first the lights, and set useLights=true) from the examples. But If I want to load it in my scene it stays black.
Btw, dwarf isn*'t totally black but I can see him even without ambientlight, so I think that something with my ambientlight doesn't work.

Ok I just solved it :)
It was a problem with my irrlicht installation. Recopied the headers and now it works.
Thanks again and have a nice day :)
Post Reply