Setting a texture

I am trying to put a texture onto an object using the following line

[java]mat3.setTexture("ColorMap", assetManager.loadTexture("Textures/terrain.jpg"));[/java]

It is giving me an error saying that

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException: Material parameter is not defined: ColorMap

at com.jme3.material.Material.checkSetParam(

at com.jme3.material.Material.setTextureParam(

at com.jme3.material.Material.setTexture(

at mygame.Main.simpleInitApp(


at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(



Is ColorMap the incorrect material parameter? If it matters, I dragged and dropped the jpg from my desktop into the Textures folder under Project Assets.

what material definition it is? for lighting you use “DiffuseMap” if it is unshaded and it dont work then try “m_ColorMap”

I am just trying to apply the image to a box. not lighting. just the image on the box.

I managed to fix it. I was using the wrong .j3md when i was creating the material. now its just too big haha. Any idea how to reduce the size of the texture on the box?


Box box = new Box(Vector3f.ZERO, 1.0f,1.0f,1.0f);

Spatial mybox = new Geometry(“Box”, box );

Material mymaterial = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mymaterial.setTexture(“ColorMap”, assetManager.loadTexture(“Textures/mytexture.jpg”));





asking about material definition i mean “Common/MatDefs/Misc/Unshaded.j3md”.

Nice you fix it

to scale texture use:


box.scaleTextureCoordinates(new Vector2f(2, 2));[/java]

thank you both very much. very helpful.

so i tried using the scaleTextureCoordinates function but this is what I get. The textures edges are just stretched. It seems really odd.

heres the screenshot i took. any idea whats going on?

enable texture repeat.

I’m guessing you scaled your texture down, once then engine gets to the edge of your texture it just stretechs the last row or column of pixels to fill the remaining geometry.

If you wanted to repeat your texture you could try tweaking your texture loading as follows…


Texture t = assetManager.loadTexture(“Textures/mytexture.jpg”);




… i use this in Lighting to get my textures repeating correctly.

Other options for changing how large your texture is appearing would be to change your geometry (make it smaller or further from the camera), or you could padd the edges of your texture (put blank space around the edge of your jpg, but please avoid this if at all possible, it’s a terrible use of resources… I feel dirty for just suggesting it but it may help someone understanding the issue).

If you’re still stuck, try explaining, or drawing, exactly what you’re trying to achieve, to help us answer you more effectively :slight_smile:

Good Luck


I think my best option is to either move it away from the camera or change the size of my geometry. It is pretty large right now.