In our game we are using vertex colors only for displaying objects (no tetxures at all) but only vertex colors look a bit boring. So I thought if we would have different textures with different patterns and multiply them with the vertex colors the objects would get some better looking skin. For example, having a standard grass pattern texture which gets multiplied with the green vertex colors of the grass, therefore making the grass look better.
Unfortunately, I am pretty new to 3D-Graphics so this question might sound stupid, but is there already a material for that in Jme or would I have to write one by myself (which would be a long task for me I guess with all the GLSL stuff to learn).
Well thanks. So I could keep using the default Lighting Material, but which parameters will I have to change in order to achieve that? The vertex color should still be the main color for the models, so setting the diffuse map wouldn´make sense right? So what do I have to change in order to multiply the texture with the vertex color?
Yeah I already looked into it, but as I as I said I am pretty new to 3D-Graphics so that´s all a bit overwhealming looking at the code
But I found this line inside the Lighting material so I guess this piece of code is doing the magic I am searching for
So I´ve tried giving the material a diffuse map, but the pattern of the diffuse map isn´t displayed on the objects surface. Instead it just darkens the object a bit (so it indeed multiplies the textures color with the vertex color).
Have i forgotten a step, because I haven´t assigned UV-Coordinates anywhere. I´ve just set the materials diffuse map.
You may need to carefully craft your texture for this purpose - with default material colors do blend not in a most fancy way possible due to nature of color representation in digital world. And UV surely should be baked in model, when you make it in 3d-tool or dynamically generate mesh.
Thanks, already thought that this might be the problem.
So for the objects like trees, etc. I can apply the texture in blender. But for our terrain which is randomly generated and created using our own FlatShadedTerrainGenerator I don´t know how to proceed. Do I have to assign the UV-Coordinates when creating the terrain, like I assign the vertex color there?
Ok seems I have to do some research on that subject. But would using the Jme Terrain Material be an solution? Like in the terrain example on the wiki, using a texture to define where which material should be apllied. Like red means grass, etc.
You’ll need to calculate a proper UV anyway. And for complex terrain it may be quite tricky.
If by “repeating” you actually mean “multitexture mixing” then I think Terrain Material is a way to go, but I never used it personally as I prefer to write custom shader code and do weird things like storing texture id and offset in a pixel.
Otherwise it will be an overkill. For example, you could have one big texture containing all terrain textures and just calculate proper UV for your vertices when generating a mesh - no need to use expensive mixing techniques or write custom shader - just clever mesh generation.
With repeating I meant that if I have a terrain texture which is 512x512 pixel, which should be used for the whole terrain, the texture shouldn´t be stretched on the whole terrain, but the texture should repeat itself. But how would something like this look in GLSL? Any short code piece would be appreciated