'Units-colors' Shaders? Textures where material color is visible throu texture?

Hi, on much games, textures are often used on different faction/players only replacing one (pink-color, or alpha-channel<-better like in ‘Glest’) -color in the texture by material/faction/player -color.

Hope someone can understand what I mean. I’m not a native-english, so I even dont know how such textures/shader-features are called.

Here is an example from Civ (the textures are the same, only the arm-colors are replaced by player colors):

How to do such in jmonkeys? Are there default shaders that already can do such?
Or are there people around that have archived that? Can me someone point to tutorials where such is done and how I do that in monkeys?

I tried to view the Wesley-tutorials, but did not find that feature and I’m new to shaders.
So where should I dig?

This will require that you write a shader or convert over to shader nodes to modify the existing shaders you are using.

The general idea would be:

  1. Create an alphamap (i.e. greyscale image black - discard color white = full saturation) to define the areas that you want to apply color. Here would be the diffuse and alpha(actually color)map


Alphamap (used for applying color to specific area):

  1. Take samples of the alphamap at the same texCoords as the diffuse
  2. Apply the defined color to the output color of your frag shader based on how white the alphamap sample is.

Hope this helps.

It helps a bit, but how is the technic called (so I can dig for more infos on such shaders, cant belive I have to reinvent that wheel)?
Also, there a lot of games that use it AND they dont have separated alpha map-texture, they store their alphamap inside their normal tex texture (parts look a little greyish transparent, besides the normal other colors).

Do you know if Wes has tutorials exactly on such, I have seen he did a lot on shader, too much for me to find things, while I still dont now on what topics I should search?

You can do it that way, however…

The above allows you to use greyscale to blend the color in and still show the detail you want.

Either way, you’ll have to modify the shaders to eval the sampled color.

The basic gist isn’t difficult… where it gets complex is:

  1. If you are using lighting, you will have to fork the lighting material/shaders.
  2. You will have to maintain them to account for updates added to the core
  3. You will have to have a decent understanding of most of the lighting/normal mapping techniques used in the shader to ensure that you are not trampling over other techniques you may wish to implement.

I understand that you feel that this is a widely used technique, but it is game/genre specific and outside of the scope of lighting which is the focus of the lighting material.

The lighting material covers a WIDE variety of different lighting/normal mapping techniques as is and is rather bloated currently. I can guarantee that this sort of thing has a -25% chance of being added to the current lighting material.

My suggestion would be to take the dive head first into shader dev as you will find more and more needs that have not been/will never be written for you.