jME3 can now load OBJ models with materials

Many people asked for this feature before, but I didn’t really feel the need to implement it.

To demonstrate the new power of this new feature, I imported the Sponza model, complete with normal maps and all.











Puh,…that looks marvelous! Good work (as always) What would be the fps without fixing it to 60?

Could it be that this broke the TangentBinormalGenerator? TestNormalMapping and my new Material Editor throw out lots of WARNUNG TangentBinormalGenerator 02:25:43 Binormal is flipped for vertex 479.…

ttrocha said:

Puh,...that looks marvelous! Good work (as always) What would be the fps without fixing it to 60?

Depends on video settings. on 5770, Lowest quality 640x480 is about 360-400 fps. Highest quality 1080p 24x super-sample is about 40-100 fps. The bottleneck is in fill rate right now, so the higher the resolution, the lower the framerate. 800,000 triangles is nothing for this video card so no problem there.
Before that, the bottleneck was too many draw calls- I had 400 objects! Through some changes to OBJLoader, I was able to use batching and reduce it to 20.

Could you give example code of how to do this?



I keep getting errors with loading in the textures.



Get a bunch of



WARNING DesktopAssetManager 4:42:10 PM Cannot locate resource: vase_plant.tga/F

WARNING DesktopAssetManager 4:42:10 PM Cannot locate resource: vase_plant_mask.tga/F/MIP



I found were to set



key.setGenerateMips(false);



in the OBJ loader but I have no idea what the /F is for.



This is trying to load in the Sponza model as well as other test models.



Thanks a bunch,

William

Thanks. I fixed this issue. It is trying to locate the textures in the root folder, rather than the folder where the OBJ model is, so now thats fixed.

Nice work Kirill!  That would be a sweet room for a physics and sound showcase :wink:

Heh, actually, the sponza is an ideal showcase for SSAO (screen-space ambient occlusion). You'll notice the lighting feels kinda unnatural due to lack of ambient light.

Cool.



I'm still not sure what to do to get the actual textures to show up.



If I just try and load the model with the line:



rootNode.attachChild((Node)assetManager.loadModel("sponza/Sponza.obj"));



I get following error when I move the mouse:



java.lang.ArrayIndexOutOfBoundsException: 16

at com.jme3.renderer.IDList.moveToNew(IDList.java:26)

at com.jme3.renderer.lwjgl.LwjglRenderer.setTexture(LwjglRenderer.java:1400)

at com.jme3.material.Material.render(Material.java:511)

at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:265)

at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:100)

at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:153)

at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:138)

at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:395)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:508)

at com.jme3.renderer.RenderManager.render(RenderManager.java:522)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:179)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:112)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:162)

at java.lang.Thread.run(Unknown Source)





I can set the "ShowNormals.j3md" mat to the model and will get the rainbow bright textures :P. Is there another material I'm supposed to be using?



Thanks again,

William

Ah I figured it out. The error I posted was if no light was added.



Put in a DirectionalLight and everything showed up.


You'll notice the lighting feels kinda unnatural due to lack of ambient light.


Is ambient light going to be implemented?

Thanks,
William

kirdel said:

Ah I figured it out. The error I posted was if no light was added.

Put in a DirectionalLight and everything showed up.

You'll notice the lighting feels kinda unnatural due to lack of ambient light.


Is ambient light going to be implemented?

Thanks,
William



Well, it definitely isn't supposed to crash if no light so there, so that's strange. I am going to check it out at some point.
To implement ambient light, you either have to use ambient occlusion baking, or a real-time solution like screen-space ambient occlusion. The latter is going to be implemented at some point.
For now, you can see how one could implement it in this scene in this video: http://www.youtube.com/watch?v=6IyMajvRWss

I’m currently working on a SSAO filter, based on the depth comparison algorithm.

So far i’ve got not so good not so bad results (looks a bit grainy)

here is a first attempt





i’m going to test it on sponza to see what it looks like

Wow, that was fast! You're a man of filters, lights, and shadows.

Who needs shiny water shaders when you have global illumination, right?

Momoko_Fan said:

Wow, that was fast!

Well don't give me too much credit, just took some things here an there, put that in JME, shaked a little and ...voil