I am curious if there are other material defs that allow for placing multiple textures like the terrain defs? If a player or enemy needs multiple materials this would come in handy. If not would it be bad to use a terrain material def for a player/enemy when they have multiple materials?
If not would it be bad to use a terrain material def for a player/enemy when they have multiple materials?
If it works I don’t see why not. Looking at terrain’s shaders they don’t look to have any terrain specific assumptions.
If you want something very specific you can also write your own materials as well. Usually you start with a core JME material that is similar to what you want to do and duplicate it into your project then tweak it to add your affect.
E.g. Unshaded.j3md and its vertex shader and fragment shader
Writing shaders is not the easiest thing in the world but it is fun when you get an interesting effect
Usually, unlike blender, geometries would be split per material, so no single geometry uses more than one material. That’s how it works in JME at least as I’m sure you’ve found out by now. That’s logical to me personally, especially for animated/skinned player/enemy character models. What you would do in this case is just put all the textures you need into the single UV texture that you use for the entire character model. This would be a better way to do it rather than mapping multiple textures in a custom material def, and both would produce the same end result.
If you specifically need to have a material with multiple texture mappings (ie - you want to arbitrarily swap some of those textures during runtime), then do what richtea said and take an existing JME material and add either multiple texture parameters, ie Texture1, Texture2, Texture3 (or use a single TextureArray if you know how to). Then in the vertex shader you can select which one of the textures to use, using some sort of vertice data that you may put in the mesh yourself.
There are several ways to do it, but a simple starter would be vertex painting the character mesh in blender, for example you could paint a triangle: Red (1,0,0) = Use Texture1, Green (0,1,0) = Use Texture2, Blue (0,0,1) = Use Texture3. You could use a varying (in/out) int, for example let’s call it “texSelect”, then set it to 0/1/2 in the vert shader depending on what color the current vertice is (inColor), then in the fragment shader simply check what texSelect is equal to and sample the needed texture. (Note: better make it a “flat” varying so it doesn’t interpolate and become something like 2.2467)