[SOLVED] Texture looks blurry

Hello all,

I’am new in JME :). I am using the JME to develop a game for my final project. My game is a kind of driving simulation.



I made the scene using blender, export it as OGRE scene, then load it.

The problem is the texture of the road markings in front of the car looks blur. I think it doesn’t matter if the blur occurs far in front of the car.



QUESTION: What causes the road markings’ textures look blurry? Is there a way so that the texture of the road markings do not look blurry? Screenshoot:







Thank you very much for your attention.

Sorry for my poor english. :wink: I’m still learning

Normally blured textures in the distance is an artifact of mipmaping. This is a technique which reduces flickering and alias problem in 3D rendering.

http://en.wikipedia.org/wiki/Mipmap



I don’t think you want to turn of mipmaps (trilinear filtering) but you can change the MinificationFilter on Textures in code. But I’m not sure if this is the cause of your problems.

1 Like

Try higher res textures…

@kwando: thank you very much :D, seems like mipmaps was the cause. I have tried BilinearNoMipMaps MinFilter and textures appear as good as i want. I also tried NearestNoMipMaps and seems like the result is the same as BilinearNoMipMaps.

QUESTION: Do the BilinearNoMipMaps and NearestNoMipMaps have a different performance? Because I can’t see any difference in my game’s fps and i have no knowledge in texture filtering. My game still run smoothly at 80-100fps.



@zarch: i already use high res texture 8).

@generalkyu np.



Modern GPU:s are good at texture filtering, that’s not the first thing to worry about :slight_smile:



I think not using mipmaps could increase the memory bandwidtdh (memory bandwidth is precious) and be worse for the cache, but this is just me guessing.



Best thing is to measure :slight_smile:

@kwando: thank you for quick reply :). Now i can continue my project. Still lots of work to be done.

Not using mipmaps will lead to aliasing artifacts, use anisitropic filtering for the texture

1 Like

Wow, the textures appear smoother and less flickering :D. I didn’t mind the flickering before, but now the textures looks better with less flickering. Thank you. I really need to learn more.

@generalkyu you will need to set Anisotropy for your texture by yourself. By default Anisotropy = 0. I would recommend you to set Anisotropy to 2 or 4.



For example in Left4Dead2 default anisotropy = 2. Also, in Left4Dead only 5 levels of mipmap of textures.



Descussed here:

http://hub.jmonkeyengine.org/groups/graphics/forum/topic/what-should-be-anisotropy-level-for-textures/

Mipmaps are vital. They are should be used.



Just try to set anisotropy for your textures.

For example I load a texture like this:



[java]

// Set Diffuse Map

String strDif = texturePath ;

TextureKey tkDif = new TextureKey(strDif, false);

tkDif.setAnisotropy(2);

if (strDif.indexOf(".dds") < 0) tkDif.setGenerateMips(true); // if this is not DDS texture

Texture diffuseTex = asset.loadTexture(tkDif); // Load a texture



matNew.setTexture("DiffuseMap", diffuseTex); // Set diffuse map

[/java]

Is there a way to set anisotropy in j3m?

I did not find the way. Possibly, we need a feature request for the Normen (j3m). Or get the feature to the assetManager(apply to all textures) for the Momoko_Fan.

@mifth : thanks a lot :). I’ve tried it and the result was great and almost the same with my code before. No need to change the MinFilter on textures. This is my code before (i just implemented it with my poor knowledge :roll: ) :

[java]

Texture pendek_normal = getAssetManager().loadTexture(“Materials/asphalt_short_normal.jpg”);

pendek_normal.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);

pendek_normal.setAnisotropicFilter(4);

jalan_pendek.getMaterial().setTexture(“NormalMap”, pendek_normal);

[/java]



as you said, i changed it :

[java]

TextureKey jalan_pendek__diffuse_key = new TextureKey(jalan_pendek_url, false);

jalan_pendek__diffuse_key.setAnisotropy(4);

if (jalan_pendek_url.indexOf(".dds") < 0) jalan_pendek__diffuse_key.setGenerateMips(true);

Texture pendek_diffuse = getAssetManager().loadTexture(jalan_pendek__diffuse_key);

jalan_pendek.getMaterial().setTexture(“DiffuseMap”, pendek_diffuse);

[/java]



what is the difference of using/not using TextureKey? Thank you for your help :).

@generalkyu you should use MipMaps.

  • Do you use dds textures? if yes, so you need to generate mipmaps with dds generation.

    in your old code i see “BilinearNoMipMaps” is used. I suppose you do not generate mipmaps at all. But mipmaps are needed for better performance.

Try this (without “if(…)”):

[java]

jalan_pendek__diffuse_key.setGenerateMips(true);

[/java]



it will always generate MipMaps.

Done.

Thank you @mifth

I learn a lot from this forum, :slight_smile: