Page 1 of 1

Coloring textures?

Posted: Sun Aug 16, 2009 8:17 am
by Reiko
Hello

I think the answer to this is very simple but I am not sure what I am doing.

I have a mesh with a monochrome texture. How can I apply something similar to a "Color balance" sort of thing, which exists in graphic programs such as Adobe Photoshop and GIMP, to the texture to change the color?

Basically, all my characters have a black-and-white hair texture and I want to be able to let the player choose an RGB color for their hair color. So rather than having 10 different textures that are coloured differently to choose from, I want to use the one black-and-white texture for everyone but be able to apply any different color to it.

What is the best way to go about this?

I'm not sure if it matters, but I dont have any lights, I just got the EMF_LIGHTING set to false on the node for the hair.

Thanks in advance.

Posted: Sun Aug 16, 2009 9:15 am
by bitplane
See the DiffuseColor method of SMaterial, just get the material and set the colour to something other than white.

Posted: Tue Aug 18, 2009 1:54 am
by Rei
Hey again (forgot the pass to my other acc >.>)

I tried your suggestion, but I must be doing something wrong, cause the texture still shows as monochrome like before. (nothing changed)

This is what I've got.

Code: Select all

mesh = smgr->getMesh("data\\malehair.x");
node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialTexture( 0, driver->getTexture("data\\malehair.jpg") );
node->setMaterialFlag(EMF_ANISOTROPIC_FILTER, true);
node->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
node->getMaterial(0).DiffuseColor.set( 255, 255, 0, 255 );
Is there something else I've forgotten to do?

Posted: Tue Aug 18, 2009 8:30 am
by hybrid
Maybe you have more than one material?

Posted: Sat Nov 21, 2009 12:21 am
by Reiko
I know this is pretty old now, at the time I couldnt solve it but I was trying just now, now that I know my way around irrlicht a little better, and I figured out a way to do it.

I just did

Code: Select all

smgr->getMeshManipulator()->setVertexColors(nodeHair->getMesh(), SColor(255, 0, 0, 255))
or whatever color. Pretty simple. This way was better cause I didn't have any lights, I think the diffuse color and such will only work with lights or something.