[Solved] Material colors look washed out

Hi there.
I made a .j3m material for my imported blender model following this tutorial: Hello Material
The problem is that the color looks washed out.

It looks like this in JME3:

This is how it looks in Blender:

And this is the texture image I’m using:

It doesn’t even look like the material editor’s thumbnail:

Here’s the material’s code:

Material My Material : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
DiffuseMap : Repeat Textures/Asphalt3D/TexturesCom_2x2_Asphalt4_1024_albedo.png
NormalMap : Repeat Textures/Asphalt3D/TexturesCom_2x2_Asphalt4_1024_normal.png
SpecularMap : Repeat Textures/Asphalt3D/TexturesCom_2x2_Asphalt4_1024_ao.png
Diffuse : 1 1 1 1
Specular : 1 1 1 1
Ambient : 1 1 1 1
UseMaterialColors : true
}
AdditionalRenderState {
}
}

What am I missing?

Thanks for reading.

Your code looks fine from here.

1 Like

Did you apply this material to the cube?

It’s probably lighting related… or using the AO texture as a specular map.

Hard to say for sure without seeing the code. So far it’s another “how long is this piece of string I’m holding” problem.

    Spatial asphaltCube = assetManager.loadModel("Models/AsphaltCube2.j3o");
    Material material = assetManager.loadAsset(
            new MaterialKey("Materials/AsphaltMaterial.j3m"));
    asphaltCube.setMaterial(material);
    
    rootNode.attachChild(asphaltCube);

    /**
     * A white, directional light source
     */
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun);
    
    flyCam.setMoveSpeed(10);

Sorry. ._.
Here’s the project.

https://github.com/LifeIsAlgorithms/Hello-stuff/tree/master/JME3/HelloMaterial

https://github.com/LifeIsAlgorithms/Hello-stuff/blob/master/JME3/HelloMaterial/assets/Materials/AsphaltMaterial.j3m#L5

Removing SpecularMap makes no difference…

You must have an ambient light, too… but you didn’t include that in the snippet.

When I have time, I will click through to the project. Might not be until September, though.

Hopefully others have more time and can drill in.

Already tried ambient light + directional light, makes no difference.

This is literally the entire thing it would seem, @pspeed:

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.asset.MaterialKey;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;

/**
 * This is the Main Class of your Game. You should only do initialization here.
 * Move your Logic into AppStates or Controls
 * @author normenhansen
 */
public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        Spatial asphaltCube = assetManager.loadModel("Models/AsphaltCube2.j3o");
        Material material = assetManager.loadAsset(
                new MaterialKey("Materials/AsphaltMaterial.j3m"));
        asphaltCube.setMaterial(material);
        
        rootNode.attachChild(asphaltCube);

        /**
         * A white, directional light source
         */
        DirectionalLight sun = new DirectionalLight();
        sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
        sun.setColor(ColorRGBA.White);
        rootNode.addLight(sun);
        
        flyCam.setMoveSpeed(10);
    }

    @Override
    public void simpleUpdate(float tpf) {
    }

    @Override
    public void simpleRender(RenderManager rm) {
    }
}

Doesn’t seem like there are any ambient lights at all, though they are listed under imports.

My theory is that the j3o file containing the model may have a light attached to it that could’ve been in the scene back in Blender since some moron decided it would be great for the blend to j3o importer to not filter out random shit like lights and cameras.

@LaPsicopata You could try exporting your 3D model in some other format and see if that works.

2 Likes

Try using the SDK to generate the material.

https://wiki.jmonkeyengine.org/sdk/material_editing.html#using-j3m-materials

If that works then compare the generated file to yours and make the appropriate adjustments.

@MoffKalast suggestion to use a different format is also a good idea.

1 Like

Thanks for the answer. I’ll try it right now.

Ah, usually when someone posts a link to a project then I assume it was something that wouldn’t fit in a post.

A post is always better for all involved… including the person reading this thread three years from now with the same issue. So always preferred when possible.

Sorry for the late answer.

@MoffKalast I tried your suggestions. There were a camera and a light source from the .blend file. I deleted them, but nothing changed.
When I tried to use other formats, I got some other issues:

  • .obj:

    • Trying to load the .obj file or to convert it to .j3o: java.lang.ClassCastException: com.jme3.asset.AssetKey cannot be cast to com.jme3.asset.TextureKey
  • .dae:

    • Trying to load it: com.jme3.asset.AssetLoadException: No loader registered for type “dae”
      I searched in the forum, and the suggestion was to download a plugin in
      Plugins → available plugins… but it doesn’t exist.
  • Ogre formats: I could never get it installed properly. When I try to export a model, I got errors in blender’s console.

@mitm I also tried your suggestion. I changed the geometry material from the properties window on Scene Editor. But it didn’t work.

Okay I see you have the blend file in the repo as well. Here’s a zip containing the export of that cube and its UVs in ogre.xml. Loading up Cube.mesh.xml should give you a node with one child geom.

If that doesn’t work then I’m out of ideas.

I used Ogre also and it looks fine when I generated the material, set the images in the material using (repeat) and used an ambient light in the scene.

This is the material as default generated,

Material MyMaterial : Common/MatDefs/Light/Lighting.j3md {
    MaterialParameters {
        Diffuse : 0.64000005 0.64000005 0.64000005 1.0
        UseMaterialColors : true
        ParallaxHeight : 0.05
        Ambient : 0.8 0.8 0.8 1.0
        GlowColor : 0.0 0.0 0.0 1.0
        BackfaceShadows : false
        DiffuseMap : Repeat Models/TexturesCom_2x2_Asphalt4_1024_albedo.png
        Specular : 0.21782178 0.21782178 0.21782178 1.0
        Shininess : 12.5
        NormalMap : Repeat Models/TexturesCom_2x2_Asphalt4_1024_normal.png
        SpecularMap : Repeat Models/TexturesCom_2x2_Asphalt4_1024_height.png
    }
    AdditionalRenderState {
      PointSprite On
      FaceCull Back
      AlphaTestFalloff 0.0
      DepthWrite On
      ColorWrite On
      PolyOffset 0.0 0.0
      DepthTest On
      Blend Off
      Wireframe Off
    }
}
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Node;

/**
 * This is the Main Class of your Game. You should only do initialization here.
 * Move your Logic into AppStates or Controls
 * @author normenhansen
 */
public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        flyCam.setMoveSpeed(10f);
        viewPort.setBackgroundColor(ColorRGBA.Gray);
        
        Node geom = (Node) assetManager.loadModel("Models/Cube.mesh.j3o");
        /** A white, directional light source */ 
        DirectionalLight sun = new DirectionalLight();
        sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
        sun.setColor(ColorRGBA.White);
        /** A white ambient light source. */ 
        AmbientLight ambient = new AmbientLight();
        ambient.setColor(ColorRGBA.White);
        
        rootNode.addLight(ambient); 
        rootNode.addLight(sun); 
        rootNode.attachChild(geom);
    }

    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
}

Edit: Changed background to gray to make it pop.

Used the same material, TangentBinormalGenerator, and toned town the ambient to .2f and got a dam near identical box as blender.

    @Override
    public void simpleInitApp() {
        flyCam.setMoveSpeed(10f);
        viewPort.setBackgroundColor(ColorRGBA.Gray);

        Node node = (Node) assetManager.loadModel("Models/Cube.mesh.j3o");
        Geometry geo = (Geometry) node.getChild("Material");
        Mesh mesh = geo.getMesh();
        TangentBinormalGenerator.generate(mesh);
        /** A white, directional light source */ 
        DirectionalLight sun = new DirectionalLight();
        sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
        sun.setColor(ColorRGBA.White);
        /** A white ambient light source. */ 
        AmbientLight ambient = new AmbientLight();
        ambient.setColor(ColorRGBA.White.mult(.2f));
        
        rootNode.addLight(ambient); 
        rootNode.addLight(sun); 
        rootNode.attachChild(node);
    }

@MoffKalast I tried just using the ogre files, I didn’t worked.
It seems the problem was the .j3m file, since I pasted @mitm material’s code and the model looked as good as in his screenshot. You both deserve a beer. <3

I really appreciate your help.
Thank you.