See model texture only when camera close

Hello to all. I would like some help on an issue.

I hava a scene with 3 objects. One teapot, the ninja from the examples and one model that i have made and exported in ogrexml.

The problem is that the teapot and the ninja can be viewed corectly but my model is black. I can see it correctly only when the camera is very close to the object. I have attached two screenshots of the issue.



Also i had the same problem when loading the elephant from the tutorials.



This is the code i have.



Thanks in advance.



package my_first_jm3_scene;

import hello.HelloAssets;

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.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
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 FirstScene extends SimpleBulletApplication {

   private Geometry floor;
   private Node nionios;
   
   @Override
   public void simpleInitApp() {
      setuplight();
      setupFloor();
      load_models("nionios/nionios.mesh.xml");
      
   }
   
   /**
    * 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(String model) {
      //This shows the path where the folder Models is located
      assetManager.registerLocator("assets/", "com.jme3.asset.plugins.ClasspathLocator");
       
        // load a model
      nionios = (Node) assetManager.loadModel("Models/"+model);
      nionios.setLocalTranslation(0, -2, 0);
      nionios.setLocalScale(0.01f);
        rootNode.attachChild(nionios);

        Geometry teapot = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
        teapot.setMaterial(mat);
        teapot.setLocalTranslation(new Vector3f(1, 0, 0));
        rootNode.attachChild(teapot);
        
     // Load a Ninja model from jme3testdata.jar
        Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.meshxml");
        ninja.setLocalScale(0.01f);
        ninja.rotate(0.0f , -3.0f , 0.0f);
        ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);
        
        rootNode.attachChild(ninja);
   }
   
   public void setuplight() {
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-0.5f, -1f, -0.3f).normalizeLocal());
        rootNode.addLight(dl);

        dl = new DirectionalLight();
        dl.setDirection(new Vector3f(0.5f, -0.1f, 0.3f).normalizeLocal());
        rootNode.addLight(dl);
   }
   
   /**
    * 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);
        key.setGenerateMips(true);
        Texture tex = assetManager.loadTexture(key);
        tex.setMinFilter(Texture.MinFilter.Trilinear);
        mat.setTexture("m_ColorMap", tex);
        
        Box floor = new Box(Vector3f.ZERO, 100, 1f, 100);
        Geometry floorGeom = new Geometry("Floor", floor);
        floorGeom.setMaterial(mat);
        floorGeom.updateModelBound();

        PhysicsNode tb=new PhysicsNode(floorGeom,new MeshCollisionShape(floorGeom.getMesh()),0);
        rootNode.attachChild(tb);
        tb.setLocalTranslation(new Vector3f(0f,-6,0f));
        tb.updateModelBound();
        tb.updateGeometricState();
        getPhysicsSpace().add(tb);
    }
   
   /**
    * @param args
    */
   public static void main(String[] args) {
      FirstScene app = new FirstScene();
      app.start();

   }
}

had a similar problem, do you use dds textures? they have a internal lod system that in lowest is normally just 1x1 black

Empire Phoenix said:

had a similar problem, do you use dds textures? they have a internal lod system that in lowest is normally just 1x1 black


I dont know. I have used the exporter from blender and the ogremax exporter for 3ds max but with both i get the same result.

my .material file is:



material nionios
{
   technique
   {
      pass
      {
         ambient 0.588235 0.588235 0.588235 1
         diffuse 0.588235 0.588235 0.588235 1
         specular 0 0 0 10 0

         texture_unit
         {
            texture 4_nionios.jpg
         }
      }

   }

}


I just tested the same code on a linux installation with an nvidia graphics card and it works perfectly.

The problem is with windows 7 OS and an Ati graphics card.

Can anyone explaine why this is happening??? :?

What do you mean you have the same problem with elephant? Does the elephant appear black unless you come really close?

Also, why is that custom model of yours increase in size from the 1st screenshot to the 2nd (clearly the model appears the same size as the ninja from far in 1 screenshot, but appears much larger in proportion at the 2nd screenshot). Can you explain that?

Momoko_Fan said:

What do you mean you have the same problem with elephant? Does the elephant appear black unless you come really close?
Also, why is that custom model of yours increase in size from the 1st screenshot to the 2nd (clearly the model appears the same size as the ninja from far in 1 screenshot, but appears much larger in proportion at the 2nd screenshot). Can you explain that?


About The example with the elephant yes. It is black and only when the camera is very close I can see the color. About the size the ninja is located behind and down from the other model. So it is normal to be smaller from the other when the camera is closer to the custom model. 

I think I fixed this issue. Update from SVN and try again :slight_smile:

Momoko_Fan said:

I think I fixed this issue. Update from SVN and try again :)

Today i downloaded the newest nightly build but the problem is still the same. I tested both my model and the elephant example with no luck.

Then I can't help you, sorry.

I can't reproduce the problem here, so I can't debug it. I tried the elephant, with the source code and material file you gave in the thread, and the elephant doesn't get darker.

I already fixed two bugs related to this issue, the DDS darkening mipmaps and shininess of 0 causing clipping. This is probably a video-card related issue.