Jme null texture bug

Here is a bug with jme when trying to use an empty texture:


geometry.getMaterial().setTexture(“Texture”, new Texture2D());



at com.jme3.renderer.lwjgl.LwjglRenderer.setTexture(

at com.jme3.material.MatParamTexture.apply(

at com.jme3.material.Material.render(

at com.jme3.renderer.RenderManager.renderGeometry(

I think it sucks that jme doesn’t have a default null texture.

Here is the fix :


private static final Texture2D EMPTY_TEXTURE ;



BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);

Graphics2D g2d = image.createGraphics();


AWTLoader loader = new AWTLoader();

EMPTY_TEXTURE = new Texture2D(loader.load(image, true));





Why would you want to render a empty texture ? just wondering?

this bug came when i was testing a scene with 0 sprites = no texture.

So i had to set it to something, anything, the data may not be available beforehand e.g sprites created in simpleUpdate() instead of simpleInit().

maybe its part of my programming, i could always choose to attach the sprite mesh later instead at init().

Or you could wait to give it a texture until it actually has one. Seems like a waste to allocate memory, create an empty image, send it to the GPU, etc. to then not render anything.

you have a point, i will change my code to wait then.

There’s no such thing as a “null texture”. You can get a placeholder image using PlaceholderAssets.getPlaceholderImage()