Set up multiple DiffuseMap

How to set multiple DiffuseMap for spatial in the code? If the method in the screenshot doesn’t work, what should I do

Lighting.j3md only supports one DiffuseMap per material.

So if you want a model to use multiple textures, you would instead need to split the model into separate Geoemtries each with their own material. Or a more efficient approach, to keep them all as one Geometry with the same shared material, would be to use a texture atlas.

You can setup a texture atlas when you create your model, or if that is not an option, you could use the engine’s texture atlas batching utility:

There is also a Terrain and Terrain material in the JME terrain library that uses a unique shader to support multiple diffuse maps, but that may not be what you are looking for since you already are loading in a specific model.

Some game types, like voxel games, will also use unique shaders and procedural generation systems to handle a large texture atlas or sprite sheet of textures in their own way

So if you need more help with something more advanced, it could help to explain what type of model you’re using and what you are trying to achieve specifically.


like said above.

i belive you should tell us what you want to achieve first.

Lightning or PBR or etc are default JME Shaders, you can always copy them and make custom one that will use more textures. Also like said above, if you have materials in Blender for example, each material = geometry when converted to JME model, so you can setup texture for each material(geom here)

My purpose is to ensure that the MTL material file can be used normally when loading obj model. The content of MTL is shown in the screenshot

MTL content contains multiple newmtl and map_ KD, bump attributes, how to use this MTL file in JME


Just curious, but did you try it? I though the JME OBJ loader already supported multiple materials (and it will split the meshes as appropriate).

…else you may want to use a different format like gltf.

I’ve tried. Many materials are not loaded on the obj model

What software did the OBJ come from?