My models are black with DirectX

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
texel3d
Posts: 23
Joined: Sat Feb 28, 2009 2:45 pm
Contact:

My models are black with DirectX

Post by texel3d »

Hi,

i try to load Anim8or files in Irrlicht 3d (1.5 under Windows and Visual C++ 2005).
It seems to work with OpenGL but not with DirectX (9 and 8 ).
With OpenGL i have my texture with lights, but with DirectX 3D models are black. Why ?

You can download the .exe and the source code here (it is very simple)(Visual C++ 2005).
http://texel3d.free.fr/bugs/irrAn8Loader.zip

It depends on LibAn8:
http://texel3d.free.fr/projets/liban8/index.html

Thanks.
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

try dissabling the light on the model in directx with setMaterialFlag(EMF_LIGHTING, false);
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
texel3d
Posts: 23
Joined: Sat Feb 28, 2009 2:45 pm
Contact:

Post by texel3d »

Texture and colors are displayed with:
model->setMaterialFlag(video::EMF_LIGHTING, false);

It tells me that the problem comes from lighting, but why ?
Why does it work with OpenGL ?
What's wong in the way i add my light ?

Code: Select all

// Add a light
scene::ILightSceneNode* nodeLight = smgr->addLightSceneNode(0, core::vector3df(100,100,100),video::SColorf(1.0f,1.0f,1.0f,1.0f),20000.0f);

video::SLight light;    
light.Type = video::ELT_POINT;
light.AmbientColor = video::SColorf(0.3f,0.3f,0.3f,1);
light.SpecularColor= video::SColorf(0.4f,0.4f,0.4f,1);
light.DiffuseColor = video::SColorf(1.0f,1.0f,1.0f,1);
light.CastShadows = false;
nodeLight->setLightData(light);
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

It may be that your normals are bad, too short or facing the wrong direction. Try the normalize normals material flag, if it fixes the problem then they are too short (vertex normals should be 1.0 in length). Another thing to check is vertex colours.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
texel3d
Posts: 23
Joined: Sat Feb 28, 2009 2:45 pm
Contact:

Post by texel3d »

I have modified my model loader to use:
meshBuffer->Material.NormalizeNormals = true;

It do not solve the problem.

My vertices colors are white (for every vertices):
vertices[0].Color = video::SColor(255,255,255,255);
vertices[1].Color = video::SColor(255,255,255,255);
vertices[2].Color = video::SColor(255,255,255,255);

When i force emissive color of materials to be greater than zero, colors are displayed in DirectX.
But Lighting do not seems to be computed/used.
Colors should be used with emissive = (255,0,0,0) !?
And what about ligthing ?
And OpenGL always works very well...

Here is my material settings:

Code: Select all

meshBuffer->Material.Wireframe = false;
meshBuffer->Material.Lighting = true;
meshBuffer->Material.BackfaceCulling = true;
meshBuffer->Material.EmissiveColor.set(material->Alpha, material->EmissiveRGB[0], material->EmissiveRGB[1], material->EmissiveRGB[2]);
meshBuffer->Material.DiffuseColor.set(material->Alpha, material->DiffuseRGB[0], material->DiffuseRGB[1], material->DiffuseRGB[2]);
meshBuffer->Material.AmbientColor.set(material->Alpha, material->AmbiantRGB[0], material->AmbiantRGB[1], material->AmbiantRGB[2]);
meshBuffer->Material.SpecularColor.set(material->Alpha, material->SpecularRGB[0], material->SpecularRGB[1], material->SpecularRGB[2]);
meshBuffer->Material.Shininess = material->Brilliance;
meshBuffer->Material.NormalizeNormals = true;
texel3d
Posts: 23
Joined: Sat Feb 28, 2009 2:45 pm
Contact:

Post by texel3d »

My problem comes from lights and not from my mesh.
(i have converted my .an8 file to .3DS and i have the same problem)

Is there a complet tutorial about how to use Directional light (and light in general) with irrlicht ?
I can't do what i want. The result are different with DirectX and OpenGL. The example codes do not use light a lot.
Post Reply