Textures blured after import a mesh uv mapped (mipmap?)

Hello all.

I have import a model UVmapped in JME . The model is good the texture is on the model but blured…

if I approach the model i see the detail of texture but at a normal distance the texture is blured.

i think that is due to mipmap texture generation but how i can reduce the mipmap effect ?

Thanks for your help :slight_smile:

http://hub.jmonkeyengine.org/javadoc/com/jme3/texture/Texture.html#setMagFilter(com.jme3.texture.Texture.MagFilter)

Possibly this will help you. But it works only with j3m materials.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:anisotropic_filtering

hello

I dont know how acces on many textures use by my models because i don’t have a methode like mySpacial.getMaterial() i dont use any material just a .j3o file

[java]
sceneLigne = assetManager.loadModel(“Models\L12v2\SceneLigne12.j3o”);
sceneLigne.scale(1f, 1f, 1f);
[/java]

i don’t how use setMagFilter()

well recursivly go down to the geometry objects
there you can do getMaterial
there you can get the Materialparams
then loop over all with type texture
then get the texture
then where texture not null set the filtering.

" go down to the geometry objects " … i am idiot maybe :slight_smile: but i am stuck on this point…

I work on netbeans not in JME sdk

@hedi said: " go down to the geometry objects " .... i am idiot maybe :) but i am stuck on this point..

I work on netbeans not in JME sdk

do instanceof to determine the type of a spatial

recursive(Spatial spat)
if spat instanceof Node
-> cast to node and call for all children this method
if spat instanceof Geometry
-> cast to gemotery and do work

I try this code

but in if ( spacialContent instanceof Geometry ) spacialContent is never instance of Geometry…

Is the code right ?

[java]

sceneLigne = assetManager.loadModel(“Models\L12v2\SceneLigne12.j3o”);
if (sceneLigne instanceof Node ){
Node sceneLigneCastNode = (Node) sceneLigne;
Iterator sceneLigneNodeIterator = sceneLigneCastNode.getChildren().iterator();
while(sceneLigneNodeIterator.hasNext()){
Spatial spacialContent = (Spatial) sceneLigneNodeIterator.next();
if ( spacialContent instanceof Geometry ){
Geometry spacialContentCastGeo = (Geometry) spacialContent;
List listMaterialParams = (List) spacialContentCastGeo.getMaterial().getParams();
Iterator listMaterialParamsIterator = listMaterialParams.iterator();
Texture testTexture = null;

                while(listMaterialParamsIterator.hasNext()){
                    Object objectParam = listMaterialParamsIterator.next();
             
                    if ( objectParam.getClass().equals(testTexture.getClass()) ){
 
                        Texture myTexture= (Texture) objectParam;
                        myTexture.setMagFilter(Texture.MagFilter.Bilinear);
                    }
                }
         
           }
        }
    }

[/java]

Well you might have nested layout,
node -> node -> node -> geom
But the top spatial might also be already a Geometry

this depends greatly on the model and the way it is imported.

The following is a optimisation for my physic models, but the base logic is similar,
you should be able to just but your material handeling in it instead of the mesh stripping.

[java]
private void stripMaterialsAndData(final Spatial model) {
System.out.println("scanning " + model.getName());
if (model instanceof Geometry) {
final Mesh mesh = ((Geometry) model).getMesh();
// kill all except position and index for reducing physicdata
mesh.clearBuffer(Type.BindPoseNormal);
mesh.clearBuffer(Type.BindPosePosition);
mesh.clearBuffer(Type.BindPoseTangent);
mesh.clearBuffer(Type.Binormal);
mesh.clearBuffer(Type.BoneIndex);
mesh.clearBuffer(Type.BoneWeight);
mesh.clearBuffer(Type.Color);
mesh.clearBuffer(Type.HWBoneIndex);
mesh.clearBuffer(Type.HWBoneWeight);
mesh.clearBuffer(Type.Normal);
mesh.clearBuffer(Type.Size);
mesh.clearBuffer(Type.Tangent);
mesh.clearBuffer(Type.TexCoord);
mesh.clearBuffer(Type.TexCoord2);
mesh.clearBuffer(Type.TexCoord3);
mesh.clearBuffer(Type.TexCoord4);
mesh.clearBuffer(Type.TexCoord5);
mesh.clearBuffer(Type.TexCoord6);
mesh.clearBuffer(Type.TexCoord7);
mesh.clearBuffer(Type.TexCoord8);
}
if (model instanceof Node) {
final Node casted = (Node) model;
for (final Spatial child : casted.getChildren()) {
this.stripMaterialsAndData(child);
}
}
}
[/java]

http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/SceneGraphVisitorAdapter.html

hi all i come back

I try this code and the model’s textures are ever blured
I don’t understand why.

do you have an idea?

Thanks for your help

[java]
if (model instanceof Geometry) {
Texture myTexture = ((Geometry) model).getMaterial().getTextureParam(“DiffuseMap”).getTextureValue();
myTexture.setMagFilter(Texture.MagFilter.Bilinear);
}
if (model instanceof Node) {
final Node casted = (Node) model;
for (final Spatial child : casted.getChildren()) {
this.addFilterToTexture(child);
}
}

[/java]

Any chance of posting a picture of what you are seeing? Even better if you can post a pic of what you expect to see as well.

Try to set the anisotopic filter on the textures, should be in the texture object as well called filtering or so

I resolve with :

[java]

myTexture.setMagFilter(Texture.MagFilter.Nearest);
myTexture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);

[/java]

thanks for your answer :slight_smile:

1 Like

^^ That was not even the one I meant, but if it works,^^

I meant tex.setAnisotropicFilter(16);
Then you can probably reactivate the mipmap based ones as well, since without you get some pixelated effects, depending on what you do.

@Empire Phoenix said: ^^ That was not even the one I meant, but if it works,^^

I meant tex.setAnisotropicFilter(16);
Then you can probably reactivate the mipmap based ones as well, since without you get some pixelated effects, depending on what you do.

your are all right with setAnisotropicFilter it is better.

thank you very much :slight_smile: