Textures of different level of details

Hi,



I am trying to create a terrain (mainly of grass). I am using splat textures. For some time ago I looked Ogre3D demos and, if I remember correctly, there was a possibility to use textures of different level of details, depending on distance of view. That is, the field from near shows detailed grass and from far it seems more like smooth green surface.



Does JME support using textures of different level of details? It seems that using detailed texture does not look good when viewed from a distance. From a distance, the grass texture begins to generate patterns, even if it is a seamless texture.



Thanks

look into mipmaps

Hi,



I have been trying to create mipmaps. I have not found a good example how to create mipmaps from loaded images. Actually I have not found out, how can I even load jme Image. I have URL, which points to png image. How can I load jme Image using URL?



Thanks

Hi,



I wrote this code and tried to create a mipmap from two images, which are 512x512 and 256x256.



When I apply the mipmap image to a texture (see later code block), all I get is a white texture.



Does anybody have an idea what might be wrong? If I call createMipMap with only a 512x512 image, the texture is rendered correctly, but the texture is rendered white if I also add 256x256 image.



Thanks



public Image createMipMap(String[] imageNames) {

      Image[] images = new Image[imageNames.length];
      for (int j = 0; j < imageNames.length; j++) {
         URL imgURL = getURL(imageNames[j]);
         images[j] = getImage(imgURL);
      }
            
      assert images != null;
      assert images[0] != null;
      
      int width = images[0].getWidth();
      int height = images[0].getHeight();
      assert (width == height);
      int size = width;
      
      assert FastMath.isPowerOfTwo(size);

      int mips = images.length;
      Image r = new Image(Image.Format.RGBA8, width, height, 0, null);

      int bufLength = size * size * 4;
      int[] mipLengths = new int[mips];
      mipLengths[0] = bufLength;
      for (int i = 1; i < mips; i++) {
         mipLengths[i] = mipLengths[i-1] >> 1;
      bufLength += (mipLengths[i]);
      }
      r.setMipMapSizes(mipLengths);

      ByteBuffer bb = BufferUtils.createByteBuffer(bufLength);

      for (int i = 0; i < mips; i++) {
         ByteBuffer bbuffer = images[i].getData().get(0);
         while (bbuffer.hasRemaining()) {
            bb.put(bbuffer.get());
         }
         bb.rewind();
      }
      
      r.setData(bb);
      return r;
   }




Texture t0 = new Texture2D();
        t0.setMagnificationFilter(Texture.MagnificationFilter.Bilinear);
        t0.setMinificationFilter(Texture.MinificationFilter.BilinearNearestMipMap);
        t0.setImage(textureImage);

   t0.setWrap(Texture.WrapMode.Repeat);
   t0.setApply(Texture.ApplyMode.Modulate);

The easiest way to create mipmaps is use the Nvidia Photoshop plugin.  Just export as .dds and click the generate mipmaps button. http://developer.nvidia.com/object/photoshop_dds_plugins.html

Hi,



Unfortunately I don't have photoshop. :frowning: But I found dds plugin to gimp with ability to generate mipmaps.



It seems that using mipmaps made textures to look much better and sharper on different view distances. So, that is a good improvement (thanks for tip). :slight_smile:



Still, I get this pattern looping when viewing far a field of grass. Are there some mipmap tools etc to remedy this pattern looping effect? So some other tricks?

For posterity what was the name of the gimp plugin you used?

Hi,



I used gimp-dds plugin (in ubuntu the package name is gimp-dds)



I think this is the plugin's homepage:



http://code.google.com/p/gimp-dds/


As an alternative if u dont have PS and are scared of Gimp…like me :stuck_out_tongue: , u can try the compressionator from ATI also does normal map compression