How to get Lighting on ogre imported models?

I have been making some baby steps into making models in Google Sketchup and using a plugin, I am able to export an xml file and a material file. The mesh loads in perfectly but the thing is unshaded, as in not affected by light sources. Can I modify this behaviour by tweaking the material file or something?



This is the material file that the exporter outputted:



[java]material SketchupDefault

{

technique

{

pass

{

diffuse 1.0 1.0 1.0

ambient 1.0 1.0 1.0

}

}

}



material SketchupDefault_Back

{

technique

{

pass

{

diffuse 0.643137254901961 0.698039215686274 0.733333333333333

ambient 0.643137254901961 0.698039215686274 0.733333333333333

}

}

}[/java]

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:materials_overview

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:j3m_material_files

https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:material_editing

like glaucomardano said, you have to use j3m. Before you ask: You can’t do it with standard material file.



So 2 options:

  • in game load model and assign j3m to it.
  • create j3o and assign j3m to it(in JMP) and load j3o in game

That material looks fine. Did you add directional and/or point lights to the scene?

Yes I have a point light which lights my scenery and objects I create and add fine with the Lighting material.



Ok so the material file is not used at all, or only creates a material with no lighting effect? Would it be possible to expand the ogre mesh load function so it also loads the material file and use Lighting shader instead? But I guess since all texture coords are in place for the mesh its just as easy to do the j3m file.



A bit unrelated to this, but a performance question: If you use e.g. Lighting shader but dont use specular maps, parallax maps or any of the other besides a pure texture will the shader pipeline still use GPU time on “ignoring” these other maps? Or would one be wise to chop the code of the shader to its bare bones? I dont have any experience in these things so I am just viewing this from a programmers perspective, where if the code has all these tests to see if it got this texture or that texture, it still uses GPU on these things. Or does the engine dynamically fit the shader depending on what layers of textures you have added?

I think yes. About the “unshaded” effect, it’s very weird. Try to add the specular param by hand in your material file.

That material file uses the lighting shader. It could be another issue. Are you using jME3 beta?

Ah I found the reason. I had an ambient light that was set to color ColorRGBA.White.mult(1.3f) as well as the material file has same colour as diffuse and ambient, so it turned out bright white all over! :slight_smile:



I was able to show it correctly now with lower ambient light and a material ambient that was turned down a bit. :slight_smile: