Materials on imported models from blender

I’m a little confused. I’m trying to import models from blender and make them glow. However these models are UV mapped. So let’s say I have a pyramid that is uv-mapped to an image. I want to use this image to create the glow effect. However, just loading the model fill it with its material. I don’t know how to access its uv-mapped texture.



I have no idea how to proceed, and the more I search the more confused I become. Is there a way for an imported model (it’s directly imported from a .blender file) to have custom Uv-mapped textures for diffuse, normal, glow etc…? If this can be done, how do I do it from inside jmonkey???

you have to create j3m files(material files) and set it to j3o files(or ingame to models), its only way i think



and remember that UV coords are remembered in j3o, so you dont need to set anything in materials(only textures)



https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material?s[]=materials



when you exporting from .blend → j3o there is no way to get textures i think

Thanks for the quick reply!



So I have to recreate the materials I use in blender in jmonkey? If I understood correctly, I should call a diffuse map for the texture, a glow map for the other texture, set the material to my custom material etc…



Ok, sounds plausible, but I have already tampered with multiple materials which target different vertices. What if I want a model with a transparent material for the outside vertices and solid material for the inner vertices?



If i load the model immediately from a blender file, there’s no problem with multiple materials, but how could I set material files to multiple layers I only specified within blender??

i dont said its impossible to set lighting material for the same textures as exported .blend file have. it is possible i think by creating lighting material definition and copy diffuse map / normal / etc to it.



but the best way is to create j3m file, yes :slight_smile:



edit:



dont know if exporter loading .blend file load it with lighting or unshaded, but for each is diffrent name for diffuse texture:

for diffuse:

[java]mat.setTexture("ColorMap", assetManager.loadTexture(texture)); // with Unshaded.j3md[/java]

for lighting:

[java]mat.setTexture("DiffuseMap", assetManager.loadTexture(texture)); // with Lighting.j3md[/java]



so if blend → j3o create lighting material(contains normal maps / diffuse) then it could work



but dont try to do this… just use j3m files, its much easier.



BTW: it is better, becoue you can set additional shader parameters too

I just did it, thanks! I’m just tampering with importing blender models so this is a huge step forward!

one more thing:



with j3m files: sometimes you need to flip textures :wink:

and for normal maps: you need to generate tangents(if its not generated while converting to j3o)

You mentioned “generate tangents”. Where is this done? In Blender? Or in JMP?



I have read this in a few posts now, but I haven’t really understood why or where. I use normal mapping extensively.

you can do it by SceneComposer in JMP ;), second click on geometry(from list of spatials) → tools → “generate tangents”



it need UV coords contained in model

Thanks for the info. That worked really well and my model did look quite different (and better). So I’ll generate tangents on all my J3O files now.



However, I did have trouble finding the SceneComposer tab in JMP. It was minimized vertically on the left-hand side of the screen. Having dragged it out as an extra tab, I was then able the select the Geometry → tools → generate tangents. I write this in case someone else can’t find it.

How do you create a j3m material from a blender .material file?

My models work fine with mesh.xml and material, but when I make a j3o model and load it with the same texture, the texture is not uv mapped right.

@ettavsdro : Don’t double-post the same question please.

2 Likes