Light / material problem...

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
Mobius
Posts: 14
Joined: Sun Dec 18, 2005 3:16 pm

Light / material problem...

Post by Mobius »

I have a problem with light/material... =(

I created a simple custom scene node.

I added a light:
light = scene_manager->addLightSceneNode(0, camera_position, SColorf(0.3f, 0.3f, 0.3f));

And I used a material with these parameters:
material.AmbientColor = SColor(255, 20, 20, 20);
material.DiffuseColor = SColor(255, 20, 20, 20);
material.EmissiveColor = SColor(255, 20, 20, 20);

With OpenGL I have this result:

Image

But with Direct3D8/9:

Image

What is the problem?
Is it "normal"?
Maybe I forgot something in my code... =(


Thanx!
Vox
Posts: 47
Joined: Fri Apr 01, 2005 5:25 pm

Post by Vox »

It is a problem with D3D renderer.

Try this (in setRenderStates3DMode):

Code: Select all

       if(ResetRenderStates)
       {
          pID3DDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
          pID3DDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
          pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
          pID3DDevice->SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
       } :
Mobius
Posts: 14
Joined: Sun Dec 18, 2005 3:16 pm

Post by Mobius »

Great, it works! =)

Thanks!!
Guest

Post by Guest »

does that mean that we need to compile the engine with tese lines? or can we apply them directly in our own program?
Mobius
Posts: 14
Joined: Sun Dec 18, 2005 3:16 pm

Post by Mobius »

Anonymous wrote:can we apply them directly in our own program?
I am not sure...
Anyway, I recompiled the engine =)
Guest

Post by Guest »

Is this "problem" because D3D enables specular by default or something? Is that what you are seeing in the DX screenshot? (specular reflection when none specified) - or is it bad lighting?
Vox
Posts: 47
Joined: Fri Apr 01, 2005 5:25 pm

Post by Vox »

Anonymous wrote:Is this "problem" because D3D enables specular by default or something?
It is a problem because D3D doesn't take material source while shading triangles. It takes only only information from vertex (like color) into account.

This problem is reported before on this forum. Somehow, Niko missed that.
Guest

Post by Guest »

hum, i'm not sure it even takes color informations.
i have a ms3D map created with milkshape of course.
i imported it to irrlicht, results are:
- opengl: color rendered as i set them into my ms3D but alpha values of materials are not loaded. (even if i try to set the alpha values directly in irrlicht, there is a problem and my map is whole black with some bad triangle we can looked when the camera moves even if i set up a light)

- directx: no problem excepts colors are not loaded, my map is whole white if i don't set up a light

i think a patch could be useful for users who don't want to recompile the engine (i don't want to install DX SDK in order to compile the engine)
Post Reply