Material DiffuseMap not working

I’m following the jMonkey documentation to learn about materials, and I got transparent objects and shaded objects working, but when I tried to add textures to a shaded object, the game crashes with this exception:

IllegalArgumentException: Material parameter is not defined: DiffuseMap

This is the code that makes the material which is causing the issue:

brickMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
TextureKey brickKey = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
Texture brickTexture = assetManager.loadTexture(brickKey);
brickMaterial.setTexture("DiffuseMap", brickTexture);
brickMaterial.setColor("Ambient", ColorRGBA.White);
brickMaterial.setColor("Specular", ColorRGBA.White);
brickMaterial.setFloat("Shininess", 128f);

The docs says that I should use DiffuseMap for “Phong-illuminated” materials but the program says it is invalid…?

That code works perfectly fine for me, so the error is likely caused by something else.

Are you messing around with brickMaterial anywhere else?
What is the stack trace of your error?

As codex suggests, you’ve left 99% of the useful information out of the stack trace so we can’t help further.

The code you posted looks fine. Your problem is probably somewhere else. Do you have other shapes/materials?

Lighting.j3md definitely has a DiffuseMap parameter:

1 Like

The error was for a different material. I should’ve checked the line number of the problem…