Rendered texture doesn't look like the original

This is probably due to texture compression, a common problem.



Use the com.jme.image.Image.GUESS_FORMAT_NO_S3TC tag in loadTexture to turn off automatic compression.



 

Hi



This may have been the same issue I had, try the following texture loading parameters

"<texture name>", Texture.MM_NONE, Texture.FM_LINEAR, com.jme.image.Image.GUESS_FORMAT_NO_S3TC, 1.0f, false



This will use no mip mapping, and disable the texture compression.

Also make sure that your textures are power of 2, although JME does resize them if they are not, but that will potentially effect the rendered image.

Endolf

:cry:



I use the following code for one tile:



        ts = display.getRenderer().createTextureState();
        final File f = new File("L:/projects/myrpg/prototype/tiles.png");
        ts.setTexture(TextureManager.loadTexture(f.toURL(), Texture.MM_LINEAR, Texture.FM_LINEAR));
        ts.setEnabled(true);

        final AlphaState as = display.getRenderer().createAlphaState();
        as.setBlendEnabled(true);
        as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
        as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
        as.setTestEnabled(false);
        as.setEnabled(true);

        textureCoordinates = BufferUtils.createVector2Buffer(4);
        textureCoordinates.put(getUForPixel(0,64)).put(getVForPixel(0,64));
        textureCoordinates.put(getUForPixel(0,64)).put(getVForPixel(0+16,64));
        textureCoordinates.put(getUForPixel(0+32,64)).put(getVForPixel(0+16,64));
        textureCoordinates.put(getUForPixel(0+32,64)).put(getVForPixel(0,64));

        ISOTile i;

        terrain.attachChild(i = new ISOTile("1", 0, 0, 0, ISOTile.U_TYPE));
        i.setRenderState(as);
        i.setTextureBuffer(0,textureCoordinates);
        i.setRenderState(ts);



Changing as you said

Endolf said:

"<texture name>", Texture.MM_NONE, Texture.FM_LINEAR, com.jme.image.Image.GUESS_FORMAT_NO_S3TC, 1.0f, false




make the screen entirely black  :-o :? :-o

How bizarre! Could it be the format of my PNG being not supported?

Why did you also change MM_LINEAR to MM_NONE?

renanse said:

Why did you also change MM_LINEAR to MM_NONE?


When I was having issues with my textures MojoMonkey suggested that mipmapping might be uglifying my textures, he suggested turning off mip mapping, and it remained in my code when the texture compression was discovered as the fault. As my texture is only being used as a HUD style component, it doesn't need mipmapping anyway, so the extra textures would just be a waste of memory.

HTH

Endolf

I've seen where not having mipmaps caused no texture to appear unless the textured object was in the exact right position to use the full scale texture.  May not be the issue here, but your comment about it turning black kinda reminded me of that.

Yeah  :smiley:



At last, it worked with the following code:


TextureManager.loadTexture(sprite.getTextureFileNameAsURL(), Texture.MM_NONE, Texture.FM_LINEAR, com.jme.image.Image.GUESS_FORMAT_NO_S3TC, 1.0f, true)



Note the true.

However, I've simplified the texture loading as following:


TextureManager.COMPRESS_BY_DEFAULT = false;
...
TextureManager.loadTexture(sprite.getTextureFileNameAsURL(), Texture.MM_NONE, Texture.FM_LINEAR )



since this is what my game requires  :)

Anyway thanks!!!

I've only found 1 texture so far where the compression introduces artifacts, my other textures seem fine. Having compression on should save some video ram, which isn't a bad thing, although we arn't short of it on high end cards these days :slight_smile:



Endolf

Well, you're right concerning memory consumption and large amount of VRAM…  :slight_smile:

(but In my case, I assure you, that I prefer to have the original rendering of the textures)  :wink:





BTW, is it possible to find how many VRAM is used by the textures :?


Endolf said:

I've only found 1 texture so far where the compression introduces artifacts, my other textures seem fine. Having compression on should save some video ram, which isn't a bad thing, although we arn't short of it on high end cards these days :)

Endolf


If you care a lot about this you should consider using DDS textures with DXT(5) compression.A lot less artifacts, and more savings (also RAM, not just VRAM). The drawback is older cards don't fully support it, though you could always use the usual textures as a fallback for that.