Hey guys!
I have a problem and I think there are different approaches so I would like to ask you guys which one is the best:
I have a simple Geometry, here the declaration
box = new Box(0.5f, 0.5f,0);
roboMaterial = new Material(app.getAssetManager(), RoboRally.UNSHADED);
roboMaterial.setTexture("ColorMap", app.getAssetManager().loadTexture("Roboter_Demo-01.png"));
roboMaterial.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
roboGeo = new Geometry("Roboter"+RoboterID, box);
roboGeo.setMaterial(roboMaterial);
roboGeo.setQueueBucket(Bucket.Translucent);
So: the texture is just a PNG. In Illustrator, i created the Roboter_Demo-01.png with three layers, so that I always could change the color of the two underlaying layers.
I want to create this effect in the game too. I guess it would work with three Geometrys, each with another layer as Material, setting the color of the Material to change the layers color. But I hoped that there is a method like setting three materials to one Geometry or only change a specific color to another, so that I would only need one Image.
1 Like
You only can set one Material for one geometry at a time. But you can of course change the material during runtime.
I donât know if something like layers is supportedâŚ
What kind of effect do you want to achieve exactly? I think, switching the material all the time could have a little performance impact, but I also could be wrong here.
1 Like
Thank you for your answer!
I donât want to change the material during the game. Lets say four players are playing. Every player can choose the color of his Roboter with two RGBA Values. The method is currently creating four exact same Roboters. Creating that many images and applying them to the material for each case would not be an option for obvious reasons. But I have the three Layers as single images. So coloring two of the layers with two RGBA Values and combing them in one Geometry would be the perfect solution for my problem. But is that possible?
1 Like
Everything is possible with shaders
Stock shaders and materials are enough for most situations, and are great starting point for customization. You have parameter named âDiffuseMapâ, so I guess you need DiffuseMap2, some additional color, all that added into copied Lighting (I guess that you need this one) material definition. After that you need to pass those extra values into shaders (copy materialâs shaders and modify them). Inside shaders do some color mixing and thatâs all.
1 Like
How do you attach them to the material, are those diffuse maps, or what are they used for?
Okay, @FrozenShade is a much more experienced and better skilled developer, so go for his suggestion, please. I just thought that it easier to apply the custom color through MaterialColors (for example diffuse). But I still donât know what those âlayer imagesâ are used for.
1 Like
I donât know either but I guess that there is something like basic texture and an additional layer which needs to be colored with custom color and applied. Think of robots with fancy textures of metal and symbols/paintings colored with red/green/blue - the color depends on playerâs fraction. So you cannot color all diffuse with material color, you need some âmapâ.
Did I understood it properly, @TheBlackBird ?
1 Like
Yeah could you show a picture of these layers or roboters? Im confused.
1 Like
Here is an image. Its 2D. Top Left ist the image how it should look after coloring and combining, the two white images are the layers which should be colored. Right now I am just setting the texture âColorMapâ with the Top Left image. My goal is to colorize the two white layers, and combine them with the left-bottom image to look like the one at the top left corner.
@FrozenShade, are DiffuseMaps a possibility here?
1 Like
Is this going to be used for a 2D or 3D game?
1 Like
Ok⌠now we have those layers. And how it should look?
How it looks in Illustrator? Show me two or three examples with different colors applied to layers.
1 Like
If you just want to set colors, you can either use vertex colors or a palette like iv shown in this thread
https://hub.jmonkeyengine.org/t/using-multiple-colors-in-geometrybatchfactory/38505/3?u=jayfella
This way you just use a single material for all colors. If you feel able, you could also add your logos to that texture.
For me, it was simpler to use a texture because i could change the palette and iterate over it easily for say a GUI color chooser. But you could define an array too when you got your palette defined as you want it.
1 Like