Modifying Texture through code

I’m having no trouble modifying a Texture2D, but is there any way to do something similar to set certain colors, such as magenta to a new color? If I have to do this through shaders, that’s OK, I’ll have to learn some basics of shaders, that’s all.

Basically, I am trying to modify a texture so certain parts are displayed with the player’s team colors. GUI portraits and the like are no problem, but the Texture on a model is different than a Texture2D in a GUI.

Mostly, I think I need a little push in the right direction.

Using a shader won’t help as shaders don’t modify the texture.

You need to mark the texture for GetPixels in the import settings and then use GetPixels, find all mangenta pixels and then replace it with a new color, afterwards applying the new colors through SetPixels followed by apply

Well to be fair, the process he wants would probably be best suited with a Color Replace shader so he doesn’t have to duplicate all the textures for each team.

There are DirectX examples for XNA, but the main idea being having an if statement within your Pixel shader that will replace all Magenta pixels with a colour of your choosing (specified per material) Look at some of the built in Shaders and add an extra Colour Picker dialog and an if statement.

http://create.msdn.com/en-US/education/catalog/sample/color_replacement
Is an XNA example, although you’ll have to convert the shader into CG/GLSL

Because I have several ships, but not a lot of textures still, I went ahead and did a color replace. It works pretty well, I was working towards Dreamora’s suggestion anyway, but having a second opinion is very helpful. I think the shader would be best, particularly if I had a lot of resources in use, but this game is not too resource heavy.

Thanks to both of you.