Material Color Problems

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
mss
Posts: 24
Joined: Mon Oct 29, 2012 6:41 pm

Material Color Problems

Post by mss »

On an untextured node, loaded from .obj file..

Code: Select all

 
        node->getMaterial(0).ColorMaterial = irr::video::ECM_NONE;
        node->getMaterial(0).SpecularColor = irr::video::SColor(255,0,0,0);
        node->getMaterial(0).AmbientColor = irr::video::SColor(255,0,0,0);
        node->getMaterial(0).DiffuseColor = irr::video::SColor(255,50,50,50);
 
Which gets me this (the knob and switch you see):

Image

Setting the color material ECM_NONE is the only thing that gave me any control of colors. Emissive still seems to work fine. However I'm finding it very difficult and non-intuitive to change diffuse and ambient color.

I have no idea why the smaller meshes are reacting so poorly to the lighting as compared to the rest of the meshes in the scene, it makes no sense to me. Even after overriding the colors, they still show up wrong.

I am using irrlicht from the trunk of about a week ago.. so.. will update it and recompile. But I swear when 1.8 released, lighting went to crap. Any confirmations elsewhere?
mss
Posts: 24
Joined: Mon Oct 29, 2012 6:41 pm

Re: Material Color Problems

Post by mss »

CONTINUING ON..

And if I set the color values to RIDICULOUSLY low values,

Code: Select all

        
                node->getMaterial(0).ColorMaterial = irr::video::ECM_NONE;
        node->getMaterial(0).SpecularColor = irr::video::SColor(255,0,0,0);
        node->getMaterial(0).AmbientColor = irr::video::SColor(255,4,4,4);
        node->getMaterial(0).DiffuseColor = irr::video::SColor(255,5,5,5);
 
I can come up with some decent-looking colors:

Image

But that's using the values 4 and 5!!!! You would think the spectrum would be a bit more spread out...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Material Color Problems

Post by hybrid »

Did you scale the buttons up or down? This problem is often raised due to wrongly scaled normals.
mss
Posts: 24
Joined: Mon Oct 29, 2012 6:41 pm

Re: Material Color Problems

Post by mss »

Hybrid.. actually... I do scale the controls down. I always recalculate the normals for mesh because they are bad when I load the .obj file.

So I changed the scale to 1,1,1 and set the materials to default and it looked better. But how do I normalize normals on a node after it is scaled?

Or should I just go back and scale everything so that I don't need to use scale in code? I'd rather just use the current fix I have, really. It's simplest.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Material Color Problems

Post by CuteAlien »

You can set NormalizeNormals to true in the materials.
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
mss
Posts: 24
Joined: Mon Oct 29, 2012 6:41 pm

Re: Material Color Problems

Post by mss »

Tried that. Can't remember the outcome.. I think nothing happened. Would have to try it again to be sure.
Post Reply