Textures, Materials and SDK

Hello everybody,
I’m doing some tests concerning the saving of the Materials of the 3D models.
Here is a simple code snippet:

    /**
     * Save Material to j3m file.
     * 
     * @param material
     * @param file
     */
    private void writeJ3m(Material material, File file) {
        try {
            J3MExporter j3mExporter = new J3MExporter();
            j3mExporter.save(material, file);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

With engine version 3.5.2-stable texture parameters are saved like this:

Material Body_Material : Common/MatDefs/Light/PBRLighting.j3md {

    MaterialParameters {
      EmissivePower : 3.0
      BackfaceShadows : false
      Roughness : 0.30151135
      EmissiveIntensity : 2.0
      Glossiness : 1.0
      BaseColor : 0.8 0.8 0.8 1.0
      ParallaxHeight : 0.05
      Metallic : 0.4
      NormalType : 1.0
      Emissive : 0.0 0.0 0.0 1.0
      NormalMap : WrapRepeat_S WrapRepeat_T "Models/Proto/body_normal.jpg"
      BaseColorMap : WrapRepeat_S WrapRepeat_T "Models/Proto/body_diffuse.jpg"
      Specular : 1.0 1.0 1.0 1.0
    }

    AdditionalRenderState {
      PointSprite On
    }
}

With version 3.6.0-beta1 the MinBilinearNoMipMaps field is also added in the texture parameters.

Material Body_Material : Common/MatDefs/Light/PBRLighting.j3md {

    MaterialParameters {
      EmissivePower : 3.0
      BackfaceShadows : false
      Roughness : 0.30151135
      EmissiveIntensity : 2.0
      Glossiness : 1.0
      BaseColor : 0.8 0.8 0.8 1.0
      ParallaxHeight : 0.05
      Metallic : 0.4
      NormalType : 1.0
      Emissive : 0.0 0.0 0.0 1.0
      NormalMap : WrapRepeat_S WrapRepeat_T MinBilinearNoMipMaps "Models/Proto/body_normal.jpg"
      BaseColorMap : WrapRepeat_S WrapRepeat_T MinBilinearNoMipMaps "Models/Proto/body_diffuse.jpg"
      Specular : 1.0 1.0 1.0 1.0
    }

    AdditionalRenderState {
      PointSprite On
    }
}

Opening both files with the SDK editor I get this error:

Error while locating rapRepeat_S WrapRepeat_T MinBilinearNoMipMaps "Models/Proto/body_normal.jpg
com.jme3.asset.AssetNotFoundException: rapRepeat_S WrapRepeat_T MinBilinearNoMipMaps "Models/Proto/body_normal.jpg (Flipped)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:385)
	at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:407)
	at com.jme3.gde.core.properties.preview.TexturePreview$1.call(TexturePreview.java:97)
	at com.jme3.gde.core.properties.preview.TexturePreview$1.call(TexturePreview.java:92)
	at com.jme3.app.AppTask.invoke(AppTask.java:147)
	at com.jme3.app.LegacyApplication.runQueuedTasks(LegacyApplication.java:751)
	at com.jme3.app.LegacyApplication.update(LegacyApplication.java:767)
	at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:296)
	at com.jme3.system.awt.AwtPanelsContext.updateInThread(AwtPanelsContext.java:219)
	at com.jme3.system.awt.AwtPanelsContext.access$100(AwtPanelsContext.java:45)
	at com.jme3.system.awt.AwtPanelsContext$AwtPanelsListener.update(AwtPanelsContext.java:72)
	at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:126)
	at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:160)
	at java.base/java.lang.Thread.run(Thread.java:834)

Error while locating rapRepeat_S WrapRepeat_T MinBilinearNoMipMaps "Models/Proto/body_diffuse.jpg
com.jme3.asset.AssetNotFoundException: rapRepeat_S WrapRepeat_T MinBilinearNoMipMaps "Models/Proto/body_diffuse.jpg (Flipped)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:385)
	at com.jme3.asset.DesktopAssetManager.loadTexture(DesktopAssetManager.java:407)
	at com.jme3.gde.core.properties.preview.TexturePreview$1.call(TexturePreview.java:97)
	at com.jme3.gde.core.properties.preview.TexturePreview$1.call(TexturePreview.java:92)
	at com.jme3.app.AppTask.invoke(AppTask.java:147)
	at com.jme3.app.LegacyApplication.runQueuedTasks(LegacyApplication.java:751)
	at com.jme3.app.LegacyApplication.update(LegacyApplication.java:767)
	at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:296)
	at com.jme3.system.awt.AwtPanelsContext.updateInThread(AwtPanelsContext.java:219)
	at com.jme3.system.awt.AwtPanelsContext.access$100(AwtPanelsContext.java:45)
	at com.jme3.system.awt.AwtPanelsContext$AwtPanelsListener.update(AwtPanelsContext.java:72)
	at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:126)
	at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:160)
	at java.base/java.lang.Thread.run(Thread.java:834)

Loading the 3d model into a jme application there are no errors.

  1. I was wondering if the problem is with the SDK or the engine.
  2. Is it possible to specify the WrapRepeat_S, WrapRepeat_T and MinBilinearNoMipMaps parameters in the SDK editor?
    Removing them from the j3m file, the editor no longer shows errors.

I’m using SDK Release 3.5-sdk2

2 Likes

…which doesn’t yet support features added in the (unreleased) 3.6 libraries.

And not even those from version 3.5.2 apparently…

Afaik those texture parameters have been there for ages, I wonder if there is a bug/regression in SDK that can not properly parse them.

Not sure if this is related or not, but I noticed “W” is somehow omitted in “rapRepeat_S”.

1 Like

Thanks for your reply Ali. Yes, that’s weird, I noticed that too… :thinking:
Regarding the extra parameter MinBilinearNoMipMaps added by the 3.6.0-beta1 version, can you confirm that it is correct?

@rickard @tonihele , could you tell us more about this topic please?

Yes, it should be correct but if you want to be sure you can remove it from the j3m file and try again. Note that MinBilinearNoMipMaps is not a new param, it has been there for a long time though.

2 Likes

Could be. I’ll have to look into it.

Edit: And thanks for reporting :wink:

Edit 2: Issue tracked here: Material parsing problem · Issue #463 · jMonkeyEngine/sdk · GitHub

4 Likes

There’s a proposed fix here:

Root causes: 1. The SDK was hardcoded to only handle “Flip” and “Repeat” and replaced the texture line in the material on save. 2. The function that removed quotations on texture name didn’t handle other options and cut off the setting names causing the exception.

Fix: Properly handling all settings is out of scope for 3.6, but this PR allows other settings to stay, loads and saves them properly.

I’ll leave the PR open for a while, in case someone else wants to test/review it.

3 Likes