I have asked this question on Stackoverflow, but the question has gone under the “unanswer” pile, therefore I’m turning here to ask it. Here it goes :
I’m trying to import a model from Blender to JMonkeyEngine3 and it appears all black on the terrain, even if it’s perfectly fine in Blender. I’ve tried recalculating normals but it doesn’t seem to do anything, either in Blender or in JME3.
How can I fix this?
Here are some screenshot of the problem :
Exhibit A : as rendered in Blender
http://i.stack.imgur.com/DBnbg.jpg
Exhibit B : as rendered in JMonkeyEngine (note that I have other models loaded as well, and they look fine).
http://i.stack.imgur.com/lpxDG.jpg
You need to generate the tangents if you are using normal maps
use
TangentBinormalGenerator.generate(yourModel);
Uh, also: any light sources in your scene?
Yes, there is a white-yellowish DirectionalLight (as seen in the shadow of the building) and a dim ambient blue-sky light.
The trick about TangentBinormalGenerator.generate(yourModel); helps (it actually entirely fixed another problem with another model that I have), as I start to see some reflections in the textures where normals were applied, but the model is still as dark (like if it reflects no light at all).
This hut model is my first attempt in years in 3d modeling (my last experience was with TrueSpace 4, if you can imagine) and I’m fairly and certainly out of shape. This is also my first real serious attempt in OpenGL programming, so all the 3d stuff are not too familiar at the moment. Though I am an undergraduate in programming. Just so you know.
Here’s an overview of what the tangent generator does to the model :
http://mind2soft.com/_temp/3d_model_test_3.jpg
try to create a new Lighting material and assign it to you model.
If it works, so assign Textures to the material too.
Also, do you have UV map for your house model?
Like this one:
http://img264.imageshack.us/img264/8942/uvbi2.jpg
If no, so you will need to make uv map texture coordinates to apply textures correctly.
If you don’t know how, so just watch tutorials: blender UV mapping - Google Search
And goodLuck in game development!
Alright, so I got mad and deleted all textures and planned on restarting the whole censored thing. So in the first image is my rendered image in blender (No UV map… just applied a texture to the object, nothing fancy, mapped to the color.)
And here’s the rendered image in JME3
And I thought that it would be hard to model… importing is a real pain…
As you have been told a model for a 3d game needs to be UV-mapped. There is no other way to texture a model. Check the wiki, it contains info on how a game compatible model works and should look.
Setting to the UV map doesn’t work either, and I did follow this video.
No need to post another JME3 render… it’s the same thing.
Yes it does work. I see you use blender 2.49, theres a nice tutorial:
https://docs.google.com/fileview?id=0B9hhZie2D-fENDBlZDU5MzgtNzlkYi00YmQzLTliNTQtNzZhYTJhYjEzNWNk&hl=en
Also check this:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_asset
I don’t understand… why is there a blender model importer if I have to convert it into OgreXml… which supposedly doesn’t work with Blender 2.49b (requires 2.59+ as the JME IDE says)?
BTW: I can’t seem to export the model; in the IDE, it says that there is an error with the file. (and I do follow the tutorial)
Update : I did export into Wavefront (.obj) and it seems to work (though I have to play a little with the normals so the faces are showing upright), but the shadows are reversed; the light shines on dark faces and shadowed faces are lighter… This also is the case for a model (that actually loads well as a pure Blender model). And I’m not sure how to “reverse” the shadows.
it works… as i said above you did not create a new Lighting JME material.
Blender importer generates its own shader… it’s not usable sometimes…
Create new Lighting material and apply it to your model. It will solve many things.
Try something like:
[java]
// Set Diffuse Map
TextureKey tkDif = new TextureKey(“YOUR TEXTURE PATH”, true); // true or false depends on a model ogre/blender…
tkDif.setAnisotropy(2); //Better sharpness of a texture use 2 or 4 values
tkDif.setGenerateMips(true);
Texture diffuseTex = assetManager.loadTexture(tkDif);
diffuseTex.setWrap(Texture.WrapMode.Repeat);
matNew = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
matNew.setTexture(“DiffuseMap”, diffuseTex);
YOURHOUSEGEOMETRY.setMaterial(mat);
[/java]
AND USE BLENDER 2.6 PLEASE!!!
Make sue your light direction is the same as the direction you set to the shadow processor.
About the shadow, I use the PssmShadowRenderer and the direciton is set to [-1, -1, -1], opposite to light, as I understand it. The landscape and objects seem to cast shadow just right elsewhere.
I’m not sure I follow, about the lighting material. My model already has some material applied when I load it, through the .mtl file. So, I have to fetch the nodes compositing my model, and re-assign materials to them this way?
As for Blender 2.6, I’m using the one in the Ubuntu repositories. I will try and install 2.6 some time today…
Blender 2.6:
http://www.graphicall.org/
http://www.blender.org/download/get-blender/
When you load a blender model… i would recommend to assign a new material to get rid of some problems like in your way.
Create a new material with code or with JMP!
@yanick said:
About the shadow, I use the PssmShadowRenderer and the direciton is set to [-1, -1, -1], opposite to light, as I understand it. The landscape and objects seem to cast shadow just right elsewhere.
If your PssmShadowRenderer's direction is -1,-1,-1 the light direction MUST be -1,-1,-1 in order to have a correct illumination.
This, correct normals direction (recompute them in blender before importing if you are not sure), and generated tangents, should do it, period.
No need to change the materials.
@nehon said:
If your PssmShadowRenderer's direction is -1,-1,-1 the light direction MUST be -1,-1,-1 in order to have a correct illumination.
This, correct normals direction (recompute them in blender before importing if you are not sure), and generated tangents, should do it, period.
No need to change the materials.
Also, doesn't a direction vector have to be normalized? -1,-1,-1 is not a normalized vector.
@normen said:
Also, doesn't a direction vector have to be normalized? -1,-1,-1 is not a normalized vector.
that does not matter for the shadow renderer, the direction is just used to compute the projection matrix.
Installed blender 2.61, and now I can’t load anything in JME. Neither .blend, or .obj and I install the OgreXML into the .blender/scripts (it says it installed successfully), but I don’t see it in Blender when exporting the model. :x