How can I set texture with unshaded material?

hi, I made a simple test game in android.
It is just simply a human walking in town.
however it’s not good performance. (about 30fps ave in Nexus7)
I think it’s because they are using lighting material. (I googled forum)
so, I have changed the code like this.

model = (Node)app.getAssetManager().loadModel(“Models/human/human.mesh.xml”);
Material mat = new Material( app.getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setTexture(“NormalMap”, app.getAssetManager().loadTexture(“Models/human/human.jpg”));

But texture map is not correct. it seems to be not applied UV coords.
so I have questions.

  1. how can I set texture with Unshaded.j3md correctly? or…
  2. how can I turn off “shading” in blender, and exporting unshaded material ? or…
  3. how do I write .material file to “unshaded” ?

I want to up to performance anyway :frowning:
please help me.
thanks, and sorry my bad English.

Hum… Why do you want to add a normal map to a texture that ignores light effects???
Try instead setting the diffuseMap…

1 Like

thanks reply.
In fact I don’t understand well.
merely I saw the advice in this forum… they said “by not using lighting material, the performance can be improved”.
btw, I have changed my code to use diffuse map.

Material mat = new Material( app.getAssetManager(), “Models/human/Lighting.j3md”);
mat.setTexture(“DiffuseMap”, app.getAssetManager().loadTexture(“Models/human/human.jpg”));

but still corrupt the texture map, and fps doesn’t improve…

Now u gone back to a lighted model again :o. You should use a ColorMap for the model if you want Unshaded. If the texture looks wrong, try flip it upside down.

How many vertices does your model have anyways?


thanks wezrule!

Material mat = new Material( getAssetManager(), “Models/human/Unshaded.j3md”);
mat.setTexture( “ColorMap”, getAssetManager().loadTexture( new TextureKey( “Models/human/human.jpg”, false)));
model.setMaterial( mat );

perfect :smiley:
I use low poly character (about 1K vertices) and town( sample of JME. a total of about 6K vertices).
If use default material(maybe lighting), average 30fps.
then change ColorMap material. now I’ve got 60fps :smiley:

However, I have a new problem.
human’s texture is OK. but town’s are bad.


[in game]

hmm… what’s mystery patchworks?
I converted file from town.scene to town.j3o because I needed assign name of all submeshes of town. ( I don’t know how do assign submeshes name, in mesh.xml file without using JMESDK).
It may be the cause…
I I tried flip and no flip, but both of failed.
this is my code.

sceneModel = assetManager.loadModel(“Scenes/town/main.j3o”);
private void updateMaterial(Spatial spatial) {
try {
if (spatial instanceof Node) {
Node node = (Node) spatial;
for (int i = 0; i < node.getQuantity(); i++) {
Spatial child = node.getChild(i);
} else if (spatial instanceof Geometry) {
Geometry geo = (Geometry) spatial;
Material mat = new Material( getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setTexture( “ColorMap”, getAssetManager().loadTexture( new TextureKey( “Scenes/town/”+geo.getName()+".jpg", false)));
} catch (Exception err) {

I'm stuck.

OK I cleared problem.
It’s truely simple…
I wrote .material file like this.


lighting off

I didn’t need adding code something. wtf!
anyway, not using lighting is bit a sad :S
I think that should be affected by the light only nearby objects if possible…

For a lot of scenes/cases you can use baked in lighting - then pick key objects to give dynamic lighting.

hmm… you mean I will bake lightmap texture in Blender or via code??

Bake the lightmap in blender, and then apply it in code