Textures not loading depending on image width and height

Hello to all. I am dealing with a strange issue.

In the example below there are 4 cubes with an image as texture. From the 4 cubes only the 2 show the texture correctly.

The only difference between the textures images is their hight and width.

The first(from the left) cubes image size is 512x512 (texture is loaded correctly)

The second cubes image size is 700x512 (No texture is shown)

The third cubes image size is 500x512 (No texture is shown)

The fourth cubes image size is 512x256 (texture is loaded correctly)

And from other images that i created i found that only images whose size was a power of 2 are displayed correctly.

Example 1024x512 , 256x256, 512x128 all are displayed correctly. Any other size appears black.

Also i tried different formats (jpg, gif) but there was no difference. It appears that only the size matters.

Here is the code i used:

package hello;

import com.jme3.app.SimpleBulletApplication;
import com.jme3.asset.TextureKey;
import com.jme3.bullet.collision.shapes.MeshCollisionShape;
import com.jme3.bullet.nodes.PhysicsNode;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;

public class Problem extends SimpleBulletApplication {

   public void simpleInitApp() {
    * This loads the models we want on our scene from the Models folder.
    * @param model The name of the model to load
   private void load_models() {
      //This shows the path where the folder Models is located
      assetManager.registerLocator("assets/", "com.jme3.asset.plugins.ClasspathLocator");
       Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
       TextureKey key1 = new TextureKey("Materials/tmp/as.png", true);
       Texture tex1 = assetManager.loadTexture(key1);
       mat1.setTexture("m_ColorMap", tex1);
       Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
       TextureKey key2 = new TextureKey("Materials/tmp/as1.png", true);
       Texture tex2 = assetManager.loadTexture(key2);
       mat2.setTexture("m_ColorMap", tex2);
       Material mat3 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
       TextureKey key3 = new TextureKey("Materials/tmp/as2.png", true);
       Texture tex3 = assetManager.loadTexture(key3);
       mat3.setTexture("m_ColorMap", tex3);
       Material mat4 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
       TextureKey key4 = new TextureKey("Materials/tmp/as3.png", true);
       Texture tex4 = assetManager.loadTexture(key4);
       mat4.setTexture("m_ColorMap", tex4);
       Box b1 = new Box(Vector3f.ZERO, 1, 1, 1);
       Geometry geom1 = new Geometry("cube", b1);
       Box b2 = new Box(Vector3f.ZERO, 1, 1, 1);
       Geometry geom2 = new Geometry("cube", b2);
       Box b3 = new Box(Vector3f.ZERO, 1, 1, 1);
       Geometry geom3 = new Geometry("cube", b3);
       Box b4 = new Box(Vector3f.ZERO, 1, 1, 1);
       Geometry geom4 = new Geometry("cube", b4);
   public void setuplight() {
       DirectionalLight dl = new DirectionalLight();
       dl.setDirection(new Vector3f(-0.5f, -1f, -0.3f).normalizeLocal());
       dl = new DirectionalLight();
       dl.setDirection(new Vector3f(0.5f, -0.1f, 0.3f).normalizeLocal());

 * Setup a floor for our scene
   public void setupFloor() {
       Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
       TextureKey key = new TextureKey("Interface/Logo/Monkey.jpg", true);
       Texture tex = assetManager.loadTexture(key);
       mat.setTexture("m_ColorMap", tex);
       Box floor = new Box(Vector3f.ZERO, 100, 1f, 100);
       Geometry floorGeom = new Geometry("Floor", floor);
       PhysicsNode tb=new PhysicsNode(floorGeom,new MeshCollisionShape(floorGeom.getMesh()),0);

 * @param args
   public static void main(String[] args) {
      Problem app = new Problem();


I also attach the files that are used as textures(the three of them)

Some drivers/hardware do not support textures with other sizes than power of 2.



So the only solution is to resize the images that i use as textures so that their size is a power of 2.

Thank you very much!  :slight_smile: